All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: "IKEDA, Munehiro" <m-ikeda@ds.jp.nec.com>
Cc: linux-kernel@vger.kernel.org, menage@google.com,
	Linux Containers <containers@lists.linux-foundation.org>,
	balbir@linux.vnet.ibm.com
Subject: Re: [PATCH] cgroup: memory.force_empty can make system slowdown
Date: Sun, 17 Aug 2008 11:10:08 +0800	[thread overview]
Message-ID: <48A79690.1090600@cn.fujitsu.com> (raw)
In-Reply-To: <48A77BBB.7050305@cn.fujitsu.com>

Li Zefan wrote:
> IKEDA, Munehiro wrote:
>> Cgroup's memory controller has a control file "memory.force_empty"
>> to reset usage account charged to a cgroup.  The account shouldn't
>> be reset if one or more processes are attached to the cgroup (at
>> least for memory controller, IMHO).  So mem_cgroup_force_empty()
>> is implemented to return -EBUSY and do nothing if so.
>> However, cgroup on hierarchy root faultily might be a exception.
>> Even if processes are attached to root cgroup (which is a "default"
>> cgroup for processes), forcing-empty can run by writing something to
>> memory.force_empty and it'll never end.
>>
> 
> I found this bug last week, and I've made patches to fix it, but then
> I was on vacation. I'll send the patches out soon.
> 
>> Following patch prevents this issue.
>>
>> This patch is for cgroup infrastructure code.  The issue can be
>> measured by modifying memory controller code also, namely to change
>> mem_cgroup_force_empty() to see CSS_ROOT bit of css->flags.
>> I believe cgroup->count approach like the patch below is rather
>> generic and reasonable, how does that sound?
>>
> 
> It's ok for the top_group's count to be 0 due to the top_cgroup hack.
> With this patch, the top cgroup's count will be always >0, even if it
> has no tasks in it, so writing to top_cgroup's force_empty will always
> return -EBUSY.
> 

I thought cgrp->css_sets will be empty when there are no tasks in the top cgroup,
but I was wrong, because init_css_set's refcount will always >0,
so cgroup_task_count() won't return 0 for the top cgroup:

# mount -t cgroup -o debug xxx /mnt
# mkdir /mnt/sub
# for pid in `cat /mnt/tasks`; do echo $pid > /mnt/sub/tasks; done
# cat /mnt/tasks
# cat /mnt/debug.taskcount
3



  reply	other threads:[~2008-08-17  3:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-16  2:26 [PATCH] cgroup: memory.force_empty can make system slowdown IKEDA, Munehiro
2008-08-17  1:15 ` Li Zefan
2008-08-17  3:10   ` Li Zefan [this message]
     [not found]   ` <48A77BBB.7050305-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-08-17  3:10     ` Li Zefan
     [not found] ` <48A63AD1.3010907-MDRzhb/z0dd8UrSeD/g0lQ@public.gmane.org>
2008-08-17  1:15   ` Li Zefan
  -- strict thread matches above, loose matches on Subject: below --
2008-08-16  2:26 IKEDA, Munehiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48A79690.1090600@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=containers@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-ikeda@ds.jp.nec.com \
    --cc=menage@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.