Skip to content

Commit a49e462

Browse files
KAGA-KOKOhtejun
authored andcommitted
cpuset: Make cpuset hotplug synchronous
Convert cpuset_hotplug_workfn() into synchronous call for cpu hotplug path. For memory hotplug path it still gets queued as a work item. Since cpuset_hotplug_workfn() can be made synchronous for cpu hotplug path, it is not required to wait for cpuset hotplug while thawing processes. Signed-off-by: Prateek Sood <prsood@codeaurora.org> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 3010c5b commit a49e462

3 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎include/linux/cpuset.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ extern int cpuset_init(void);
5454
extern void cpuset_init_smp(void);
5555
extern void cpuset_force_rebuild(void);
5656
extern void cpuset_update_active_cpus(void);
57-
extern void cpuset_wait_for_hotplug(void);
5857
extern void cpuset_read_lock(void);
5958
extern void cpuset_read_unlock(void);
6059
extern void cpuset_cpus_allowed(struct task_struct *p, struct cpumask *mask);
@@ -176,8 +175,6 @@ static inline void cpuset_update_active_cpus(void)
176175
partition_sched_domains(1, NULL, NULL);
177176
}
178177

179-
static inline void cpuset_wait_for_hotplug(void) { }
180-
181178
static inline void cpuset_read_lock(void) { }
182179
static inline void cpuset_read_unlock(void) { }
183180

‎kernel/cgroup/cpuset.c‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3101,7 +3101,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
31013101
}
31023102

31033103
/**
3104-
* cpuset_hotplug_workfn - handle CPU/memory hotunplug for a cpuset
3104+
* cpuset_hotplug - handle CPU/memory hotunplug for a cpuset
31053105
*
31063106
* This function is called after either CPU or memory configuration has
31073107
* changed and updates cpuset accordingly. The top_cpuset is always
@@ -3116,7 +3116,7 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
31163116
* Note that CPU offlining during suspend is ignored. We don't modify
31173117
* cpusets across suspend/resume cycles at all.
31183118
*/
3119-
static void cpuset_hotplug_workfn(struct work_struct *work)
3119+
static void cpuset_hotplug(bool use_cpu_hp_lock)
31203120
{
31213121
static cpumask_t new_cpus;
31223122
static nodemask_t new_mems;
@@ -3201,25 +3201,32 @@ static void cpuset_hotplug_workfn(struct work_struct *work)
32013201
/* rebuild sched domains if cpus_allowed has changed */
32023202
if (cpus_updated || force_rebuild) {
32033203
force_rebuild = false;
3204-
rebuild_sched_domains();
3204+
if (use_cpu_hp_lock)
3205+
rebuild_sched_domains();
3206+
else {
3207+
/* Acquiring cpu_hotplug_lock is not required.
3208+
* When cpuset_hotplug() is called in hotplug path,
3209+
* cpu_hotplug_lock is held by the hotplug context
3210+
* which is waiting for cpuhp_thread_fun to indicate
3211+
* completion of callback.
3212+
*/
3213+
percpu_down_write(&cpuset_rwsem);
3214+
rebuild_sched_domains_locked();
3215+
percpu_up_write(&cpuset_rwsem);
3216+
}
32053217
}
32063218

32073219
free_cpumasks(NULL, ptmp);
32083220
}
32093221

3210-
void cpuset_update_active_cpus(void)
3222+
static void cpuset_hotplug_workfn(struct work_struct *work)
32113223
{
3212-
/*
3213-
* We're inside cpu hotplug critical region which usually nests
3214-
* inside cgroup synchronization. Bounce actual hotplug processing
3215-
* to a work item to avoid reverse locking order.
3216-
*/
3217-
schedule_work(&cpuset_hotplug_work);
3224+
cpuset_hotplug(true);
32183225
}
32193226

3220-
void cpuset_wait_for_hotplug(void)
3227+
void cpuset_update_active_cpus(void)
32213228
{
3222-
flush_work(&cpuset_hotplug_work);
3229+
cpuset_hotplug(false);
32233230
}
32243231

32253232
/*

‎kernel/power/process.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ void thaw_processes(void)
204204
__usermodehelper_set_disable_depth(UMH_FREEZING);
205205
thaw_workqueues();
206206

207-
cpuset_wait_for_hotplug();
208-
209207
read_lock(&tasklist_lock);
210208
for_each_process_thread(g, p) {
211209
/* No other threads should have PF_SUSPEND_TASK set */

0 commit comments

Comments
 (0)