From patchwork Thu Aug 25 22:43:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 1099352 Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7PMkrEM022043 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 25 Aug 2011 22:47:14 GMT Received: from daredevil.linux-foundation.org (localhost [127.0.0.1]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7PMi5Pl015303; Thu, 25 Aug 2011 15:44:36 -0700 Received: from mail-bw0-f47.google.com (mail-bw0-f47.google.com [209.85.214.47]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p7PMhVws015230 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=FAIL); Thu, 25 Aug 2011 15:43:33 -0700 Received: by bkbzu17 with SMTP id zu17so2224921bkb.6 for ; Thu, 25 Aug 2011 15:43:30 -0700 (PDT) Received: by 10.204.152.24 with SMTP id e24mr163395bkw.324.1314312210700; Thu, 25 Aug 2011 15:43:30 -0700 (PDT) Received: from localhost.localdomain ([130.75.117.88]) by mx.google.com with ESMTPS id x19sm293867bkt.9.2011.08.25.15.43.29 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Aug 2011 15:43:29 -0700 (PDT) From: Tejun Heo To: rjw@sisk.pl, paul@paulmenage.org, lizf@cn.fujitsu.com Date: Fri, 26 Aug 2011 00:43:07 +0200 Message-Id: <1314312192-26885-2-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1314312192-26885-1-git-send-email-tj@kernel.org> References: <1314312192-26885-1-git-send-email-tj@kernel.org> Received-SPF: pass (localhost is always allowed.) X-Spam-Status: No, hits=-4.375 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SPF_PASS, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.21 Cc: fweisbec@gmail.com, containers@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Tejun Heo , linux-pm@lists.linux-foundation.org, kamezawa.hiroyu@jp.fujitsu.com Subject: [linux-pm] [PATCH 1/6] cgroup: subsys->attach_task() should be called after migration X-BeenThere: linux-pm@lists.linux-foundation.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux power management List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-pm-bounces@lists.linux-foundation.org Errors-To: linux-pm-bounces@lists.linux-foundation.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 25 Aug 2011 22:47:14 +0000 (UTC) cgroup_attach_task() calls subsys->attach_task() after cgroup_task_migrate(); however, cgroup_attach_proc() calls it before migration. This actually affects some of the users. Update cgroup_attach_proc() such that ->attach_task() is called after migration. Signed-off-by: Tejun Heo Cc: Paul Menage Cc: Li Zefan --- kernel/cgroup.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 1d2b6ce..a606fa2 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2135,14 +2135,16 @@ int cgroup_attach_proc(struct cgroup *cgrp, struct task_struct *leader) oldcgrp = task_cgroup_from_root(tsk, root); if (cgrp == oldcgrp) continue; + + /* if the thread is PF_EXITING, it can just get skipped. */ + retval = cgroup_task_migrate(cgrp, oldcgrp, tsk, true); + BUG_ON(retval != 0 && retval != -ESRCH); + /* attach each task to each subsystem */ for_each_subsys(root, ss) { if (ss->attach_task) ss->attach_task(cgrp, tsk); } - /* if the thread is PF_EXITING, it can just get skipped. */ - retval = cgroup_task_migrate(cgrp, oldcgrp, tsk, true); - BUG_ON(retval != 0 && retval != -ESRCH); } /* nothing is sensitive to fork() after this point. */