[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090311153228.GA21217@suse.de>
Date: Wed, 11 Mar 2009 08:32:28 -0700
From: Greg KH <gregkh@...e.de>
To: Alex Chiang <achiang@...com>,
Vegard Nossum <vegard.nossum@...il.com>,
Pekka Enberg <penberg@...helsinki.fi>,
Ingo Molnar <mingo@...e.hu>, jbarnes@...tuousgeek.org,
tj@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH, RFC] sysfs: only allow one scheduled removal callback
per kobj
On Wed, Mar 11, 2009 at 01:03:59AM -0600, Alex Chiang wrote:
> * Greg KH <gregkh@...e.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@...itifp1 ~]# 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@...itifp1 ~]# 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@...itifp1 ~]# 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@...itifp1 ~]# 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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists