kernfs: skip lockdep annotation always if ignore_lockdep is set
PATCH 1/1 kernfs: skip lockdep annotation always if ignore_lockdep is set
We skip lockdep annotations for sysfs attributes with ignore_lockdep set. An exception is kernfs_deactivate where we annotate even in this case. Since the lockdep map key needed for the annotation is not initialized whenever ignore_lockdep is set, we'll get a warning for the uninitialized key.
Note that this happens since,
commit 517e64f57883bd63c5a4ab8b3d0d3ed68c55d0cf
Author: Tejun Heo <[email protected]> Date: Thu Nov 28 14:54:29 2013 -0500
Before this change we had a valid key even in case of ignore_lockdep, so the annotation in kernfs_deactivate worked, or at least didn't produce the above warning. Fix this by skipping the annotation whenever ignore_lockdep is set.
The actual attribute triggering the bug was 'delete_device' in drivers/i2c/i2c-core.c, for the backtrace see the reference below.
Reference: http://lists.freedesktop.org/archives/intel-gfx/2014-February/039663.html
--- fs/kernfs/dir.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/kernfs/dir.c +8 -4
@@ -187,19 +187,23 @@ static void kernfs_deactivate(struct kernfs_node *kn) kn->u.completion = (void *)&wait; -rwsem_acquire (&kn->dep_map,0 ,0 , _RET_IP_); +if (kn->flags &KERNFS_LOCKDEP ) +rwsem_acquire (&kn->dep_map,0 ,0 , _RET_IP_);/* atomic_add_return() is a mb(), put_active() will always see * the updated kn->u.completion. */ v =atomic_add_return (KN_DEACTIVATED_BIAS , &kn->active);if (v !=KN_DEACTIVATED_BIAS ) { -lock_contended (&kn->dep_map, _RET_IP_); +if (kn->flags &KERNFS_LOCKDEP ) +lock_contended (&kn->dep_map, _RET_IP_);wait_for_completion (&wait); } -lock_acquired (&kn->dep_map, _RET_IP_); -rwsem_release (&kn->dep_map,1 , _RET_IP_); +if (kn->flags &KERNFS_LOCKDEP ) { +lock_acquired (&kn->dep_map, _RET_IP_); +rwsem_release (&kn->dep_map,1 , _RET_IP_); + } }/**
Signature · 1 line
1.8.1.2
Tejun Heo
maintainerQuoted 12 lines · Imre Deak
We skip lockdep annotations for sysfs attributes with
ignore_lockdepset. An exception iskernfs_deactivatewhere we annotate even in this case. Since the lockdep map key needed for the annotation is not initialized wheneverignore_lockdepis set, we'll get a warning for the uninitialized key.Note that this happens since,
commit
517e64f57883bd63c5a4ab8b3d0d3ed68c55d0cfAuthor: Tejun Heo <[email protected]> Date: Thu Nov 28 14:54:29 2013 -0500
Quoted 7 lines
Before this change we had a valid key even in case of
ignore_lockdep, so the annotation inkernfs_deactivateworked, or at least didn't produce the above warning. Fix this by skipping the annotation wheneverignore_lockdepis set.The actual attribute triggering the bug was '
delete_device' indrivers/i2c/i2c-core.c, for the backtrace see the reference below.
I think Greg already has about the same patch queued.
http://lkml.kernel.org/g/[email protected]
Thanks.
Signature · 1 line
tejun
Greg Kroah-Hartman
maintainerQuoted 18 lines · Tejun Heo
Quoted 17 lines · Imre Deak
We skip lockdep annotations for sysfs attributes with
ignore_lockdepset. An exception iskernfs_deactivatewhere we annotate even in this case. Since the lockdep map key needed for the annotation is not initialized wheneverignore_lockdepis set, we'll get a warning for the uninitialized key.Note that this happens since,
commit
517e64f57883bd63c5a4ab8b3d0d3ed68c55d0cfAuthor: Tejun Heo <[email protected]> Date: Thu Nov 28 14:54:29 2013 -0500Before this change we had a valid key even in case of
ignore_lockdep, so the annotation inkernfs_deactivateworked, or at least didn't produce the above warning. Fix this by skipping the annotation wheneverignore_lockdepis set.
Quoted 6 lines
Quoted 2 lines
The actual attribute triggering the bug was '
delete_device' indrivers/i2c/i2c-core.c, for the backtrace see the reference below.I think Greg already has about the same patch queued.
Yes, I just sent it to Linus a few minutes ago.
thanks,
greg k-h