From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932693AbbCQT1X (ORCPT ); Tue, 17 Mar 2015 15:27:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57978 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932335AbbCQT1S (ORCPT ); Tue, 17 Mar 2015 15:27:18 -0400 Date: Tue, 17 Mar 2015 20:25:21 +0100 From: Oleg Nesterov To: Aaron Tomlin Cc: akpm@linux-foundation.org, rientjes@google.com, dwysocha@redhat.com, linux-kernel@vger.kernel.org, Ingo Molnar Subject: [PATCH 1/2] hung_task: split for_each_process_thread() into for_each_process() + __for_each_thread() Message-ID: <20150317192521.GB32579@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150317192450.GA32579@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); -- 1.5.5.1