All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Mandeep Singh Baines <msb@google.com>
Cc: mingo@elte.hu, linux-kernel@vger.kernel.org, rientjes@google.com,
	mbligh@google.com, thockin@google.com, akpm@linux-foundation.org
Subject: Re: [PATCH] softlockup: remove timestamp checking from hung_task
Date: Mon, 9 Feb 2009 20:54:47 +0100	[thread overview]
Message-ID: <20090209195446.GA4572@nowhere> (raw)
In-Reply-To: <20090209192956.GA7332@google.com>

On Mon, Feb 09, 2009 at 11:29:56AM -0800, Mandeep Singh Baines wrote:
> Frederic Weisbecker (fweisbec@gmail.com) wrote:
> > BTW, here is a small fixlet on top of your patch about what I commented concerning
> > the tasks than weren't yet scheduled once:
> > 
> > --
> > From e7120e424b031978e482b5fe311d90916ffb8b7e Mon Sep 17 00:00:00 2001
> > From: Frederic Weisbecker <fweisbec@gmail.com>
> > Date: Sat, 7 Feb 2009 17:45:12 +0100
> > Subject: [PATCH] softlockup: ensure the task has been scheduled once
> > 
> > When we check if the task has been scheduled since the last scan, we might
> > have a race condition if the task has been inserted on the task list but not
> > yet scheduled once. So we just add a small check to ensure it has been switched
> > in at least one time to avoid false positive.
> > 
> > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
> > ---
> >  kernel/hung_task.c |    6 +++++-
> >  1 files changed, 5 insertions(+), 1 deletions(-)
> > 
> > diff --git a/kernel/hung_task.c b/kernel/hung_task.c
> > index 4a10756..7f57a71 100644
> > --- a/kernel/hung_task.c
> > +++ b/kernel/hung_task.c
> > @@ -72,7 +72,11 @@ 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 and that it has been scheduled
> > +	 * at least once.
> > +	 */
> > +	if (t->flags & PF_FROZEN || !switch_count)
> >  		return;
> >  
> >  	if (switch_count != t->last_switch_count) {
> > -- 
> > 1.6.1
> > 
> 
> Good catch! I would change the description though. The race is a little
> more subtle than your current description. For a newly forked process, the race
> can occur if check_hung_task() processes the task in the time between the task
> changing its state to UNINTERRUPTIBLE and the the scheduler updating the
> switch_count (nivcsw or nvcsw).
> 
> One minor change to the  code comment. You want to ensure that the task has
> context switched at least once, NOT that the task has been scheduled at least
> once.

Ooh ok. I thought that the first schedule updated nivcsw/nvcsw, that's why
I cancelled my comment.

Ok so I will resend the patch with the appropriate comment.


> 
> If you re-send the patch with the fixed comment and description, I'll
> ack it.

Thanks! :-)


  reply	other threads:[~2009-02-09 19:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-06 23:37 [PATCH] softlockup: remove timestamp checking from hung_task Mandeep Singh Baines
2009-02-07 16:23 ` Frederic Weisbecker
2009-02-07 16:34   ` Frederic Weisbecker
2009-02-07 16:51     ` Frederic Weisbecker
2009-02-07 17:02       ` Frederic Weisbecker
2009-02-09 19:29       ` Mandeep Singh Baines
2009-02-09 19:54         ` Frederic Weisbecker [this message]
2009-02-09 10:04 ` Ingo Molnar

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=20090209195446.GA4572@nowhere \
    --to=fweisbec@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbligh@google.com \
    --cc=mingo@elte.hu \
    --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.