From: Matthew Wilcox <matthew@wil.cx>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: James Nelson <james4765@verizon.net>,
akpm@osdl.org, kernel-janitors@lists.osdl.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [KJ] Re: [PATCH] pcxx: replace cli()/sti() with spin_lock_irqsave()/spin_unlock_irqrestore()
Date: Mon, 20 Dec 2004 17:27:33 +0000 [thread overview]
Message-ID: <20041220172733.GK7113@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <1103554747.30268.24.camel@localhost.localdomain>
On Mon, Dec 20, 2004 at 02:59:09PM +0000, Alan Cox wrote:
> On Gwe, 2004-12-17 at 22:34, James Nelson wrote:
> > - save_flags(flags);
> > - cli();
> > + spin_lock_irqsave(&pcxx_lock, flags);
> > del_timer_sync(&pcxx_timer);
>
> Not safe if the lock is grabbed by the timer between the lock and the
> irqsave as it will spin on another cpu and the timer delete will never
> finish.
Right, but wrong reason ...
James admitted he thought the driver was otherwise SMP-safe; he didn't know
how to convert things from the old locking style to proper locking.
The problem with this code section is not the race between local
interrupts and the lock, since irqs are disabled before the cpu tries to
grab the lock. The problem is that if the lock is grabbed by this code
path, and then the timer running on a different CPU attempts to acquire
the lock, it will spin. del_timer_sync() will then spin waiting for
the timer to complete. We're deadlocked.
--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
next prev parent reply other threads:[~2004-12-20 17:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-17 22:34 [PATCH] pcxx: replace cli()/sti() with spin_lock_irqsave()/spin_unlock_irqrestore() James Nelson
2004-12-20 14:59 ` Alan Cox
2004-12-20 17:27 ` Matthew Wilcox [this message]
2004-12-20 20:23 ` Alan Cox
2004-12-20 21:51 ` Jim Nelson
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=20041220172733.GK7113@parcelfarce.linux.theplanet.co.uk \
--to=matthew@wil.cx \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=james4765@verizon.net \
--cc=kernel-janitors@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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