Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cgroup/cpuset: Move housekeeping_update()/rebuild_sched_domains() together

With the latest changes in sched/isolation.c, rebuild_sched_domains*()
requires the HK_TYPE_DOMAIN housekeeping cpumask to be properly
updated first, if needed, before the sched domains can be
rebuilt. So the two naturally fit together. Do that by creating a new
update_hk_sched_domains() helper to house both actions.

The name of the isolated_cpus_updating flag to control the
call to housekeeping_update() is now outdated. So change it to
update_housekeeping to better reflect its purpose. Also move the call
to update_hk_sched_domains() to the end of cpuset and hotplug operations
before releasing the cpuset_mutex.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Waiman Long and committed by
Tejun Heo
3bfe4796 5e6aac57

+24 -27
+24 -27
kernel/cgroup/cpuset.c
··· 130 130 static cpumask_var_t isolated_cpus; /* CSCB */ 131 131 132 132 /* 133 - * Set if isolated_cpus is being updated in the current cpuset_mutex 134 - * critical section. 133 + * Set if housekeeping cpumasks are to be updated. 135 134 */ 136 - static bool isolated_cpus_updating; /* RWCS */ 135 + static bool update_housekeeping; /* RWCS */ 137 136 138 137 /* 139 138 * A flag to force sched domain rebuild at the end of an operation. ··· 1188 1189 return; 1189 1190 cpumask_andnot(isolated_cpus, isolated_cpus, xcpus); 1190 1191 } 1191 - isolated_cpus_updating = true; 1192 + update_housekeeping = true; 1192 1193 } 1193 1194 1194 1195 /* ··· 1306 1307 } 1307 1308 1308 1309 /* 1309 - * update_isolation_cpumasks - Update external isolation related CPU masks 1310 + * update_hk_sched_domains - Update HK cpumasks & rebuild sched domains 1310 1311 * 1311 - * The following external CPU masks will be updated if necessary: 1312 - * - workqueue unbound cpumask 1312 + * Update housekeeping cpumasks and rebuild sched domains if necessary. 1313 + * This should be called at the end of cpuset or hotplug actions. 1313 1314 */ 1314 - static void update_isolation_cpumasks(void) 1315 + static void update_hk_sched_domains(void) 1315 1316 { 1316 - int ret; 1317 - 1318 - if (!isolated_cpus_updating) 1319 - return; 1320 - 1321 - ret = housekeeping_update(isolated_cpus); 1322 - WARN_ON_ONCE(ret < 0); 1323 - 1324 - isolated_cpus_updating = false; 1317 + if (update_housekeeping) { 1318 + /* Updating HK cpumasks implies rebuild sched domains */ 1319 + WARN_ON_ONCE(housekeeping_update(isolated_cpus)); 1320 + update_housekeeping = false; 1321 + force_sd_rebuild = true; 1322 + } 1323 + /* force_sd_rebuild will be cleared in rebuild_sched_domains_locked() */ 1324 + if (force_sd_rebuild) 1325 + rebuild_sched_domains_locked(); 1325 1326 } 1326 1327 1327 1328 /** ··· 1472 1473 cs->remote_partition = true; 1473 1474 cpumask_copy(cs->effective_xcpus, tmp->new_cpus); 1474 1475 spin_unlock_irq(&callback_lock); 1475 - update_isolation_cpumasks(); 1476 1476 cpuset_force_rebuild(); 1477 1477 cs->prs_err = 0; 1478 1478 ··· 1516 1518 compute_excpus(cs, cs->effective_xcpus); 1517 1519 reset_partition_data(cs); 1518 1520 spin_unlock_irq(&callback_lock); 1519 - update_isolation_cpumasks(); 1520 1521 cpuset_force_rebuild(); 1521 1522 1522 1523 /* ··· 1586 1589 if (xcpus) 1587 1590 cpumask_copy(cs->exclusive_cpus, xcpus); 1588 1591 spin_unlock_irq(&callback_lock); 1589 - update_isolation_cpumasks(); 1590 1592 if (adding || deleting) 1591 1593 cpuset_force_rebuild(); 1592 1594 ··· 1929 1933 partition_xcpus_add(new_prs, parent, tmp->delmask); 1930 1934 1931 1935 spin_unlock_irq(&callback_lock); 1932 - update_isolation_cpumasks(); 1933 1936 1934 1937 if ((old_prs != new_prs) && (cmd == partcmd_update)) 1935 1938 update_partition_exclusive_flag(cs, new_prs); ··· 2896 2901 else if (isolcpus_updated) 2897 2902 isolated_cpus_update(old_prs, new_prs, cs->effective_xcpus); 2898 2903 spin_unlock_irq(&callback_lock); 2899 - update_isolation_cpumasks(); 2900 2904 2901 2905 /* Force update if switching back to member & update effective_xcpus */ 2902 2906 update_cpumasks_hier(cs, &tmpmask, !new_prs); ··· 3185 3191 } 3186 3192 3187 3193 free_cpuset(trialcs); 3188 - if (force_sd_rebuild) 3189 - rebuild_sched_domains_locked(); 3190 3194 out_unlock: 3195 + update_hk_sched_domains(); 3191 3196 cpuset_full_unlock(); 3192 3197 if (of_cft(of)->private == FILE_MEMLIST) 3193 3198 schedule_flush_migrate_mm(); ··· 3294 3301 cpuset_full_lock(); 3295 3302 if (is_cpuset_online(cs)) 3296 3303 retval = update_prstate(cs, val); 3304 + update_hk_sched_domains(); 3297 3305 cpuset_full_unlock(); 3298 3306 return retval ?: nbytes; 3299 3307 } ··· 3469 3475 /* Reset valid partition back to member */ 3470 3476 if (is_partition_valid(cs)) 3471 3477 update_prstate(cs, PRS_MEMBER); 3478 + update_hk_sched_domains(); 3472 3479 cpuset_full_unlock(); 3473 3480 } 3474 3481 ··· 3877 3882 rcu_read_unlock(); 3878 3883 } 3879 3884 3880 - /* rebuild sched domains if necessary */ 3881 - if (force_sd_rebuild) 3882 - rebuild_sched_domains_cpuslocked(); 3883 3885 3886 + if (update_housekeeping || force_sd_rebuild) { 3887 + mutex_lock(&cpuset_mutex); 3888 + update_hk_sched_domains(); 3889 + mutex_unlock(&cpuset_mutex); 3890 + } 3884 3891 free_tmpmasks(ptmp); 3885 3892 } 3886 3893