Linux Container Development
 help / color / mirror / Atom feed
  • [parent not found: <20111121230709.GR25776@google.com>]
  • * [PATCH] cgroup_freezer: fix freezing groups with stopped tasks
    @ 2011-11-16 21:50 Michal Hocko
      0 siblings, 0 replies; 16+ messages in thread
    From: Michal Hocko @ 2011-11-16 21:50 UTC (permalink / raw)
      To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
      Cc: Tejun Heo, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
    	Tomasz Buchert, cgroups-u79uwXL29TY76Z2rM5mHXA, Andrew Morton,
    	Paul Menage
    
    2d3cbf8b (cgroup_freezer: update_freezer_state() does incorrect state
    transitions) removed is_task_frozen_enough and replaced it with a simple
    frozen call. This, however, breaks freezing for a group with stopped tasks
    because those cannot be frozen and so the group remains in CGROUP_FREEZING
    state (update_if_frozen doesn't count stopped tasks) and never reaches
    CGROUP_FROZEN.
    
    Let's add is_task_frozen_enough back and use it at the original locations
    (update_if_frozen and try_to_freeze_cgroup). Semantically we consider
    stopped tasks as frozen enough so we should consider both cases when
    testing frozen tasks.
    
    Testcase:
    mkdir /dev/freezer
    mount -t cgroup -o freezer none /dev/freezer
    mkdir /dev/freezer/foo
    sleep 1h &
    pid=$!
    kill -STOP $pid
    echo $pid > /dev/freezer/foo/tasks
    echo FROZEN > /dev/freezer/foo/freezer.state
    while true
    do
            cat /dev/freezer/foo/freezer.state
            [ "`cat /dev/freezer/foo/freezer.state`" = "FROZEN" ] && break
            sleep 1
    done
    echo OK
    
    Signed-off-by: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
    Cc: Tomasz Buchert <tomasz.buchert-MZpvjPyXg2s@public.gmane.org>
    Cc: Paul Menage <paul-inf54ven1CmVyaH7bEyXVA@public.gmane.org>
    Cc: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
    Cc: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
    Cc: Tejun Heo <htejun-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
    ---
     kernel/cgroup_freezer.c |   11 +++++++++--
     1 files changed, 9 insertions(+), 2 deletions(-)
    
    diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
    index 5e828a2..4d073dc 100644
    --- a/kernel/cgroup_freezer.c
    +++ b/kernel/cgroup_freezer.c
    @@ -153,6 +153,13 @@ static void freezer_destroy(struct cgroup_subsys *ss,
     	kfree(cgroup_freezer(cgroup));
     }
     
    +/* Task is frozen or will freeze immediately when next it gets woken */
    +static bool is_task_frozen_enough(struct task_struct *task)
    +{
    +	return frozen(task) ||
    +		(task_is_stopped_or_traced(task) && freezing(task));
    +}
    +
     /*
      * The call to cgroup_lock() in the freezer.state write method prevents
      * a write to that file racing against an attach, and hence the
    @@ -231,7 +238,7 @@ static void update_if_frozen(struct cgroup *cgroup,
     	cgroup_iter_start(cgroup, &it);
     	while ((task = cgroup_iter_next(cgroup, &it))) {
     		ntotal++;
    -		if (frozen(task))
    +		if (is_task_frozen_enough(task))
     			nfrozen++;
     	}
     
    @@ -284,7 +291,7 @@ static int try_to_freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
     	while ((task = cgroup_iter_next(cgroup, &it))) {
     		if (!freeze_task(task, true))
     			continue;
    -		if (frozen(task))
    +		if (is_task_frozen_enough(task))
     			continue;
     		if (!freezing(task) && !freezer_should_skip(task))
     			num_cant_freeze_now++;
    -- 
    1.7.7.1
    
    ^ permalink raw reply related	[flat|nested] 16+ messages in thread

    end of thread, other threads:[~2011-11-24 21:52 UTC | newest]
    
    Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <1321480234-29241-1-git-send-email-mhocko@suse.cz>
         [not found] ` <1321480234-29241-1-git-send-email-mhocko-AlSwsSmVLrQ@public.gmane.org>
    2011-11-17 10:14   ` [PATCH] cgroup_freezer: fix freezing groups with stopped tasks Tomasz Buchert
         [not found]     ` <4EC4DE9D.3040703-MZpvjPyXg2s@public.gmane.org>
    2011-11-17 16:13       ` Michal Hocko
         [not found]     ` <20111117161318.GA1233@tiehlicka.suse.cz>
         [not found]       ` <20111117161318.GA1233-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org>
    2011-11-17 17:03         ` Tomasz Buchert
    2011-11-21 13:40   ` Michal Hocko
    2011-11-21 23:07   ` Tejun Heo
         [not found] ` <20111121230709.GR25776@google.com>
         [not found]   ` <20111121230709.GR25776-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
    2011-11-22  2:20     ` Li Zefan
         [not found]       ` <4ECB06D2.6060106-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
    2011-11-22  2:21         ` Tejun Heo
         [not found]           ` <20111122022118.GT25776-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
    2011-11-22  9:05             ` Michal Hocko
         [not found]               ` <20111122090522.GA26768-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org>
    2011-11-22 15:39                 ` Tejun Heo
         [not found]               ` <20111122153948.GE322@google.com>
         [not found]                 ` <20111122153948.GE322-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
    2011-11-22 15:48                   ` Tejun Heo
    2011-11-22 15:56                   ` Michal Hocko
         [not found]                 ` <20111122154748.GF322@google.com>
         [not found]                   ` <20111122154748.GF322-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
    2011-11-23  2:00                     ` Li Zefan
    2011-11-24 10:04                     ` Michal Hocko
         [not found]                   ` <20111124100454.GE26036@tiehlicka.suse.cz>
         [not found]                     ` <20111124100454.GE26036-VqjxzfR4DlwKmadIfiO5sKVXKuFTiq87@public.gmane.org>
    2011-11-24 20:00                       ` Tejun Heo
         [not found]                     ` <20111124200009.GB6735@google.com>
         [not found]                       ` <20111124200009.GB6735-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
    2011-11-24 21:52                         ` Michal Hocko
    2011-11-16 21:50 Michal Hocko
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox