From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Balbir Singh <bsingharora@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Oleg Nesterov <oleg@redhat.com>
Cc: 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, 05 Sep 2016 17:14:19 +1000 [thread overview]
Message-ID: <1473059659.2313.45.camel@kernel.crashing.org> (raw)
In-Reply-To: <e02cce7b-d9ca-1ad0-7a61-ea97c7582b37@gmail.com>
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)
> + */
> + smp_rmb();
> if (p->on_rq && ttwu_remote(p, wake_flags))
> goto stat;
>
next prev parent reply other threads:[~2016-09-05 7:15 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 [this message]
2016-09-05 7:48 ` Peter Zijlstra
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=1473059659.2313.45.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=aik@ozlabs.ru \
--cc=bsingharora@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicholas.piggin@gmail.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).