Skip to content

Commit c188f33

Browse files
Waiman-Longhtejun
authored andcommitted
cgroup/cpuset: Account for boot time isolated CPUs
With the "isolcpus" boot command line parameter, we are able to create isolated CPUs at boot time. These isolated CPUs aren't fully accounted for in the cpuset code. For instance, the root cgroup's "cpuset.cpus.isolated" control file does not include the boot time isolated CPUs. Fix that by looking for pre-isolated CPUs at init time. The prstate_housekeeping_conflict() function does check the HK_TYPE_DOMAIN housekeeping cpumask to make sure that CPUs outside of it can only be used in isolated partition. Given the fact that we are going to make housekeeping cpumasks dynamic, the current check may not be right anymore. Save the boot time HK_TYPE_DOMAIN cpumask and check against it instead of the upcoming dynamic HK_TYPE_DOMAIN housekeeping cpumask. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 3c2acae commit c188f33

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

kernel/cgroup/cpuset.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,12 @@ static cpumask_var_t subpartitions_cpus;
224224
*/
225225
static cpumask_var_t isolated_cpus;
226226

227+
/*
228+
* Housekeeping (HK_TYPE_DOMAIN) CPUs at boot
229+
*/
230+
static cpumask_var_t boot_hk_cpus;
231+
static bool have_boot_isolcpus;
232+
227233
/* List of remote partition root children */
228234
static struct list_head remote_children;
229235

@@ -1823,15 +1829,15 @@ static void remote_partition_check(struct cpuset *cs, struct cpumask *newmask,
18231829
* @new_cpus: cpu mask
18241830
* Return: true if there is conflict, false otherwise
18251831
*
1826-
* CPUs outside of housekeeping_cpumask(HK_TYPE_DOMAIN) can only be used in
1827-
* an isolated partition.
1832+
* CPUs outside of boot_hk_cpus, if defined, can only be used in an
1833+
* isolated partition.
18281834
*/
18291835
static bool prstate_housekeeping_conflict(int prstate, struct cpumask *new_cpus)
18301836
{
1831-
const struct cpumask *hk_domain = housekeeping_cpumask(HK_TYPE_DOMAIN);
1832-
bool all_in_hk = cpumask_subset(new_cpus, hk_domain);
1837+
if (!have_boot_isolcpus)
1838+
return false;
18331839

1834-
if (!all_in_hk && (prstate != PRS_ISOLATED))
1840+
if ((prstate != PRS_ISOLATED) && !cpumask_subset(new_cpus, boot_hk_cpus))
18351841
return true;
18361842

18371843
return false;
@@ -4345,6 +4351,13 @@ int __init cpuset_init(void)
43454351

43464352
BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
43474353

4354+
have_boot_isolcpus = housekeeping_enabled(HK_TYPE_DOMAIN);
4355+
if (have_boot_isolcpus) {
4356+
BUG_ON(!alloc_cpumask_var(&boot_hk_cpus, GFP_KERNEL));
4357+
cpumask_copy(boot_hk_cpus, housekeeping_cpumask(HK_TYPE_DOMAIN));
4358+
cpumask_andnot(isolated_cpus, cpu_possible_mask, boot_hk_cpus);
4359+
}
4360+
43484361
return 0;
43494362
}
43504363

0 commit comments

Comments
 (0)