Skip to content

Commit 4fd48b4

Browse files
committed
Merge branch 'for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup updates from Tejun Heo: "Nothing too interesting. Rik made cpuset cooperate better with isolcpus and there are several other cleanup patches" * 'for-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cpuset, isolcpus: document relationship between cpusets & isolcpus cpusets, isolcpus: exclude isolcpus from load balancing in cpusets sched, isolcpu: make cpu_isolated_map visible outside scheduler cpuset: initialize cpuset a bit early cgroup: Use kvfree in pidlist_free() cgroup: call cgroup_subsys->bind on cgroup subsys initialization
2 parents a1480a1 + 34ebe93 commit 4fd48b4

File tree

6 files changed

+29
-12
lines changed

6 files changed

+29
-12
lines changed

Documentation/cgroups/cpusets.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,10 @@ Put simply, it costs less to balance between two smaller sched domains
392392
than one big one, but doing so means that overloads in one of the
393393
two domains won't be load balanced to the other one.
394394

395-
By default, there is one sched domain covering all CPUs, except those
396-
marked isolated using the kernel boot time "isolcpus=" argument.
395+
By default, there is one sched domain covering all CPUs, including those
396+
marked isolated using the kernel boot time "isolcpus=" argument. However,
397+
the isolated CPUs will not participate in load balancing, and will not
398+
have tasks running on them unless explicitly assigned.
397399

398400
This default load balancing across all CPUs is not well suited for
399401
the following two situations:
@@ -465,6 +467,10 @@ such partially load balanced cpusets, as they may be artificially
465467
constrained to some subset of the CPUs allowed to them, for lack of
466468
load balancing to the other CPUs.
467469

470+
CPUs in "cpuset.isolcpus" were excluded from load balancing by the
471+
isolcpus= kernel boot option, and will never be load balanced regardless
472+
of the value of "cpuset.sched_load_balance" in any cpuset.
473+
468474
1.7.1 sched_load_balance implementation details.
469475
------------------------------------------------
470476

include/linux/sched.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ extern asmlinkage void schedule_tail(struct task_struct *prev);
337337
extern void init_idle(struct task_struct *idle, int cpu);
338338
extern void init_idle_bootup_task(struct task_struct *idle);
339339

340+
extern cpumask_var_t cpu_isolated_map;
341+
340342
extern int runqueue_is_locked(int cpu);
341343

342344
#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)

init/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ asmlinkage __visible void __init start_kernel(void)
654654
page_writeback_init();
655655
proc_root_init();
656656
nsfs_init();
657-
cgroup_init();
658657
cpuset_init();
658+
cgroup_init();
659659
taskstats_init_early();
660660
delayacct_init();
661661

kernel/cgroup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,10 +3806,7 @@ static void *pidlist_allocate(int count)
38063806

38073807
static void pidlist_free(void *p)
38083808
{
3809-
if (is_vmalloc_addr(p))
3810-
vfree(p);
3811-
else
3812-
kfree(p);
3809+
kvfree(p);
38133810
}
38143811

38153812
/*
@@ -5040,6 +5037,9 @@ int __init cgroup_init(void)
50405037
WARN_ON(cgroup_add_dfl_cftypes(ss, ss->dfl_cftypes));
50415038
WARN_ON(cgroup_add_legacy_cftypes(ss, ss->legacy_cftypes));
50425039
}
5040+
5041+
if (ss->bind)
5042+
ss->bind(init_css_set.subsys[ssid]);
50435043
}
50445044

50455045
cgroup_kobj = kobject_create_and_add("cgroup", fs_kobj);

kernel/cpuset.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
622622
int csn; /* how many cpuset ptrs in csa so far */
623623
int i, j, k; /* indices for partition finding loops */
624624
cpumask_var_t *doms; /* resulting partition; i.e. sched domains */
625+
cpumask_var_t non_isolated_cpus; /* load balanced CPUs */
625626
struct sched_domain_attr *dattr; /* attributes for custom domains */
626627
int ndoms = 0; /* number of sched domains in result */
627628
int nslot; /* next empty doms[] struct cpumask slot */
@@ -631,6 +632,10 @@ static int generate_sched_domains(cpumask_var_t **domains,
631632
dattr = NULL;
632633
csa = NULL;
633634

635+
if (!alloc_cpumask_var(&non_isolated_cpus, GFP_KERNEL))
636+
goto done;
637+
cpumask_andnot(non_isolated_cpus, cpu_possible_mask, cpu_isolated_map);
638+
634639
/* Special case for the 99% of systems with one, full, sched domain */
635640
if (is_sched_load_balance(&top_cpuset)) {
636641
ndoms = 1;
@@ -643,7 +648,8 @@ static int generate_sched_domains(cpumask_var_t **domains,
643648
*dattr = SD_ATTR_INIT;
644649
update_domain_attr_tree(dattr, &top_cpuset);
645650
}
646-
cpumask_copy(doms[0], top_cpuset.effective_cpus);
651+
cpumask_and(doms[0], top_cpuset.effective_cpus,
652+
non_isolated_cpus);
647653

648654
goto done;
649655
}
@@ -666,7 +672,8 @@ static int generate_sched_domains(cpumask_var_t **domains,
666672
* the corresponding sched domain.
667673
*/
668674
if (!cpumask_empty(cp->cpus_allowed) &&
669-
!is_sched_load_balance(cp))
675+
!(is_sched_load_balance(cp) &&
676+
cpumask_intersects(cp->cpus_allowed, non_isolated_cpus)))
670677
continue;
671678

672679
if (is_sched_load_balance(cp))
@@ -748,6 +755,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
748755

749756
if (apn == b->pn) {
750757
cpumask_or(dp, dp, b->effective_cpus);
758+
cpumask_and(dp, dp, non_isolated_cpus);
751759
if (dattr)
752760
update_domain_attr_tree(dattr + nslot, b);
753761

@@ -760,6 +768,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
760768
BUG_ON(nslot != ndoms);
761769

762770
done:
771+
free_cpumask_var(non_isolated_cpus);
763772
kfree(csa);
764773

765774
/*

kernel/sched/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ __read_mostly int scheduler_running;
306306
*/
307307
int sysctl_sched_rt_runtime = 950000;
308308

309+
/* cpus with isolated domains */
310+
cpumask_var_t cpu_isolated_map;
311+
309312
/*
310313
* this_rq_lock - lock this runqueue and disable interrupts.
311314
*/
@@ -5811,9 +5814,6 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)
58115814
update_top_cache_domain(cpu);
58125815
}
58135816

5814-
/* cpus with isolated domains */
5815-
static cpumask_var_t cpu_isolated_map;
5816-
58175817
/* Setup the mask of cpus configured for isolated domains */
58185818
static int __init isolated_cpu_setup(char *str)
58195819
{

0 commit comments

Comments
 (0)