From: Keith Owens <kaos@sgi.com>
To: Zwane Mwaikambo <zwane@fsmlabs.com>
Cc: Andrew Morton <akpm@osdl.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][2.6-mm] i386: enable interrupts on contention in spin_lock_irq
Date: Wed, 26 May 2004 17:29:46 +1000 [thread overview]
Message-ID: <14280.1085556586@kao2.melbourne.sgi.com> (raw)
In-Reply-To: Your message of "Wed, 26 May 2004 03:11:07 -0400." <Pine.LNX.4.58.0405260250310.1794@montezuma.fsmlabs.com>
On Wed, 26 May 2004 03:11:07 -0400 (EDT),
Zwane Mwaikambo <zwane@fsmlabs.com> wrote:
>This little bit was missing from the previous patch. It will enable
>interrupts whilst a cpu is spinning on a lock in spin_lock_irq as well as
>spin_lock_irqsave. UP/SMP compile and runtime/stress tested on i386,
>UP/SMP compile tested on amd64.
>
>+#define _raw_spin_lock_irq(lock) _raw_spin_lock_flags(lock, X86_EFLAGS_IF)
You are assuming that all uses of spin_lock_irq() are done when
interrupts are already enabled. This _should_ be true, because the
matching spin_unlock_irq() will unconditionally reenable interrupts.
However I have seen buggy code where spin_lock_irq() was issued with
interrupts disabled. By unconditionally passing X86_EFLAGS_IF, that
buggy code can now run in one of two states :-
state 1
Enter with interrupts disabled
Do some work
spin_lock_irq()
No lock contention, do not enable interrupts
Do some more work
spin_unlock_irq()
state 2
Enter with interrupts disabled
Do some work
spin_lock_irq()
Lock contention, enable interrupts, get lock, disable interrupts
Do some more work
spin_unlock_irq()
Your patch opens a window where data that was protected by the disabled
interrupt on entry becomes unprotected while waiting for the lock and
can therefore change.
It could be that I am worrying unnecessarily, after all any code that
calls spin_lock_irq() with interrupts already disabled is probably
wrong to start off with. But it does need to be considered as a
possible failure mode.
next prev parent reply other threads:[~2004-05-26 7:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-26 7:11 [PATCH][2.6-mm] i386: enable interrupts on contention in spin_lock_irq Zwane Mwaikambo
2004-05-26 7:29 ` Keith Owens [this message]
2004-05-26 7:48 ` Zwane Mwaikambo
2004-05-26 7:58 ` Duncan Sands
2004-05-26 8:11 ` Zwane Mwaikambo
2004-05-27 1:45 ` 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=14280.1085556586@kao2.melbourne.sgi.com \
--to=kaos@sgi.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zwane@fsmlabs.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.