Skip to content

Commit 800d4d3

Browse files
yongzhang0Ingo Molnar
authored and
Ingo Molnar
committed
sched, autogroup: Stop going ahead if autogroup is disabled
when autogroup is disable from the beginning, sched_autogroup_create_attach() autogroup_move_group() <== 1 sched_move_task() <== 2 task_move_group_fair() set_task_rq() task_group() autogroup_task_group() We go the whole path without doing anything useful. Then stop going further if autogroup is disabled. But there will be a race window between 1 and 2, in which sysctl_sched_autogroup_enabled is enabled. This issue will be toke by following patch. Signed-off-by: Yong Zhang <[email protected]> Signed-off-by: Peter Zijlstra <[email protected]> Cc: Mike Galbraith <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 1747b21 commit 800d4d3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

kernel/sched_autogroup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,15 @@ autogroup_move_group(struct task_struct *p, struct autogroup *ag)
161161

162162
p->signal->autogroup = autogroup_kref_get(ag);
163163

164+
if (!ACCESS_ONCE(sysctl_sched_autogroup_enabled))
165+
goto out;
166+
164167
t = p;
165168
do {
166169
sched_move_task(t);
167170
} while_each_thread(p, t);
168171

172+
out:
169173
unlock_task_sighand(p, &flags);
170174
autogroup_kref_put(prev);
171175
}

kernel/sched_autogroup.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#ifdef CONFIG_SCHED_AUTOGROUP
22

33
struct autogroup {
4+
/*
5+
* reference doesn't mean how many thread attach to this
6+
* autogroup now. It just stands for the number of task
7+
* could use this autogroup.
8+
*/
49
struct kref kref;
510
struct task_group *tg;
611
struct rw_semaphore lock;

0 commit comments

Comments
 (0)