mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Q: a bogus task_running() check in try_to_wake_up() ?
@ 2007-07-15 15:39 Oleg Nesterov
  2007-07-17 19:05 ` Ingo Molnar
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Nesterov @ 2007-07-15 15:39 UTC (permalink / raw)
  To: Ingo Molnar, Mike Galbraith; +Cc: linux-kernel

try_to_wake_up:
	
	if (p->se.on_rq)
		goto out_running;

	...

	if (unlikely(task_running(rq, p)))
		goto out_activate;

How it possible that rq->curr has on_rq == 0 ?

AFAICS, this can only happen if this task is rq->idle. But idle threads
should not sleep, we have a special "scheduling from the idle thread!"
check in schedule().

Thanks in advance,

Oleg.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Q: a bogus task_running() check in try_to_wake_up() ?
  2007-07-15 15:39 Q: a bogus task_running() check in try_to_wake_up() ? Oleg Nesterov
@ 2007-07-17 19:05 ` Ingo Molnar
  2007-07-18 16:35   ` Oleg Nesterov
  0 siblings, 1 reply; 3+ messages in thread
From: Ingo Molnar @ 2007-07-17 19:05 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Mike Galbraith, linux-kernel


* Oleg Nesterov <oleg@tv-sign.ru> wrote:

> try_to_wake_up:
> 	
> 	if (p->se.on_rq)
> 		goto out_running;
> 
> 	...
> 
> 	if (unlikely(task_running(rq, p)))
> 		goto out_activate;
> 
> How it possible that rq->curr has on_rq == 0 ?
> 
> AFAICS, this can only happen if this task is rq->idle. But idle 
> threads should not sleep, we have a special "scheduling from the idle 
> thread!" check in schedule().

it's also possible if an arch uses __ARCH_WANT_INTERRUPTS_ON_CTXSW, 
right?

[ btw., we dont have a special "scheduling from the idle thread" check
  in schedule() anymore, it's now in kernel/sched_idletask.c :-) ]

	Ingo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Q: a bogus task_running() check in try_to_wake_up() ?
  2007-07-17 19:05 ` Ingo Molnar
@ 2007-07-18 16:35   ` Oleg Nesterov
  0 siblings, 0 replies; 3+ messages in thread
From: Oleg Nesterov @ 2007-07-18 16:35 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Mike Galbraith, linux-kernel

On 07/17, Ingo Molnar wrote:
> 
> * Oleg Nesterov <oleg@tv-sign.ru> wrote:
> 
> > try_to_wake_up:
> > 	
> > 	if (p->se.on_rq)
> > 		goto out_running;
> > 
> > 	...
> > 
> > 	if (unlikely(task_running(rq, p)))
> > 		goto out_activate;
> > 
> > How it possible that rq->curr has on_rq == 0 ?
> > 
> > AFAICS, this can only happen if this task is rq->idle. But idle 
> > threads should not sleep, we have a special "scheduling from the idle 
> > thread!" check in schedule().
> 
> it's also possible if an arch uses __ARCH_WANT_INTERRUPTS_ON_CTXSW, 
> right?

Ah, got it. I guess you meant __ARCH_WANT_UNLOCKED_CTXSW though.

In that case schedule() drops rq->lock before the context switch, but doesn't
clear ->oncpu. So, task_running(p) means we must not activate "p" on another
CPU, otherwise it could be scheduled before the switch-in-progress completes.

Thanks a lot!

Oleg.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-07-18 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-15 15:39 Q: a bogus task_running() check in try_to_wake_up() ? Oleg Nesterov
2007-07-17 19:05 ` Ingo Molnar
2007-07-18 16:35   ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®