Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754024AbYHPCca (ORCPT ); Fri, 15 Aug 2008 22:32:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751444AbYHPCcV (ORCPT ); Fri, 15 Aug 2008 22:32:21 -0400 Received: from mx1.redhat.com ([66.187.233.31]:37376 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750928AbYHPCcV (ORCPT ); Fri, 15 Aug 2008 22:32:21 -0400 Message-ID: <48A63AD1.3010907@ds.jp.nec.com> Date: Fri, 15 Aug 2008 22:26:25 -0400 From: "IKEDA, Munehiro" User-Agent: Thunderbird 2.0.0.16 (X11/20080723) MIME-Version: 1.0 To: menage@google.com, balbir@linux.vnet.ibm.com CC: Linux Containers , linux-kernel@vger.kernel.org Subject: [PATCH] cgroup: memory.force_empty can make system slowdown Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1880 Lines: 52 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. 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? Paul, Balbir? Signed-off-by: Munehiro "Muuhh" Ikeda diff -uNrp linux-2.6.27-rc3.orig/kernel/cgroup.c linux-2.6.27-rc3/kernel/cgroup.c --- linux-2.6.27-rc3.orig/kernel/cgroup.c 2008-08-12 21:55:39.000000000 -0400 +++ linux-2.6.27-rc3/kernel/cgroup.c 2008-08-15 20:52:52.000000000 -0400 @@ -2264,8 +2264,10 @@ static void init_cgroup_css(struct cgrou css->cgroup = cgrp; atomic_set(&css->refcnt, 0); css->flags = 0; - if (cgrp == dummytop) + if (cgrp == dummytop) { set_bit(CSS_ROOT, &css->flags); + atomic_set(&css->cgroup->count, 1); + } BUG_ON(cgrp->subsys[ss->subsys_id]); cgrp->subsys[ss->subsys_id] = css; } -- IKEDA, Munehiro NEC Corporation of America m-ikeda@ds.jp.nec.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/