]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
sched, autogroup: Stop going ahead if autogroup is disabled
authorYong Zhang <yong.zhang0@gmail.com>
Sun, 20 Feb 2011 07:08:14 +0000 (15:08 +0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 23 Feb 2011 10:33:59 +0000 (11:33 +0100)
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 <yong.zhang0@gmail.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1298185696-4403-4-git-send-email-yong.zhang0@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
kernel/sched_autogroup.c
kernel/sched_autogroup.h

index 9fb65628315709b36d4bb6d9bd100644d2a00992..137a096ae9d850a7218debad9c653fc6ab4dda29 100644 (file)
@@ -161,11 +161,15 @@ autogroup_move_group(struct task_struct *p, struct autogroup *ag)
 
        p->signal->autogroup = autogroup_kref_get(ag);
 
+       if (!ACCESS_ONCE(sysctl_sched_autogroup_enabled))
+               goto out;
+
        t = p;
        do {
                sched_move_task(t);
        } while_each_thread(p, t);
 
+out:
        unlock_task_sighand(p, &flags);
        autogroup_kref_put(prev);
 }
index 7b859ffe5dadd677cce89f833ee43a242ea3a992..05577055cfcaa4dc7ac055cb495f8e4ac97d96c4 100644 (file)
@@ -1,6 +1,11 @@
 #ifdef CONFIG_SCHED_AUTOGROUP
 
 struct autogroup {
+       /*
+        * reference doesn't mean how many thread attach to this
+        * autogroup now. It just stands for the number of task
+        * could use this autogroup.
+        */
        struct kref             kref;
        struct task_group       *tg;
        struct rw_semaphore     lock;