All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Mandeep Singh Baines <msb@google.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	linux-kernel@vger.kernel.org, rientjes@google.com,
	mbligh@google.com, thockin@google.com
Subject: Re: [PATCH] softlockup: ensure the task has been switched out once
Date: Wed, 11 Feb 2009 11:04:32 +0100	[thread overview]
Message-ID: <20090211100432.GF20518@elte.hu> (raw)
In-Reply-To: <20090210181504.GI7332@google.com>


* Mandeep Singh Baines <msb@google.com> wrote:

> Frederic Weisbecker (fweisbec@gmail.com) wrote:
> > When we check if a task has been switched out since the last scan, we might
> > have a race condition on the following scenario:
> > 
> > _ the task is freshly created and scheduled
> > _ it puts its state to TASK_UNINTERRUPTIBLE and is not yet switched out
> > _ check_hung_task() scans this task and will report a false positive because
> >   t->nvcsw + t->nivcsw == t->last_switch_count == 0
> > 
> > Add a check for such cases.
> > 
> > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > ---
> >  kernel/hung_task.c |    8 +++++++-
> >  1 files changed, 7 insertions(+), 1 deletions(-)
> > 
> > diff --git a/kernel/hung_task.c b/kernel/hung_task.c
> > index 0c924de..022a492 100644
> > --- a/kernel/hung_task.c
> > +++ b/kernel/hung_task.c
> > @@ -72,7 +72,13 @@ static void check_hung_task(struct task_struct *t, unsigned long timeout)
> >  {
> >  	unsigned long switch_count = t->nvcsw + t->nivcsw;
> >  
> > -	if (t->flags & PF_FROZEN)
> > +	/*
> > +	 * Ensure the task is not frozen.
> > +	 * Also, when a freshly created task is scheduled once, changes
> > +	 * its state to TASK_UNINTERRUPTIBLE without having ever been
> > +	 * switched out once, it musn't be checked.
> > +	 */
> > +	if (unlikely(t->flags & PF_FROZEN || !switch_count))
> >  		return;
> >  
> >  	if (switch_count != t->last_switch_count) {
> > -- 
> > 1.6.1
> > 
> > 
> 
> 
> Looks good to me. Thanks for fixing this!
> 
> Acked-by: Mandeep Singh Baines <msb@google.com>

Applied to tip:core/softlockup, thanks guys!

	Ingo

      reply	other threads:[~2009-02-11 10:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 15:52 [PATCH] softlockup: ensure the task has been switched out once Frederic Weisbecker
2009-02-10 18:15 ` Mandeep Singh Baines
2009-02-11 10:04   ` Ingo Molnar [this message]

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=20090211100432.GF20518@elte.hu \
    --to=mingo@elte.hu \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@google.com \
    --cc=msb@google.com \
    --cc=rientjes@google.com \
    --cc=thockin@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.