Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1476159

Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a woken up task

From Benjamin Herrenschmidt <benh@kernel.crashing.org>
Newsgroups linux.kernel
Subject Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a woken up task
Date 2016-09-05 09:20 +0200
Message-ID <sdWmd-xw-11@gated-at.bofh.it> (permalink)
References <scaMF-17E-9@gated-at.bofh.it> <sdSBY-6rw-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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;
>  

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[v2][PATCH] Fix a race between try_to_wake_up() and a woken up task Balbir Singh <bsingharora@gmail.com> - 2016-08-31 12:20 +0200
  [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a woken  up task Balbir Singh <bsingharora@gmail.com> - 2016-09-05 05:20 +0200
    Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a  woken up task Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2016-09-05 09:20 +0200
      Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a  woken up task Peter Zijlstra <peterz@infradead.org> - 2016-09-05 09:50 +0200
        Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a  woken up task Mike Galbraith <umgwanakikbuti@gmail.com> - 2016-09-05 10:30 +0200
          Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a  woken up task Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2016-09-05 10:40 +0200
        Re: [RESEND][v2][PATCH] Fix a race between try_to_wake_up() and a  woken up task Balbir Singh <bsingharora@gmail.com> - 2016-09-05 10:40 +0200
    [tip:sched/urgent] sched/core: Fix a race between try_to_wake_up()  and a woken up task tip-bot for Balbir Singh <tipbot@zytor.com> - 2016-09-05 13:20 +0200

csiph-web