From: Oleg Nesterov <oleg@redhat.com>
To: Aaron Tomlin <atomlin@redhat.com>
Cc: akpm@linux-foundation.org, rientjes@google.com,
dwysocha@redhat.com, linux-kernel@vger.kernel.org,
Ingo Molnar <mingo@kernel.org>
Subject: [PATCH 2/2] hung_task: improve the rcu_lock_break() logic
Date: Tue, 17 Mar 2015 20:25:40 +0100 [thread overview]
Message-ID: <20150317192540.GC32579@redhat.com> (raw)
In-Reply-To: <20150317192450.GA32579@redhat.com>
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 <oleg@redhat.com>
---
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 */
--
1.5.5.1
next prev parent reply other threads:[~2015-03-17 19:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 14:13 [PATCH 0/1] hung_task: Change hung_task.c to use for_each_process_thread() Aaron Tomlin
2015-03-17 14:13 ` [PATCH 1/1] " Aaron Tomlin
2015-03-17 17:09 ` Oleg Nesterov
2015-03-17 17:18 ` Aaron Tomlin
2015-03-17 19:24 ` [PATCH 0/2] hung_task: improve rcu_lock_break() logic Oleg Nesterov
2015-03-17 19:25 ` [PATCH 1/2] hung_task: split for_each_process_thread() into for_each_process() + __for_each_thread() Oleg Nesterov
2015-03-20 16:55 ` Aaron Tomlin
2015-03-17 19:25 ` Oleg Nesterov [this message]
2015-03-20 16:55 ` [PATCH 2/2] hung_task: improve the rcu_lock_break() logic Aaron Tomlin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150317192540.GC32579@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=atomlin@redhat.com \
--cc=dwysocha@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rientjes@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox