From: "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>
To: Andrew Morton <akpm@osdl.org>
Cc: greg@kroah.com, LKML <linux-kernel@vger.kernel.org>
Subject: Re: pci_walk_bus race condition
Date: Fri, 02 Jun 2006 18:51:45 +0800 [thread overview]
Message-ID: <1149245505.8436.222.camel@ymzhang-perf.sh.intel.com> (raw)
In-Reply-To: <20060601222402.f2d427b4.akpm@osdl.org>
On Fri, 2006-06-02 at 13:24, Andrew Morton wrote:
> On Thu, 1 Jun 2006 22:11:41 -0700
> Andrew Morton <akpm@osdl.org> wrote:
>
> > On Fri, 02 Jun 2006 12:35:43 +0800
> > "Zhang, Yanmin" <yanmin_zhang@linux.intel.com> wrote:
> >
> > > pci_walk_bus has a race with pci_destroy_dev. When cb is called
> > > in pci_walk_bus, pci_destroy_dev might unlink the dev pointed by next.
> > > Later on in the next loop, pointer next becomes NULL and cause
> > > kernel panic.
> > >
> > > Below patch against 2.6.17-rc4 fixes it by changing pci_bus_lock (spin_lock)
> > > to pci_bus_sem (rw_semaphore).
> >
> > How does s/spinlock/rwsem/ fix a race??
>
> oic. "and hold the lock across the callback".
Sorry for missing the statement.
>
> Is the ranking of pci_bus_sem and dev->dev.sem correct+consistent? It
> looks OK.
Yes, I think so. The write lock of pci_bus_sem and dev->dev.sem are used in
different steps. Here we use read lock of pci_bus_sem + dev->dev.sem.
>
> It might be worth making a not that the callback function cannot call any
> PCI layer function which takes pci_bus_sem - that'll casue a recursive
> down_read(), which is a nasty source of rare deadlocks.
Currently, only pci error recovery codes call it while cb are the error
callback functions in the driver. They shouldn't try to apply for write lock of
pci_walk_sem. Perhaps we could add more comments in function pci_walk_bus.
prev parent reply other threads:[~2006-06-02 10:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-26 6:35 Zhang, Yanmin
2006-05-26 13:50 ` Greg KH
2006-05-29 0:41 ` Zhang, Yanmin
2006-05-29 8:05 ` Zhang, Yanmin
2006-06-02 4:35 ` Zhang, Yanmin
2006-06-02 5:11 ` Andrew Morton
2006-06-02 5:24 ` Andrew Morton
2006-06-02 10:51 ` Zhang, Yanmin [this message]
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=1149245505.8436.222.camel@ymzhang-perf.sh.intel.com \
--to=yanmin_zhang@linux.intel.com \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--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
all inboxes | Powered by JetHome®