[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20140519151233.5043b749361e1b384f1e5562@gmail.com>
Date: Mon, 19 May 2014 15:12:33 +0200
From: Juri Lelli <juri.lelli@...il.com>
To: Kirill Tkhai <tkhai@...dex.ru>
Cc: linux-kernel@...r.kernel.org, peterz@...radead.org,
mingo@...hat.com, stable@...r.kernel.org
Subject: Re: [PATCH] sched/dl: Fix race between dl_task_timer() and
sched_setaffinity()
On Sat, 17 May 2014 01:30:03 +0400
Kirill Tkhai <tkhai@...dex.ru> wrote:
> The race is in unlocked task_rq() access. In pair with parallel
> call of sched_setaffinity() it may be a reason of corruption
> of internal rq's data.
>
Sure, the thing can happen!
> Signed-off-by: Kirill Tkhai <tkhai@...dex.ru>
> CC: Juri Lelli <juri.lelli@...il.com>
> CC: Peter Zijlstra <peterz@...radead.org>
> CC: Ingo Molnar <mingo@...hat.com>
> Cc: <stable@...r.kernel.org> # v3.14
> ---
> kernel/sched/deadline.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 800e99b..ffb023a 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -513,9 +513,16 @@ static enum hrtimer_restart dl_task_timer(struct hrtimer *timer)
> struct sched_dl_entity,
> dl_timer);
> struct task_struct *p = dl_task_of(dl_se);
> - struct rq *rq = task_rq(p);
> + struct rq *rq;
We could maybe add a comment here, in line with what we have below, to
document why we need this.
Thanks,
- Juri
> +again:
> + rq = task_rq(p);
> raw_spin_lock(&rq->lock);
>
> + if (unlikely(rq != task_rq(p))) {
> + raw_spin_unlock(&rq->lock);
> + goto again;
> + }
> +
> /*
> * We need to take care of a possible races here. In fact, the
> * task might have changed its scheduling policy to something
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists