Re: [bisected] Clocksource tsc unstable git

Peter Zijlstra
2010-11-09T13:45:52Z

On Tue, 2010-11-09 at 14:21 +0100, Markus Trippelsdorf wrote:
>
> You've missed the fact that Peter already has a patch that fixes the
> problem, but he never bothered to post it in this thread.
>
Right, forgot about that, sorry.

Still Heiko has a good point, I've queued the below after I realized
that PREEMPT_ACTIVE would still require two tests and the on_rq bit is
actually sufficient.

---
Subject: sched: Fix runnable condition for stoptask
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
Date: Tue Nov 09 14:36:52 CET 2010

Heiko reported that the TASK_RUNNING check is not sufficient for
CONFIG_PREEMPT=y since we can get preempted with !TASK_RUNNING.

He suggested adding a ->se.on_rq test to the existing TASK_RUNNING
one, however TASK_RUNNING will always have ->se.on_rq, so we might as
well reduce that to a single test.

Reported-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <new-submission>
---
kernel/sched_stoptask.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/kernel/sched_stoptask.c
===================================================================
--- linux-2.6.orig/kernel/sched_stoptask.c
+++ linux-2.6/kernel/sched_stoptask.c
@@ -26,7 +26,7 @@ static struct task_struct *pick_next_tas
{
struct task_struct *stop = rq->stop;

- if (stop && stop->state == TASK_RUNNING)
+ if (stop && stop->se.on_rq)
return stop;

return NULL;