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: add decrease attach_in_progress helpers

There are several functions to decrease attach_in_progress, and they
will wake up cpuset_attach_wq when attach_in_progress is zero. So,
add a helper to make it concise.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Reviewed-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Chen Ridong and committed by
Tejun Heo
4a711dd9 c149c4a4

+24 -15
+24 -15
kernel/cgroup/cpuset.c
··· 491 491 } 492 492 493 493 /* 494 + * decrease cs->attach_in_progress. 495 + * wake_up cpuset_attach_wq if cs->attach_in_progress==0. 496 + */ 497 + static inline void dec_attach_in_progress_locked(struct cpuset *cs) 498 + { 499 + lockdep_assert_held(&cpuset_mutex); 500 + 501 + cs->attach_in_progress--; 502 + if (!cs->attach_in_progress) 503 + wake_up(&cpuset_attach_wq); 504 + } 505 + 506 + static inline void dec_attach_in_progress(struct cpuset *cs) 507 + { 508 + mutex_lock(&cpuset_mutex); 509 + dec_attach_in_progress_locked(cs); 510 + mutex_unlock(&cpuset_mutex); 511 + } 512 + 513 + /* 494 514 * Cgroup v2 behavior is used on the "cpus" and "mems" control files when 495 515 * on default hierarchy or when the cpuset_v2_mode flag is set by mounting 496 516 * the v1 cpuset cgroup filesystem with the "cpuset_v2_mode" mount option. ··· 3442 3422 cs = css_cs(css); 3443 3423 3444 3424 mutex_lock(&cpuset_mutex); 3445 - cs->attach_in_progress--; 3446 - if (!cs->attach_in_progress) 3447 - wake_up(&cpuset_attach_wq); 3425 + dec_attach_in_progress_locked(cs); 3448 3426 3449 3427 if (cs->nr_migrate_dl_tasks) { 3450 3428 int cpu = cpumask_any(cs->effective_cpus); ··· 3557 3539 reset_migrate_dl_data(cs); 3558 3540 } 3559 3541 3560 - cs->attach_in_progress--; 3561 - if (!cs->attach_in_progress) 3562 - wake_up(&cpuset_attach_wq); 3542 + dec_attach_in_progress_locked(cs); 3563 3543 3564 3544 mutex_unlock(&cpuset_mutex); 3565 3545 } ··· 4300 4284 if (same_cs) 4301 4285 return; 4302 4286 4303 - mutex_lock(&cpuset_mutex); 4304 - cs->attach_in_progress--; 4305 - if (!cs->attach_in_progress) 4306 - wake_up(&cpuset_attach_wq); 4307 - mutex_unlock(&cpuset_mutex); 4287 + dec_attach_in_progress(cs); 4308 4288 } 4309 4289 4310 4290 /* ··· 4332 4320 guarantee_online_mems(cs, &cpuset_attach_nodemask_to); 4333 4321 cpuset_attach_task(cs, task); 4334 4322 4335 - cs->attach_in_progress--; 4336 - if (!cs->attach_in_progress) 4337 - wake_up(&cpuset_attach_wq); 4338 - 4323 + dec_attach_in_progress_locked(cs); 4339 4324 mutex_unlock(&cpuset_mutex); 4340 4325 } 4341 4326