From: Junaid Shahid <junaids@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Andres Lagar-Cavilla <andreslc@google.com>,
Greg Thelen <gthelen@google.com>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: Re: [PATCH] kthread: Fix race condition between kthread_parkme() and kthread_unpark()
Date: Fri, 29 Sep 2017 13:58:28 -0700 [thread overview]
Message-ID: <1906007.YVkLUJZ5jy@js-desktop.svl.corp.google.com> (raw)
In-Reply-To: <20170929082838.z2eyp67hbdfcpibj@hirez.programming.kicks-ass.net>
Thanks for the clarification. But in that case, shouldn’t the patch check whether IS_PARKED was already set before calling complete(&self->parked)? Otherwise, the completion count for self->parked could be more than 1 as a result of spurious wakeups, which could make a future call to kthread_park complete prematurely.
Thanks,
Junaid
On Friday, September 29, 2017 10:28:38 AM Peter Zijlstra wrote:
> On Fri, Sep 29, 2017 at 09:59:55AM +0200, Thomas Gleixner wrote:
> > On Thu, 28 Sep 2017, Junaid Shahid wrote:
> >
> > > Hi Peter,
> > >
> > > It looks like try_cmpxchg is not available on non-x86 archs, but other than
> > > that the version that you proposed looks good.
> > >
> > > One thing that I am a bit curious about is that the original code, before
> > > either patch, had a test_and_set_bit for KTHREAD_IS_PARKED rather than just
> > > a set_bit. I can't think of any reason why that was needed, since it
> > > doesn't look like TASK_PARKED tasks are susceptible to spurious wakeups. Do
> > > you by any chance happen to know if there was any specific reason for it?
> >
> > Everything is susceptible to spurious wakeups and has to deal with it.
>
> Right, we should code as if they are at all times possible. Currently,
> for TASK_PARKED, I don't think they can happen, but I've had patches
> that introduce them on purpose (regardless the state) just to stress the
> code.
>
> IIRC only TASK_STOPPED and/or TASK_TRACED hard rely on not getting any.
prev parent reply other threads:[~2017-09-29 20:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-29 2:32 Junaid Shahid
2017-05-30 22:37 ` Junaid Shahid
2017-05-30 22:40 ` Andrew Morton
2017-07-18 0:13 ` Junaid Shahid
2017-07-18 6:35 ` Thomas Gleixner
2017-09-27 12:17 ` Peter Zijlstra
[not found] ` <CAL-GctE0BLVk=ps09dnir8pcpnfzg88jMK4CKkRVmY7-ho87nQ@mail.gmail.com>
2017-09-29 7:59 ` Thomas Gleixner
2017-09-29 8:28 ` Peter Zijlstra
2017-09-29 20:58 ` Junaid Shahid [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=1906007.YVkLUJZ5jy@js-desktop.svl.corp.google.com \
--to=junaids@google.com \
--cc=andreslc@google.com \
--cc=gthelen@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®