From: Greg KH <gregkh@suse.de>
To: Alex Chiang <achiang@hp.com>,
Vegard Nossum <vegard.nossum@gmail.com>,
Pekka Enberg <penberg@cs.helsinki.fi>,
Ingo Molnar <mingo@elte.hu>,
jbarnes@virtuousgeek.org, tj@kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH, RFC] sysfs: only allow one scheduled removal callback per kobj
Date: Wed, 11 Mar 2009 08:32:28 -0700 [thread overview]
Message-ID: <20090311153228.GA21217@suse.de> (raw)
In-Reply-To: <20090311070359.GF25665@ldl.fc.hp.com>
On Wed, Mar 11, 2009 at 01:03:59AM -0600, Alex Chiang wrote:
> * Greg KH <gregkh@suse.de>:
> > On Tue, Mar 10, 2009 at 05:20:27PM -0600, Alex Chiang wrote:
> > > Hi Vegard, sysfs folks,
> > >
> > > Vegard was nice enough to test my PCI remove/rescan patches under
> > > kmemcheck. Maybe "torture" is a more appropriate term. ;)
> > >
> > > My patch series introduces a sysfs "remove" attribute for PCI
> > > devices, which will remove that device (and child devices).
> > >
> > > http://thread.gmane.org/gmane.linux.kernel.pci/3495
> > >
> > > Vegard decided that he wanted to do something like:
> > >
> > > # while true ; do echo 1 > /sys/bus/pci/devices/.../remove ; done
> > >
> > > which caused a nasty oops in my code. You can see the results of
> > > his testing in the thread I referenced above.
> > >
> > > After looking at my code for a bit, I decided that maybe it
> > > wasn't completely my fault. ;) See, I'm using device_schedule_callback()
> >
> > why? Are you really in interrupt context here to need to do the remove
> > at a later time?
>
> What other interface can I use to remove objects from sysfs?
What everyone else does, device_unregister()? SCSI can't do this
because it is in interrupt context at the moment, that is why it delays
the action from happening.
> Demo:
>
> Here's the topology of my machine. Sorry about the long line, but
> device 0000:04 is a complex device with an internal bridge and 4
> PCI functions.
>
> [root@tahitifp1 ~]# lspci -vt
> +-[0000:03]---00.0-[0000:04-07]----00.0-[0000:05-07]--+-02.0-[0000:06]--+-00.0 Intel Corporation 82571EB Quad Port Gigabit Mezzanine Adapter
> | | \-00.1 Intel Corporation 82571EB Quad Port Gigabit Mezzanine Adapter
> | \-04.0-[0000:07]--+-00.0 Intel Corporation 82571EB Quad Port Gigabit Mezzanine Adapter
> | \-00.1 Intel Corporation 82571EB Quad Port Gigabit Mezzanine Adapter
>
> Here's the state of my machine before I do anything.
>
> [root@tahitifp1 ~]# ls /sys/bus/pci/devices/
> 0000:00:01.0 0000:00:02.2 0000:02:02.0 0000:05:04.0 0000:08:00.0
> 0000:00:01.1 0000:00:04.0 0000:02:02.1 0000:06:00.0 0000:0a:00.0
> 0000:00:01.2 0000:01:01.0 0000:03:00.0 0000:06:00.1
> 0000:00:02.0 0000:01:01.1 0000:04:00.0 0000:07:00.0
> 0000:00:02.1 0000:02:01.0 0000:05:02.0 0000:07:00.1
>
> We see the following PCI buses.
>
> [root@tahitifp1 ~]# ls /sys/class/pci_bus/
> 0000:00 0000:02 0000:04 0000:06 0000:08 0000:0a
> 0000:01 0000:03 0000:05 0000:07 0000:09 0000:0b
>
> Use my shiny new patch set. :)
>
> [root@tahitifp1 ~]# echo 1 > /sys/bus/pci/devices/0000\:04\:00.0/remove
>
> Now device 0000:04:00.0 is gone, as are all the devices below it.
> Just as we expect.
And this is just what other subsystems do (like USB) when their device
disappears, nothing new here :)
Why can't you use device_unregister()? Or, you could use device_del(),
which lets you rely on the fact that the device structure is still
around for a bit, but it will disappear from sysfs. Just don't forget
to do the final put_device() on it to free the memory and "really"
release it.
Or am I missing something else here?
thanks,
greg k-h
next prev parent reply other threads:[~2009-03-11 15:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-10 23:20 [PATCH, RFC] sysfs: only allow one scheduled removal callback per kobj Alex Chiang
2009-03-11 4:41 ` Greg KH
2009-03-11 7:03 ` Alex Chiang
2009-03-11 7:20 ` Tejun Heo
2009-03-12 0:27 ` Alex Chiang
2009-03-12 3:22 ` Greg KH
2009-03-12 22:02 ` Alex Chiang
2009-03-13 12:03 ` Cornelia Huck
2009-03-13 18:08 ` Alex Chiang
2009-03-11 15:32 ` Greg KH [this message]
2009-03-11 17:47 ` Cornelia Huck
2009-03-11 18:14 ` Alex Chiang
2009-03-11 18:19 ` Greg KH
2009-03-11 18:42 ` Alex Chiang
2009-03-12 10:25 ` Cornelia Huck
2009-03-12 21:33 ` Alex Chiang
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=20090311153228.GA21217@suse.de \
--to=gregkh@suse.de \
--cc=achiang@hp.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@cs.helsinki.fi \
--cc=tj@kernel.org \
--cc=vegard.nossum@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox