public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Chris Wright <chris@wirex.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] PCI device list locking - take 2
Date: Wed, 18 Jun 2003 16:52:32 -0700	[thread overview]
Message-ID: <20030618235232.GA2667@kroah.com> (raw)
In-Reply-To: <20030618163237.A21050@figure1.int.wirex.com>

On Wed, Jun 18, 2003 at 04:32:37PM -0700, Chris Wright wrote:
> * Greg KH (greg@kroah.com) wrote:
> > Hm, I think we should probably just check in pci_get_device() to verify
> > that ->next is really valid.  If it isn't just return NULL, as we have
> > no idea what the next device would possibly be.  The worse thing that
> > would happen is the proc file would be a bit shorter than expected.  If
> > read again, it would be correct, with the previously referenced device
> > now gone.
> 
> I'm not sure testing a valid ->next makes sense.  It could be non-NULL,
> but poison, or if it was using list_del_init, it would be stuck in loop.

When we take the devices off of the list, after list_del(), still under
the lock, we can null out the list pointers.  Then, later under the
lock, we can check the pointer before we move to it.  We aren't doing
fancy list_* functions with the pci device lists at all.

> > I don't want to try to hold a lock over start/next/stop as that would
> > just be asking for trouble :)
> 
> Heh, I agree, it doesn't feel quite right to acquire lock and release
> lock in separate functions, but in the case of start/show/next/stop this
> seems to be the design.  Alternative here seems to be keeping thing on
> list with get and deleting from with put on last ref, but that didn't
> look so simple.

No, that isn't the proper model anyway.  After the device is removed, we
don't want to still have it floating around on the device lists, even if
someone has a reference to it.  That would make things just too
difficult :)

I'll go and try to see how the above proposed changes will work out, and
see if I can see any side affects when beating on /proc/pci on a pci
hotplug box...

thanks,

greg k-h

  reply	other threads:[~2003-06-19  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-18 21:29 [RFC] PCI device list locking - take 2 Greg KH
2003-06-18 22:33 ` Chris Wright
2003-06-18 22:46   ` Greg KH
2003-06-18 23:32     ` Chris Wright
2003-06-18 23:52       ` Greg KH [this message]
2003-06-19  0:20         ` Chris Wright

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=20030618235232.GA2667@kroah.com \
    --to=greg@kroah.com \
    --cc=chris@wirex.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