Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754548AbYKDGvy (ORCPT ); Tue, 4 Nov 2008 01:51:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752171AbYKDGvp (ORCPT ); Tue, 4 Nov 2008 01:51:45 -0500 Received: from cn.fujitsu.com ([222.73.24.84]:53403 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751709AbYKDGvo (ORCPT ); Tue, 4 Nov 2008 01:51:44 -0500 Message-ID: <490FF047.2030008@cn.fujitsu.com> Date: Tue, 04 Nov 2008 14:48:39 +0800 From: Li Zefan User-Agent: Thunderbird 2.0.0.9 (X11/20071115) MIME-Version: 1.0 To: Andrew Morton CC: Matt Helsley , "Rafael J. Wysocki" , Linux-Kernel , Linux Containers , linux-pm@lists.linux-foundation.org, Cedric Le Goater , "Serge E. Hallyn" , Paul Menage Subject: [PATCH] freezer_cg: remove task_lock from freezer_fork() References: <20080811235323.872291138@us.ibm.com> <20080811235325.121356317@us.ibm.com> <6599ad830811032143h51eae533k5b0c17e65a7fa675@mail.gmail.com> <490FE7B5.8020400@cn.fujitsu.com> In-Reply-To: <490FE7B5.8020400@cn.fujitsu.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1385 Lines: 40 In theory the task can be moved to another cgroup and the freezer will be freed right after task_lock is dropped, so the lock results in zero protection. But in the case of freezer_fork() no lock is needed, since the task is not in tasklist yet so it won't be moved to another cgroup, so task->cgroups won't be changed or invalidated. Signed-off-by: Li Zefan --- kernel/cgroup_freezer.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index 7fa476f..6605907 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c @@ -184,9 +184,13 @@ static void freezer_fork(struct cgroup_subsys *ss, struct task_struct *task) { struct freezer *freezer; - task_lock(task); + /* + * No lock is needed, since the task isn't on tasklist yet, + * so it can't be moved to another cgroup, which means the + * freezer won't be removed and will be valid during this + * function call. + */ freezer = task_freezer(task); - task_unlock(task); spin_lock_irq(&freezer->lock); BUG_ON(freezer->state == CGROUP_FROZEN); -- 1.5.4.rc3 -- 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/