Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit43be438

Browse files
fbqPeter Zijlstra
authored and
Peter Zijlstra
committed
lockdep: Put graph lock/unlock under lock_recursion protection
A warning was hit when running xfstests/generic/068 in a Hyper-V guest:[...] ------------[ cut here ]------------[...] DEBUG_LOCKS_WARN_ON(lockdep_hardirqs_enabled())[...] WARNING: CPU: 2 PID: 1350 at kernel/locking/lockdep.c:5280 check_flags.part.0+0x165/0x170[...] ...[...] Workqueue: events pwq_unbound_release_workfn[...] RIP: 0010:check_flags.part.0+0x165/0x170[...] ...[...] Call Trace:[...] lock_is_held_type+0x72/0x150[...] ? lock_acquire+0x16e/0x4a0[...] rcu_read_lock_sched_held+0x3f/0x80[...] __send_ipi_one+0x14d/0x1b0[...] hv_send_ipi+0x12/0x30[...] __pv_queued_spin_unlock_slowpath+0xd1/0x110[...] __raw_callee_save___pv_queued_spin_unlock_slowpath+0x11/0x20[...] .slowpath+0x9/0xe[...] lockdep_unregister_key+0x128/0x180[...] pwq_unbound_release_workfn+0xbb/0xf0[...] process_one_work+0x227/0x5c0[...] worker_thread+0x55/0x3c0[...] ? process_one_work+0x5c0/0x5c0[...] kthread+0x153/0x170[...] ? __kthread_bind_mask+0x60/0x60[...] ret_from_fork+0x1f/0x30The cause of the problem is we have call chain lockdep_unregister_key()-> <irq disabled by raw_local_irq_save()> lockdep_unlock() ->arch_spin_unlock() -> __pv_queued_spin_unlock_slowpath() -> pv_kick() ->__send_ipi_one() -> trace_hyperv_send_ipi_one().Although this particular warning is triggered because Hyper-V has atrace point in ipi sending, but in general arch_spin_unlock() may callanother function having a trace point in it, so put the arch_spin_lock()and arch_spin_unlock() after lock_recursion protection to fix thisproblem and avoid similiar problems.Signed-off-by: Boqun Feng <boqun.feng@gmail.com>Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>Link:https://lkml.kernel.org/r/20201113110512.1056501-1-boqun.feng@gmail.com
1 parentd61fc96 commit43be438

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎kernel/locking/lockdep.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,21 @@ static inline void lockdep_lock(void)
108108
{
109109
DEBUG_LOCKS_WARN_ON(!irqs_disabled());
110110

111+
__this_cpu_inc(lockdep_recursion);
111112
arch_spin_lock(&__lock);
112113
__owner=current;
113-
__this_cpu_inc(lockdep_recursion);
114114
}
115115

116116
staticinlinevoidlockdep_unlock(void)
117117
{
118+
DEBUG_LOCKS_WARN_ON(!irqs_disabled());
119+
118120
if (debug_locks&&DEBUG_LOCKS_WARN_ON(__owner!=current))
119121
return;
120122

121-
__this_cpu_dec(lockdep_recursion);
122123
__owner=NULL;
123124
arch_spin_unlock(&__lock);
125+
__this_cpu_dec(lockdep_recursion);
124126
}
125127

126128
staticinlineboollockdep_assert_locked(void)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp