Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751398AbbEYRoQ (ORCPT ); Mon, 25 May 2015 13:44:16 -0400 Received: from relay.parallels.com ([195.214.232.42]:43846 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969AbbEYRoN (ORCPT ); Mon, 25 May 2015 13:44:13 -0400 Message-ID: <1432575846.6866.31.camel@odin.com> Subject: [PATCH RFC 01/13] exit: Clarify choice of new parent in forget_original_parent() From: Kirill Tkhai To: CC: Oleg Nesterov , Andrew Morton , Ingo Molnar , "Peter Zijlstra" , Michal Hocko , "Rik van Riel" , Ionut Alexa , Peter Hurley , Kirill Tkhai Date: Mon, 25 May 2015 20:44:06 +0300 In-Reply-To: <20150525162722.5171.15901.stgit@pro> References: <20150525162722.5171.15901.stgit@pro> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.30.16.109] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2898 Lines: 92 Second parameter of find_new_reaper() and the similarity of its name and find_child_reaper()'s confuse a reader. Rename find_child_reaper() for better conformity of its name and its function. Also delete the second parameter of find_new_reaper(). These both improve modularity. Signed-off-by: Kirill Tkhai --- kernel/exit.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 22fcc05..a29c35d 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -450,7 +450,7 @@ static struct task_struct *find_alive_thread(struct task_struct *p) return NULL; } -static struct task_struct *find_child_reaper(struct task_struct *father) +static void check_pid_ns_reaper_exit(struct task_struct *father) __releases(&tasklist_lock) __acquires(&tasklist_lock) { @@ -458,12 +458,12 @@ static struct task_struct *find_child_reaper(struct task_struct *father) struct task_struct *reaper = pid_ns->child_reaper; if (likely(reaper != father)) - return reaper; + return; reaper = find_alive_thread(father); if (reaper) { pid_ns->child_reaper = reaper; - return reaper; + return; } write_unlock_irq(&tasklist_lock); @@ -473,8 +473,6 @@ static struct task_struct *find_child_reaper(struct task_struct *father) } zap_pid_ns_processes(pid_ns); write_lock_irq(&tasklist_lock); - - return father; } /* @@ -484,15 +482,16 @@ static struct task_struct *find_child_reaper(struct task_struct *father) * child_subreaper for its children (like a service manager) * 3. give it to the init process (PID 1) in our pid namespace */ -static struct task_struct *find_new_reaper(struct task_struct *father, - struct task_struct *child_reaper) +static struct task_struct *find_new_reaper(struct task_struct *father) { - struct task_struct *thread, *reaper; + struct task_struct *thread, *reaper, *child_reaper; thread = find_alive_thread(father); if (thread) return thread; + child_reaper = task_active_pid_ns(father)->child_reaper; + if (father->signal->has_child_subreaper) { /* * Find the first ->is_child_subreaper ancestor in our pid_ns. @@ -557,11 +556,11 @@ static void forget_original_parent(struct task_struct *father, exit_ptrace(father, dead); /* Can drop and reacquire tasklist_lock */ - reaper = find_child_reaper(father); + check_pid_ns_reaper_exit(father); if (list_empty(&father->children)) return; - reaper = find_new_reaper(father, reaper); + reaper = find_new_reaper(father); list_for_each_entry(p, &father->children, sibling) { for_each_thread(p, t) { t->real_parent = reaper; -- 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/