* 2.6.12-rc2 in_atomic() picks up preempt_disable()
@ 2005-04-07 10:10 Keith Owens
2005-04-07 10:17 ` Arjan van de Ven
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Keith Owens @ 2005-04-07 10:10 UTC (permalink / raw)
To: Ingo Molnar; +Cc: linux-kernel
2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
in_atomic() macro thinks that preempt_disable() indicates an atomic
region so calls to __might_sleep() result in a stack trace.
preempt_count() returns 1, no soft or hard irqs are running and no
spinlocks are held. It looks like there is no way to distinguish
between the use of preempt_disable() in the lock functions (atomic) and
preempt_disable() outside the lock functions (do nothing that might
migrate me).
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
2005-04-07 10:10 2.6.12-rc2 in_atomic() picks up preempt_disable() Keith Owens
@ 2005-04-07 10:17 ` Arjan van de Ven
2005-04-07 12:24 ` Romano Giannetti
2005-04-07 10:22 ` Andrew Morton
2005-04-07 14:54 ` Ingo Molnar
2 siblings, 1 reply; 8+ messages in thread
From: Arjan van de Ven @ 2005-04-07 10:17 UTC (permalink / raw)
To: Keith Owens; +Cc: Ingo Molnar, linux-kernel
On Thu, 2005-04-07 at 20:10 +1000, Keith Owens wrote:
> 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
> in_atomic() macro thinks that preempt_disable() indicates an atomic
> region so calls to __might_sleep() result in a stack trace.
but you're not allowed to schedule when preempt is disabled!
> preempt_count() returns 1, no soft or hard irqs are running and no
> spinlocks are held. It looks like there is no way to distinguish
> between the use of preempt_disable() in the lock functions (atomic) and
> preempt_disable() outside the lock functions (do nothing that might
> migrate me).
in what code are you seeing this?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
2005-04-07 10:17 ` Arjan van de Ven
@ 2005-04-07 12:24 ` Romano Giannetti
0 siblings, 0 replies; 8+ messages in thread
From: Romano Giannetti @ 2005-04-07 12:24 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: Keith Owens, Ingo Molnar, linux-kernel
On Thu, Apr 07, 2005 at 12:17:37PM +0200, Arjan van de Ven wrote:
> On Thu, 2005-04-07 at 20:10 +1000, Keith Owens wrote:
> > 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
> > in_atomic() macro thinks that preempt_disable() indicates an atomic
> > region so calls to __might_sleep() result in a stack trace.
>
> but you're not allowed to schedule when preempt is disabled!
>
Could it be related to this:
http://marc.theaimsgroup.com/?l=linux-kernel&m=111277325629959&w=2
--
Romano Giannetti - Univ. Pontificia Comillas (Madrid, Spain)
Electronic Engineer - phone +34 915 422 800 ext 2416 fax +34 915 596 569
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
2005-04-07 10:10 2.6.12-rc2 in_atomic() picks up preempt_disable() Keith Owens
2005-04-07 10:17 ` Arjan van de Ven
@ 2005-04-07 10:22 ` Andrew Morton
2005-04-07 14:54 ` Ingo Molnar
2 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2005-04-07 10:22 UTC (permalink / raw)
To: Keith Owens; +Cc: mingo, linux-kernel
Keith Owens <kaos@sgi.com> wrote:
>
> 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
> in_atomic() macro thinks that preempt_disable() indicates an atomic
> region so calls to __might_sleep() result in a stack trace.
> preempt_count() returns 1, no soft or hard irqs are running and no
> spinlocks are held. It looks like there is no way to distinguish
> between the use of preempt_disable() in the lock functions (atomic) and
> preempt_disable() outside the lock functions (do nothing that might
> migrate me).
Is this new behaviour?
It sounds correct to me:
preempt_disable();
do_something_which_might_sleep();
preempt_enable();
Is buggy?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
2005-04-07 10:10 2.6.12-rc2 in_atomic() picks up preempt_disable() Keith Owens
2005-04-07 10:17 ` Arjan van de Ven
2005-04-07 10:22 ` Andrew Morton
@ 2005-04-07 14:54 ` Ingo Molnar
2 siblings, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2005-04-07 14:54 UTC (permalink / raw)
To: Keith Owens; +Cc: linux-kernel
* Keith Owens <kaos@sgi.com> wrote:
> 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
> in_atomic() macro thinks that preempt_disable() indicates an atomic
> region so calls to __might_sleep() result in a stack trace.
> preempt_count() returns 1, no soft or hard irqs are running and no
> spinlocks are held. It looks like there is no way to distinguish
> between the use of preempt_disable() in the lock functions (atomic)
> and preempt_disable() outside the lock functions (do nothing that
> might migrate me).
preempt_disable() sections are just as much atomic as spinlocked
regions. Like the name suggests it.
Ingo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
@ 2005-04-07 18:40 Mikael Pettersson
2005-04-07 18:59 ` Ingo Molnar
2005-04-07 20:17 ` Arjan van de Ven
0 siblings, 2 replies; 8+ messages in thread
From: Mikael Pettersson @ 2005-04-07 18:40 UTC (permalink / raw)
To: arjan, kaos; +Cc: linux-kernel, mingo
On Thu, 07 Apr 2005 12:17:37 +0200, Arjan van de Ven wrote:
>On Thu, 2005-04-07 at 20:10 +1000, Keith Owens wrote:
>> 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
>> in_atomic() macro thinks that preempt_disable() indicates an atomic
>> region so calls to __might_sleep() result in a stack trace.
>
>but you're not allowed to schedule when preempt is disabled!
That sounds draconian. Where is that requirement stated?
A preempt-disabled region ought to have the same semantics
as in a CONFIG_PREEMPT=n kernel, and since schedule is Ok
in the latter case it should be Ok in the former too.
All that preempt_disable() should do is prevent involuntary
schedules. But the conditional schedules introduced by may-sleep
functions are _voluntary_, so there's no reason to forbid them.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
2005-04-07 18:40 Mikael Pettersson
@ 2005-04-07 18:59 ` Ingo Molnar
2005-04-07 20:17 ` Arjan van de Ven
1 sibling, 0 replies; 8+ messages in thread
From: Ingo Molnar @ 2005-04-07 18:59 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: arjan, kaos, linux-kernel
* Mikael Pettersson <mikpe@csd.uu.se> wrote:
> On Thu, 07 Apr 2005 12:17:37 +0200, Arjan van de Ven wrote:
> >On Thu, 2005-04-07 at 20:10 +1000, Keith Owens wrote:
> >> 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
> >> in_atomic() macro thinks that preempt_disable() indicates an atomic
> >> region so calls to __might_sleep() result in a stack trace.
> >
> >but you're not allowed to schedule when preempt is disabled!
>
> That sounds draconian. Where is that requirement stated?
(in the code, and in lkml discussions, as usual. There's tons of code
that correctly handled it and continues to handle it. Let me be clear,
this isnt some obscure side-effect, this is one of the cornerstones,
preempt_disable()/enable() always had these semantics, and this is very
much being relied on in a number of areas.)
> A preempt-disabled region ought to have the same semantics as in a
> CONFIG_PREEMPT=n kernel, and since schedule is Ok in the latter case
> it should be Ok in the former too.
>
> All that preempt_disable() should do is prevent involuntary schedules.
> But the conditional schedules introduced by may-sleep functions are
> _voluntary_, so there's no reason to forbid them.
this just hides bugs and introduces bugs. From a critical section POV a
voluntary preemption is almost the same thing as a voluntary preemption
- the task may wander to another CPU, and smp_processor_id() might
become different. If it's not a problem for your code to preempt then
just enable preemption before calling it. Anyway, preempt_disable() /
preempt_enable() is pretty much an internal interface and shouldnt be
used lightly.
Ingo
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: 2.6.12-rc2 in_atomic() picks up preempt_disable()
2005-04-07 18:40 Mikael Pettersson
2005-04-07 18:59 ` Ingo Molnar
@ 2005-04-07 20:17 ` Arjan van de Ven
1 sibling, 0 replies; 8+ messages in thread
From: Arjan van de Ven @ 2005-04-07 20:17 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: kaos, linux-kernel, mingo
On Thu, 2005-04-07 at 20:40 +0200, Mikael Pettersson wrote:
> On Thu, 07 Apr 2005 12:17:37 +0200, Arjan van de Ven wrote:
> >On Thu, 2005-04-07 at 20:10 +1000, Keith Owens wrote:
> >> 2.6.12-rc2, with CONFIG_PREEMPT and CONFIG_PREEMPT_DEBUG. The
> >> in_atomic() macro thinks that preempt_disable() indicates an atomic
> >> region so calls to __might_sleep() result in a stack trace.
> >
> >but you're not allowed to schedule when preempt is disabled!
>
> That sounds draconian. Where is that requirement stated?
>
> A preempt-disabled region ought to have the same semantics
> as in a CONFIG_PREEMPT=n kernel, and since schedule is Ok
> in the latter case it should be Ok in the former too.
>
> All that preempt_disable() should do is prevent involuntary
> schedules. But the conditional schedules introduced by may-sleep
> functions are _voluntary_, so there's no reason to forbid them.
but that implies you need to remember this after schedule. all in all it
starts to smell more and more like the local irq disable flag, and I at
least thing of it in a very similar way as well.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-04-07 20:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-07 10:10 2.6.12-rc2 in_atomic() picks up preempt_disable() Keith Owens
2005-04-07 10:17 ` Arjan van de Ven
2005-04-07 12:24 ` Romano Giannetti
2005-04-07 10:22 ` Andrew Morton
2005-04-07 14:54 ` Ingo Molnar
2005-04-07 18:40 Mikael Pettersson
2005-04-07 18:59 ` Ingo Molnar
2005-04-07 20:17 ` Arjan van de Ven
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®