From: george anzinger <george@mvista.com>
To: Robert Love <rml@tech9.net>
Cc: Linus Torvalds <torvalds@transmeta.com>,
Andrew Morton <akpm@zip.com.au>, Ingo Molnar <mingo@elte.hu>,
Zwane Mwaikambo <zwane@linuxpower.ca>,
Trond Myklebust <trond.myklebust@fys.uio.no>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [patch] irqlock patch -G3. [was Re: odd memorycorruptionin2.5.27?]
Date: Wed, 24 Jul 2002 13:56:05 -0700 [thread overview]
Message-ID: <3D3F1465.ACA06312@mvista.com> (raw)
In-Reply-To: 1027529360.3581.1213.camel@sinai
Robert Love wrote:
>
> On Wed, 2002-07-24 at 09:40, Linus Torvalds wrote:
>
> > Just as an example, in the not too distant future what _will_ happen is
> > that
> >
> > spin_lock_irqsave()
> > ..
> > spin_unlock_irqrestore()
> >
> > will not necessarily increment the preemtion count. Why should they?
> > They've disabled local interrupts, so there's no preemption to protect
> > against. That's just an _obvious_ optimization.
I thought this was the thing to do back at the beginning of
the preemption saga, but now I am not so sure. Lately I
have been doing a bit of code in the clock routines. These
get called from both interrupt context and from normal
context and thus need to use the IRQ locks. The task entry
does a spin_lock_irq() and the interrupt routine KNOWS
interrupts are off and just does a spin_lock(). The inner
code just knows that it is wrapped by an IRQ off and so does
not use the IRQ version of the spin locks it needs.
The above change would auger that the "inner" code should
use _raw* spinlocks OR should use the nested IRQ locks. But
an IRQ lock is a LOT more expensive (due to the hardware
sync implied by messing with the interrupt system) than inc
and dec on a counter.
This, by the way, is the same reason that
preempt_enable()/preemp_disable() should be preferred over
local_irq_disable()/local_irq_enable() when either would do
the job.
>
> So obvious it is even in my queue :)
>
> I do not think we are ready yet - there is just way too much code that
> does not pair up as you mention... but I have played with the patch and
> some debugging to see just how feasible it is. Fairly soon.
>
> Note that other preemptible kernels (IRIX and BeOS, for example) do not
> even have a preemption count -- all spinlocks also disable interrupts.
> Not that I am suggesting that, I am very fond of our preempt_count
> mechanism, but its a point to consider even if it were feasible (e.g. we
> did not have spinlocks held for hundreds of milliseconds).
>
> > We can easily add a debugging check to spin_unlock() that says:
> >
> > /* Somebody messed up, doesn't hold any other preemption thing
> > * than this lock that is now getting released, and has interrupts
> > * disabled
> > */
> > BUG_ON(preempt_count() == 1 && interrupts_enabled())
> >
> > No?
>
> Pretty similar to the debugging I played with... as long as it goes away
> eventually (who wants this in their unlock path?) we certainly should
> add it at some point.
I think we also need to have debugging code in the
local_irq_enable() to make sure the correct preemption
enable is being done.
--
George Anzinger george@mvista.com
High-res-timers:
http://sourceforge.net/projects/high-res-timers/
Real time sched: http://sourceforge.net/projects/rtsched/
Preemption patch:
http://www.kernel.org/pub/linux/kernel/people/rml
next prev parent reply other threads:[~2002-07-24 21:12 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-23 6:23 odd memory corruption in 2.5.27? Zwane Mwaikambo
2002-07-23 6:24 ` Zwane Mwaikambo
2002-07-23 6:26 ` Zwane Mwaikambo
2002-07-23 7:57 ` Trond Myklebust
2002-07-23 8:54 ` Zwane Mwaikambo
2002-07-23 20:32 ` george anzinger
2002-07-23 20:47 ` William Lee Irwin III
2002-07-23 23:28 ` [patch] irqlock patch -G3. [was Re: odd memory corruption in 2.5.27?] Ingo Molnar
2002-07-23 23:53 ` george anzinger
2002-07-23 23:56 ` Linus Torvalds
2002-07-24 0:07 ` Ingo Molnar
2002-07-24 2:15 ` Linus Torvalds
2002-07-24 8:59 ` [patch] irqlock patch 2.5.27-H3 Ingo Molnar
2002-07-24 1:08 ` [patch] irqlock patch -G3. [was Re: odd memory corruption in 2.5.27?] Robert Love
2002-07-24 3:13 ` [patch] irqlock patch -G3. [was Re: odd memory corruption in2.5.27?] Andrew Morton
2002-07-24 3:18 ` Linus Torvalds
2002-07-24 7:13 ` Ingo Molnar
2002-07-24 7:34 ` Ingo Molnar
2002-07-24 8:00 ` [patch] irqlock patch -G3. [was Re: odd memory corruptionin2.5.27?] Andrew Morton
2002-07-24 7:54 ` Ingo Molnar
2002-07-24 8:03 ` William Lee Irwin III
2002-07-24 8:06 ` Ingo Molnar
2002-07-24 8:15 ` William Lee Irwin III
2002-07-24 8:17 ` Ingo Molnar
2002-07-24 16:40 ` Linus Torvalds
2002-07-24 16:49 ` Robert Love
2002-07-24 20:56 ` george anzinger [this message]
2002-07-24 7:37 ` [patch] irqlock patch -G3. [was Re: odd memory corruption in2.5.27?] Ingo Molnar
2002-07-24 6:52 ` odd memory corruption in 2.5.27? Zwane Mwaikambo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D3F1465.ACA06312@mvista.com \
--to=george@mvista.com \
--cc=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rml@tech9.net \
--cc=torvalds@transmeta.com \
--cc=trond.myklebust@fys.uio.no \
--cc=zwane@linuxpower.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox