Skip to content

Commit 703ac29

Browse files
committed
cgroup/cpuset: Account for boot time isolated CPUs
jira NONE_AUTOMATION Rebuild_History Non-Buildable kernel-5.14.0-570.17.1.el9_6 commit-author Waiman Long <[email protected]> commit c188f33 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]> (cherry picked from commit c188f33) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 4c591db commit 703ac29

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

@@ -1801,15 +1807,15 @@ static void remote_partition_check(struct cpuset *cs, struct cpumask *newmask,
18011807
* @new_cpus: cpu mask
18021808
* Return: true if there is conflict, false otherwise
18031809
*
1804-
* CPUs outside of housekeeping_cpumask(HK_TYPE_DOMAIN) can only be used in
1805-
* an isolated partition.
1810+
* CPUs outside of boot_hk_cpus, if defined, can only be used in an
1811+
* isolated partition.
18061812
*/
18071813
static bool prstate_housekeeping_conflict(int prstate, struct cpumask *new_cpus)
18081814
{
1809-
const struct cpumask *hk_domain = housekeeping_cpumask(HK_TYPE_DOMAIN);
1810-
bool all_in_hk = cpumask_subset(new_cpus, hk_domain);
1815+
if (!have_boot_isolcpus)
1816+
return false;
18111817

1812-
if (!all_in_hk && (prstate != PRS_ISOLATED))
1818+
if ((prstate != PRS_ISOLATED) && !cpumask_subset(new_cpus, boot_hk_cpus))
18131819
return true;
18141820

18151821
return false;
@@ -4334,6 +4340,13 @@ int __init cpuset_init(void)
43344340

43354341
BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
43364342

4343+
have_boot_isolcpus = housekeeping_enabled(HK_TYPE_DOMAIN);
4344+
if (have_boot_isolcpus) {
4345+
BUG_ON(!alloc_cpumask_var(&boot_hk_cpus, GFP_KERNEL));
4346+
cpumask_copy(boot_hk_cpus, housekeeping_cpumask(HK_TYPE_DOMAIN));
4347+
cpumask_andnot(isolated_cpus, cpu_possible_mask, boot_hk_cpus);
4348+
}
4349+
43374350
return 0;
43384351
}
43394352

0 commit comments

Comments
 (0)