From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752416AbbCTQ4U (ORCPT ); Fri, 20 Mar 2015 12:56:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48352 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752367AbbCTQ4S (ORCPT ); Fri, 20 Mar 2015 12:56:18 -0400 Date: Fri, 20 Mar 2015 16:55:36 +0000 From: Aaron Tomlin To: Oleg Nesterov Cc: akpm@linux-foundation.org, rientjes@google.com, dwysocha@redhat.com, linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: [PATCH 2/2] hung_task: improve the rcu_lock_break() logic Message-ID: <20150320165536.GJ6831@atomlin.usersys.redhat.com> References: <1426601624-6703-1-git-send-email-atomlin@redhat.com> <1426601624-6703-2-git-send-email-atomlin@redhat.com> <20150317170920.GA21493@redhat.com> <20150317192450.GA32579@redhat.com> <20150317192540.GC32579@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150317192540.GC32579@redhat.com> X-PGP-Key: http://pgp.mit.edu/pks/lookup?search=atomlin%40redhat.com X-PGP-Fingerprint: 7906 84EB FA8A 9638 8D1E 6E9B E2DE 9658 19CC 77D6 User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2015-03-17 20:25 +0100, Oleg Nesterov wrote: > check_hung_uninterruptible_tasks() stops after rcu_lock_break() if either > "t" or "g" exits, this is suboptimal. > > If "t" is alive, we can always continue, t->group_leader can be used as the > new "g". We do not even bother to check g != NULL in this case. > > If "g" is alive, we can at least continue the outer for_each_process() loop. > > Signed-off-by: Oleg Nesterov > --- > kernel/hung_task.c | 29 ++++++++++++++++++++--------- > 1 files changed, 20 insertions(+), 9 deletions(-) > > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > index 4735b99..f488059 100644 > --- a/kernel/hung_task.c > +++ b/kernel/hung_task.c > @@ -134,20 +134,26 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout) > * For preemptible RCU it is sufficient to call rcu_read_unlock in order > * to exit the grace period. For classic RCU, a reschedule is required. > */ > -static bool rcu_lock_break(struct task_struct *g, struct task_struct *t) > +static void rcu_lock_break(struct task_struct **g, struct task_struct **t) > { > - bool can_cont; > + bool alive; > + > + get_task_struct(*g); > + get_task_struct(*t); > > - get_task_struct(g); > - get_task_struct(t); > rcu_read_unlock(); > cond_resched(); > rcu_read_lock(); > - can_cont = pid_alive(g) && pid_alive(t); > - put_task_struct(t); > - put_task_struct(g); > > - return can_cont; > + alive = pid_alive(*g); > + put_task_struct(*g); > + if (!alive) > + *g = NULL; > + > + alive = pid_alive(*t); > + put_task_struct(*t); > + if (!alive) > + *t = NULL; > } > > /* > @@ -178,7 +184,12 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) > > if (!--batch_count) { > batch_count = HUNG_TASK_BATCHING; > - if (!rcu_lock_break(g, t)) > + rcu_lock_break(&g, &t); > + if (t) /* in case g == NULL */ > + g = t->group_leader; > + else if (g) /* continue the outer loop */ > + break; > + else /* both dead */ > goto unlock; > } > /* use "==" to skip the TASK_KILLABLE tasks */ Looks good to me. Thanks. Acked-by: Aaron Tomlin