From: Peter Zijlstra <peterz@infradead.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Balbir Singh <bsingharora@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Nicholas Piggin <nicholas.piggin@gmail.com>,
Alexey Kardashevskiy <aik@ozlabs.ru>
Subject: Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a woken up task
Date: Mon, 5 Sep 2016 09:48:58 +0200 [thread overview]
Message-ID: <20160905074858.GP10153@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1473059659.2313.45.camel@kernel.crashing.org>
On Mon, Sep 05, 2016 at 05:14:19PM +1000, Benjamin Herrenschmidt wrote:
> On Mon, 2016-09-05 at 13:16 +1000, Balbir Singh wrote:
>
> .../...
> >
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Nicholas Piggin <npiggin@gmail.com>
>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>
> > Signed-off-by: Balbir Singh <bsingharora@gmail.com>
> > ---
> > kernel/sched/core.c | 11 +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 2a906f2..582c684 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -2016,6 +2016,17 @@ try_to_wake_up(struct task_struct *p, unsigned
> > int state, int wake_flags)
> > success = 1; /* we're going to change ->state */
> > cpu = task_cpu(p);
> >
> > + /*
> > + * Ensure we see on_rq and p_state consistently
> > + *
> > + * For example in __rwsem_down_write_failed(), we have
> > + * [S] ->on_rq = 1 [L] ->state
> > + * MB RMB
> > + * [S] ->state = TASK_UNINTERRUPTIBLE [L] ->on_rq
> > + * In the absence of the RMB p->on_rq can be observed to be 0
> > + * and we end up spinning indefinitely in while (p->on_cpu)
> > + */
So I did replace that comment with the one I proposed earlier. I checked
a fair number of architectures and many did not have an obvious barrier
in switch_to(). So that is not something we can rely on, nor do we need
to I think.
> > + smp_rmb();
> > if (p->on_rq && ttwu_remote(p, wake_flags))
> > goto stat;
> >
next prev parent reply other threads:[~2016-09-05 7:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-31 10:08 [v2][PATCH] Fix a race between try_to_wake_up() and a woken up task Balbir Singh
2016-09-05 3:16 ` [RESEND][v2][PATCH] " Balbir Singh
2016-09-05 7:14 ` Benjamin Herrenschmidt
2016-09-05 7:48 ` Peter Zijlstra [this message]
2016-09-05 8:24 ` Mike Galbraith
2016-09-05 8:31 ` Benjamin Herrenschmidt
2016-09-05 8:37 ` Balbir Singh
2016-09-05 11:14 ` [tip:sched/urgent] sched/core: " tip-bot for Balbir Singh
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=20160905074858.GP10153@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=aik@ozlabs.ru \
--cc=benh@kernel.crashing.org \
--cc=bsingharora@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicholas.piggin@gmail.com \
--cc=oleg@redhat.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