From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbbCTQz6 (ORCPT ); Fri, 20 Mar 2015 12:55:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51329 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751163AbbCTQz5 (ORCPT ); Fri, 20 Mar 2015 12:55:57 -0400 Date: Fri, 20 Mar 2015 16:55:10 +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 1/2] hung_task: split for_each_process_thread() into for_each_process() + __for_each_thread() Message-ID: <20150320165510.GI6831@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> <20150317192521.GB32579@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150317192521.GB32579@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: > Preparation. Change the main loop in check_hung_uninterruptible_tasks() > to use the nested for_each_process() + __for_each_thread() loops explicitly. > Note that we use __for_each_thread(), not for_each_thread(). This way it > is clear that the inner loop doesn't depend on 'g' after we read ->signal. > > Signed-off-by: Oleg Nesterov > --- > kernel/hung_task.c | 23 ++++++++++++++--------- > 1 files changed, 14 insertions(+), 9 deletions(-) > > diff --git a/kernel/hung_task.c b/kernel/hung_task.c > index e0f90c2..4735b99 100644 > --- a/kernel/hung_task.c > +++ b/kernel/hung_task.c > @@ -169,17 +169,22 @@ static void check_hung_uninterruptible_tasks(unsigned long timeout) > return; > > rcu_read_lock(); > - for_each_process_thread(g, t) { > - if (!max_count--) > - goto unlock; > - if (!--batch_count) { > - batch_count = HUNG_TASK_BATCHING; > - if (!rcu_lock_break(g, t)) > + for_each_process(g) { > + struct signal_struct *sig = g->signal; > + > + __for_each_thread(sig, t) { > + if (!max_count--) > goto unlock; > + > + if (!--batch_count) { > + batch_count = HUNG_TASK_BATCHING; > + if (!rcu_lock_break(g, t)) > + goto unlock; > + } > + /* use "==" to skip the TASK_KILLABLE tasks */ > + if (t->state == TASK_UNINTERRUPTIBLE) > + check_hung_task(t, timeout); > } > - /* use "==" to skip the TASK_KILLABLE tasks waiting on NFS */ > - if (t->state == TASK_UNINTERRUPTIBLE) > - check_hung_task(t, timeout); > } > unlock: > rcu_read_unlock(); > Acked-by: Aaron Tomlin