<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/sysfs/file.c, branch v2.6.34</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>sysfs: Only take active references on attributes.</title>
<updated>2010-03-08T01:04:51+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2010-02-11T23:20:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=a2db6842873c8e5a70652f278d469128cb52db70'/>
<id>a2db6842873c8e5a70652f278d469128cb52db70</id>
<content type='text'>
If we exclude directories and symlinks from the set of sysfs
dirents where we need active references we are left with
sysfs attributes (binary or not).

- Tweak sysfs_deactivate to only do something on attributes
- Move lockdep initialization into sysfs_file_add_mode to
  limit it to just attributes.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we exclude directories and symlinks from the set of sysfs
dirents where we need active references we are left with
sysfs attributes (binary or not).

- Tweak sysfs_deactivate to only do something on attributes
- Move lockdep initialization into sysfs_file_add_mode to
  limit it to just attributes.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Acked-by: WANG Cong &lt;xiyou.wangcong@gmail.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: Remove sysfs_get/put_active_two</title>
<updated>2010-03-08T01:04:51+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2010-02-11T23:18:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e72ceb8ccac5f770b3e696e09bb673dca7024b20'/>
<id>e72ceb8ccac5f770b3e696e09bb673dca7024b20</id>
<content type='text'>
It turns out that holding an active reference on a directory is
pointless.  The purpose of the active references are to allows us to
block when removing sysfs entries that have custom methods so we don't
remove modules while running modular code and to keep those custom
methods from accessing data structures after the files have been
removed.  Further sysfs_remove_dir remove all elements in the
directory before removing the directory itself, so there is no chance
we will remove a directory with active children.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It turns out that holding an active reference on a directory is
pointless.  The purpose of the active references are to allows us to
block when removing sysfs entries that have custom methods so we don't
remove modules while running modular code and to keep those custom
methods from accessing data structures after the files have been
removed.  Further sysfs_remove_dir remove all elements in the
directory before removing the directory itself, so there is no chance
we will remove a directory with active children.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>Driver core: Constify struct sysfs_ops in struct kobj_type</title>
<updated>2010-03-08T01:04:49+00:00</updated>
<author>
<name>Emese Revfy</name>
<email>re.emese@gmail.com</email>
</author>
<published>2010-01-19T01:58:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=52cf25d0ab7f78eeecc59ac652ed5090f69b619e'/>
<id>52cf25d0ab7f78eeecc59ac652ed5090f69b619e</id>
<content type='text'>
Constify struct sysfs_ops.

This is part of the ops structure constification
effort started by Arjan van de Ven et al.

Benefits of this constification:

 * prevents modification of data that is shared
   (referenced) by many other structure instances
   at runtime

 * detects/prevents accidental (but not intentional)
   modification attempts on archs that enforce
   read-only kernel data at runtime

 * potentially better optimized code as the compiler
   can assume that the const data cannot be changed

 * the compiler/linker move const data into .rodata
   and therefore exclude them from false sharing

Signed-off-by: Emese Revfy &lt;re.emese@gmail.com&gt;
Acked-by: David Teigland &lt;teigland@redhat.com&gt;
Acked-by: Matt Domsch &lt;Matt_Domsch@dell.com&gt;
Acked-by: Maciej Sosnowski &lt;maciej.sosnowski@intel.com&gt;
Acked-by: Hans J. Koch &lt;hjk@linutronix.de&gt;
Acked-by: Pekka Enberg &lt;penberg@cs.helsinki.fi&gt;
Acked-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Acked-by: Stephen Hemminger &lt;shemminger@vyatta.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Constify struct sysfs_ops.

This is part of the ops structure constification
effort started by Arjan van de Ven et al.

Benefits of this constification:

 * prevents modification of data that is shared
   (referenced) by many other structure instances
   at runtime

 * detects/prevents accidental (but not intentional)
   modification attempts on archs that enforce
   read-only kernel data at runtime

 * potentially better optimized code as the compiler
   can assume that the const data cannot be changed

 * the compiler/linker move const data into .rodata
   and therefore exclude them from false sharing

Signed-off-by: Emese Revfy &lt;re.emese@gmail.com&gt;
Acked-by: David Teigland &lt;teigland@redhat.com&gt;
Acked-by: Matt Domsch &lt;Matt_Domsch@dell.com&gt;
Acked-by: Maciej Sosnowski &lt;maciej.sosnowski@intel.com&gt;
Acked-by: Hans J. Koch &lt;hjk@linutronix.de&gt;
Acked-by: Pekka Enberg &lt;penberg@cs.helsinki.fi&gt;
Acked-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Acked-by: Stephen Hemminger &lt;shemminger@vyatta.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: Add sysfs_add/remove_files utility functions</title>
<updated>2010-03-08T01:04:47+00:00</updated>
<author>
<name>Andi Kleen</name>
<email>andi@firstfloor.org</email>
</author>
<published>2010-01-05T11:48:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=1c205ae18db53ff72985dd79f3baaf2dbaba6db7'/>
<id>1c205ae18db53ff72985dd79f3baaf2dbaba6db7</id>
<content type='text'>
Adding/Removing a whole array of attributes is very common. Add a standard
utility function to do this with a simple function call, instead of
requiring drivers to open code this.

Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;


</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Adding/Removing a whole array of attributes is very common. Add a standard
utility function to do this with a simple function call, instead of
requiring drivers to open code this.

Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;


</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: In sysfs_chmod_file lazily propagate the mode change.</title>
<updated>2009-12-11T19:24:54+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2009-11-21T00:08:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=06fc0d66f7ed3a3b08e8fcf8c325ecf0b8f93fea'/>
<id>06fc0d66f7ed3a3b08e8fcf8c325ecf0b8f93fea</id>
<content type='text'>
Now that sysfs_getattr and sysfs_permission refresh the vfs
inode there is no need to immediatly push the mode change
into the vfs cache.  Reducing the amount of work needed and
simplifying the locking.

Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@aristanetworks.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that sysfs_getattr and sysfs_permission refresh the vfs
inode there is no need to immediatly push the mode change
into the vfs cache.  Reducing the amount of work needed and
simplifying the locking.

Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@aristanetworks.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: Simplify sysfs_chmod_file semantics</title>
<updated>2009-12-11T19:24:53+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2009-11-08T07:27:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=4c6974f51a981d14f13e36049d6307d3bcda550e'/>
<id>4c6974f51a981d14f13e36049d6307d3bcda550e</id>
<content type='text'>
Currently every caller of sysfs_chmod_file happens at either
file creation time to set a non-default mode or in response
to a specific user requested space change in policy.  Making
timestamps of when the chmod happens and notification of
a file changing mode uninteresting.

Remove the unnecessary time stamp and filesystem change
notification, and removes the last of the explicit inotify
and donitfy support from sysfs.

Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@aristanetworks.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently every caller of sysfs_chmod_file happens at either
file creation time to set a non-default mode or in response
to a specific user requested space change in policy.  Making
timestamps of when the chmod happens and notification of
a file changing mode uninteresting.

Remove the unnecessary time stamp and filesystem change
notification, and removes the last of the explicit inotify
and donitfy support from sysfs.

Acked-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Signed-off-by: Eric W. Biederman &lt;ebiederm@aristanetworks.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: Allow sysfs_notify_dirent to be called from interrupt context.</title>
<updated>2009-10-14T22:16:25+00:00</updated>
<author>
<name>Neil Brown</name>
<email>neilb@suse.de</email>
</author>
<published>2009-09-15T23:05:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=83db93f4de2d9ae441a491d1dc61c2204f0195de'/>
<id>83db93f4de2d9ae441a491d1dc61c2204f0195de</id>
<content type='text'>
sysfs_notify_dirent is a simple atomic operation that can be used to
alert user-space that new data can be read from a sysfs attribute.

Unfortunately it cannot currently be called from non-process context
because of its use of spin_lock which is sometimes taken with
interrupts enabled.

So change all lockers of sysfs_open_dirent_lock to disable interrupts,
thus making sysfs_notify_dirent safe to be called from non-process
context (as drivers/md does in md_safemode_timeout).

sysfs_get_open_dirent is (documented as being) only called from
process context, so it uses spin_lock_irq.  Other places
use spin_lock_irqsave.

The usage for sysfs_notify_dirent in md_safemode_timeout was
introduced in 2.6.28, so this patch is suitable for that and more
recent kernels.

Reported-by: Joel Andres Granados &lt;jgranado@redhat.com&gt;
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
sysfs_notify_dirent is a simple atomic operation that can be used to
alert user-space that new data can be read from a sysfs attribute.

Unfortunately it cannot currently be called from non-process context
because of its use of spin_lock which is sometimes taken with
interrupts enabled.

So change all lockers of sysfs_open_dirent_lock to disable interrupts,
thus making sysfs_notify_dirent safe to be called from non-process
context (as drivers/md does in md_safemode_timeout).

sysfs_get_open_dirent is (documented as being) only called from
process context, so it uses spin_lock_irq.  Other places
use spin_lock_irqsave.

The usage for sysfs_notify_dirent in md_safemode_timeout was
introduced in 2.6.28, so this patch is suitable for that and more
recent kernels.

Reported-by: Joel Andres Granados &lt;jgranado@redhat.com&gt;
Signed-off-by: NeilBrown &lt;neilb@suse.de&gt;
Signed-off-by: Dan Williams &lt;dan.j.williams@intel.com&gt;
Cc: stable &lt;stable@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: file.c: use create_singlethread_workqueue()</title>
<updated>2009-05-28T21:24:07+00:00</updated>
<author>
<name>Andrew Morton</name>
<email>akpm@linux-foundation.org</email>
</author>
<published>2009-05-07T19:36:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=086a377edc969aea6c761176a7e4ff68f264d6fe'/>
<id>086a377edc969aea6c761176a7e4ff68f264d6fe</id>
<content type='text'>
We don't need a kernel thread per CPU for this application.

Acked-by: Alex Chiang &lt;achiang@hp.com&gt;
Cc: Lai Jiangshan &lt;laijs@cn.fujitsu.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We don't need a kernel thread per CPU for this application.

Acked-by: Alex Chiang &lt;achiang@hp.com&gt;
Cc: Lai Jiangshan &lt;laijs@cn.fujitsu.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: sysfs poll keep the poll rule of regular file.</title>
<updated>2009-04-16T23:17:09+00:00</updated>
<author>
<name>KOSAKI Motohiro</name>
<email>kosaki.motohiro@jp.fujitsu.com</email>
</author>
<published>2009-04-09T04:53:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=1af3557abdef34ee036a6de4cb79e24468544b8d'/>
<id>1af3557abdef34ee036a6de4cb79e24468544b8d</id>
<content type='text'>
Currently, following test programs don't finished.

% ruby -e '
Thread.new { sleep }
File.read("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies")
'

strace expose the reason.

...
open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf9fa6b8) = -1 ENOTTY (Inappropriate ioctl for device)
fstat64(3, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
_llseek(3, 0, [0], SEEK_CUR)            = 0
select(4, [3], NULL, NULL, NULL)        = 1 (in [3])
read(3, "1400000 1300000 1200000 1100000 1"..., 4096) = 62
select(4, [3], NULL, NULL, NULL


Because Ruby (the scripting language) VM assume select system-call
against regular file don't block.  it because SUSv3 says "Regular files
shall always poll TRUE for reading and writing".  see
http://www.opengroup.org/onlinepubs/009695399/functions/poll.html it
seems valid assumption.

But sysfs_poll() don't keep this rule although sysfs file can read and
write always.

This patch restore proper poll behavior to sysfs.
/sys/block/md*/md/sync_action polling application and another sysfs
updating sensitive application still can use POLLERR and POLLPRI.

Cc: Neil Brown &lt;neilb@suse.de&gt;
Signed-off-by: KOSAKI Motohiro &lt;kosaki.motohiro@jp.fujitsu.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently, following test programs don't finished.

% ruby -e '
Thread.new { sleep }
File.read("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies")
'

strace expose the reason.

...
open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", O_RDONLY|O_LARGEFILE) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbf9fa6b8) = -1 ENOTTY (Inappropriate ioctl for device)
fstat64(3, {st_mode=S_IFREG|0444, st_size=4096, ...}) = 0
_llseek(3, 0, [0], SEEK_CUR)            = 0
select(4, [3], NULL, NULL, NULL)        = 1 (in [3])
read(3, "1400000 1300000 1200000 1100000 1"..., 4096) = 62
select(4, [3], NULL, NULL, NULL


Because Ruby (the scripting language) VM assume select system-call
against regular file don't block.  it because SUSv3 says "Regular files
shall always poll TRUE for reading and writing".  see
http://www.opengroup.org/onlinepubs/009695399/functions/poll.html it
seems valid assumption.

But sysfs_poll() don't keep this rule although sysfs file can read and
write always.

This patch restore proper poll behavior to sysfs.
/sys/block/md*/md/sync_action polling application and another sysfs
updating sensitive application still can use POLLERR and POLLPRI.

Cc: Neil Brown &lt;neilb@suse.de&gt;
Signed-off-by: KOSAKI Motohiro &lt;kosaki.motohiro@jp.fujitsu.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
<entry>
<title>sysfs: don't use global workqueue in sysfs_schedule_callback()</title>
<updated>2009-04-16T23:17:08+00:00</updated>
<author>
<name>Alex Chiang</name>
<email>achiang@hp.com</email>
</author>
<published>2009-03-25T21:11:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=d110271e1f4140a9fb06d968b1afe9ca56a6064e'/>
<id>d110271e1f4140a9fb06d968b1afe9ca56a6064e</id>
<content type='text'>
A sysfs attribute using sysfs_schedule_callback() to commit suicide
may end up calling device_unregister(), which will eventually call
a driver's -&gt;remove function.

Drivers may call flush_scheduled_work() in their shutdown routines,
in which case lockdep will complain with something like the following:

  =============================================
  [ INFO: possible recursive locking detected ]
  2.6.29-rc8-kk #1
  ---------------------------------------------
  events/4/56 is trying to acquire lock:
  (events){--..}, at: [&lt;ffffffff80257fc0&gt;] flush_workqueue+0x0/0xa0

  but task is already holding lock:
  (events){--..}, at: [&lt;ffffffff80257648&gt;] run_workqueue+0x108/0x230

  other info that might help us debug this:
  3 locks held by events/4/56:
  #0:  (events){--..}, at: [&lt;ffffffff80257648&gt;] run_workqueue+0x108/0x230
  #1:  (&amp;ss-&gt;work){--..}, at: [&lt;ffffffff80257648&gt;] run_workqueue+0x108/0x230
  #2:  (pci_remove_rescan_mutex){--..}, at: [&lt;ffffffff803c10d1&gt;] remove_callback+0x21/0x40

  stack backtrace:
  Pid: 56, comm: events/4 Not tainted 2.6.29-rc8-kk #1
  Call Trace:
  [&lt;ffffffff8026dfcd&gt;] validate_chain+0xb7d/0x1260
  [&lt;ffffffff8026eade&gt;] __lock_acquire+0x42e/0xa40
  [&lt;ffffffff8026f148&gt;] lock_acquire+0x58/0x80
  [&lt;ffffffff80257fc0&gt;] ? flush_workqueue+0x0/0xa0
  [&lt;ffffffff8025800d&gt;] flush_workqueue+0x4d/0xa0
  [&lt;ffffffff80257fc0&gt;] ? flush_workqueue+0x0/0xa0
  [&lt;ffffffff80258070&gt;] flush_scheduled_work+0x10/0x20
  [&lt;ffffffffa0144065&gt;] e1000_remove+0x55/0xfe [e1000e]
  [&lt;ffffffff8033ee30&gt;] ? sysfs_schedule_callback_work+0x0/0x50
  [&lt;ffffffff803bfeb2&gt;] pci_device_remove+0x32/0x70
  [&lt;ffffffff80441da9&gt;] __device_release_driver+0x59/0x90
  [&lt;ffffffff80441edb&gt;] device_release_driver+0x2b/0x40
  [&lt;ffffffff804419d6&gt;] bus_remove_device+0xa6/0x120
  [&lt;ffffffff8043e46b&gt;] device_del+0x12b/0x190
  [&lt;ffffffff8043e4f6&gt;] device_unregister+0x26/0x70
  [&lt;ffffffff803ba969&gt;] pci_stop_dev+0x49/0x60
  [&lt;ffffffff803baab0&gt;] pci_remove_bus_device+0x40/0xc0
  [&lt;ffffffff803c10d9&gt;] remove_callback+0x29/0x40
  [&lt;ffffffff8033ee4f&gt;] sysfs_schedule_callback_work+0x1f/0x50
  [&lt;ffffffff8025769a&gt;] run_workqueue+0x15a/0x230
  [&lt;ffffffff80257648&gt;] ? run_workqueue+0x108/0x230
  [&lt;ffffffff8025846f&gt;] worker_thread+0x9f/0x100
  [&lt;ffffffff8025bce0&gt;] ? autoremove_wake_function+0x0/0x40
  [&lt;ffffffff802583d0&gt;] ? worker_thread+0x0/0x100
  [&lt;ffffffff8025b89d&gt;] kthread+0x4d/0x80
  [&lt;ffffffff8020d4ba&gt;] child_rip+0xa/0x20
  [&lt;ffffffff8020cebc&gt;] ? restore_args+0x0/0x30
  [&lt;ffffffff8025b850&gt;] ? kthread+0x0/0x80
  [&lt;ffffffff8020d4b0&gt;] ? child_rip+0x0/0x20

Although we know that the device_unregister path will never acquire
a lock that a driver might try to acquire in its -&gt;remove, in general
we should never attempt to flush a workqueue from within the same
workqueue, and lockdep rightly complains.

So as long as sysfs attributes cannot commit suicide directly and we
are stuck with this callback mechanism, put the sysfs callbacks on
their own workqueue instead of the global one.

This has the side benefit that if a suicidal sysfs attribute kicks
off a long chain of -&gt;remove callbacks, we no longer induce a long
delay on the global queue.

This also fixes a missing module_put in the error path introduced
by sysfs-only-allow-one-scheduled-removal-callback-per-kobj.patch.

We never destroy the workqueue, but I'm not sure that's a
problem.

Reported-by: Kenji Kaneshige &lt;kaneshige.kenji@jp.fujitsu.com&gt;
Tested-by: Kenji Kaneshige &lt;kaneshige.kenji@jp.fujitsu.com&gt;
Signed-off-by: Alex Chiang &lt;achiang@hp.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A sysfs attribute using sysfs_schedule_callback() to commit suicide
may end up calling device_unregister(), which will eventually call
a driver's -&gt;remove function.

Drivers may call flush_scheduled_work() in their shutdown routines,
in which case lockdep will complain with something like the following:

  =============================================
  [ INFO: possible recursive locking detected ]
  2.6.29-rc8-kk #1
  ---------------------------------------------
  events/4/56 is trying to acquire lock:
  (events){--..}, at: [&lt;ffffffff80257fc0&gt;] flush_workqueue+0x0/0xa0

  but task is already holding lock:
  (events){--..}, at: [&lt;ffffffff80257648&gt;] run_workqueue+0x108/0x230

  other info that might help us debug this:
  3 locks held by events/4/56:
  #0:  (events){--..}, at: [&lt;ffffffff80257648&gt;] run_workqueue+0x108/0x230
  #1:  (&amp;ss-&gt;work){--..}, at: [&lt;ffffffff80257648&gt;] run_workqueue+0x108/0x230
  #2:  (pci_remove_rescan_mutex){--..}, at: [&lt;ffffffff803c10d1&gt;] remove_callback+0x21/0x40

  stack backtrace:
  Pid: 56, comm: events/4 Not tainted 2.6.29-rc8-kk #1
  Call Trace:
  [&lt;ffffffff8026dfcd&gt;] validate_chain+0xb7d/0x1260
  [&lt;ffffffff8026eade&gt;] __lock_acquire+0x42e/0xa40
  [&lt;ffffffff8026f148&gt;] lock_acquire+0x58/0x80
  [&lt;ffffffff80257fc0&gt;] ? flush_workqueue+0x0/0xa0
  [&lt;ffffffff8025800d&gt;] flush_workqueue+0x4d/0xa0
  [&lt;ffffffff80257fc0&gt;] ? flush_workqueue+0x0/0xa0
  [&lt;ffffffff80258070&gt;] flush_scheduled_work+0x10/0x20
  [&lt;ffffffffa0144065&gt;] e1000_remove+0x55/0xfe [e1000e]
  [&lt;ffffffff8033ee30&gt;] ? sysfs_schedule_callback_work+0x0/0x50
  [&lt;ffffffff803bfeb2&gt;] pci_device_remove+0x32/0x70
  [&lt;ffffffff80441da9&gt;] __device_release_driver+0x59/0x90
  [&lt;ffffffff80441edb&gt;] device_release_driver+0x2b/0x40
  [&lt;ffffffff804419d6&gt;] bus_remove_device+0xa6/0x120
  [&lt;ffffffff8043e46b&gt;] device_del+0x12b/0x190
  [&lt;ffffffff8043e4f6&gt;] device_unregister+0x26/0x70
  [&lt;ffffffff803ba969&gt;] pci_stop_dev+0x49/0x60
  [&lt;ffffffff803baab0&gt;] pci_remove_bus_device+0x40/0xc0
  [&lt;ffffffff803c10d9&gt;] remove_callback+0x29/0x40
  [&lt;ffffffff8033ee4f&gt;] sysfs_schedule_callback_work+0x1f/0x50
  [&lt;ffffffff8025769a&gt;] run_workqueue+0x15a/0x230
  [&lt;ffffffff80257648&gt;] ? run_workqueue+0x108/0x230
  [&lt;ffffffff8025846f&gt;] worker_thread+0x9f/0x100
  [&lt;ffffffff8025bce0&gt;] ? autoremove_wake_function+0x0/0x40
  [&lt;ffffffff802583d0&gt;] ? worker_thread+0x0/0x100
  [&lt;ffffffff8025b89d&gt;] kthread+0x4d/0x80
  [&lt;ffffffff8020d4ba&gt;] child_rip+0xa/0x20
  [&lt;ffffffff8020cebc&gt;] ? restore_args+0x0/0x30
  [&lt;ffffffff8025b850&gt;] ? kthread+0x0/0x80
  [&lt;ffffffff8020d4b0&gt;] ? child_rip+0x0/0x20

Although we know that the device_unregister path will never acquire
a lock that a driver might try to acquire in its -&gt;remove, in general
we should never attempt to flush a workqueue from within the same
workqueue, and lockdep rightly complains.

So as long as sysfs attributes cannot commit suicide directly and we
are stuck with this callback mechanism, put the sysfs callbacks on
their own workqueue instead of the global one.

This has the side benefit that if a suicidal sysfs attribute kicks
off a long chain of -&gt;remove callbacks, we no longer induce a long
delay on the global queue.

This also fixes a missing module_put in the error path introduced
by sysfs-only-allow-one-scheduled-removal-callback-per-kobj.patch.

We never destroy the workqueue, but I'm not sure that's a
problem.

Reported-by: Kenji Kaneshige &lt;kaneshige.kenji@jp.fujitsu.com&gt;
Tested-by: Kenji Kaneshige &lt;kaneshige.kenji@jp.fujitsu.com&gt;
Signed-off-by: Alex Chiang &lt;achiang@hp.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</pre>
</div>
</content>
</entry>
</feed>
