History

Merge tag 'locking-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking fixes from Thomas Gleixner: "A couple of locking fixes: - Fix incorrect failure injection handling in the fuxtex code - Prevent a preemption warning in lockdep when tracking local_irq_enable() and interrupts are already enabled - Remove more raw_cpu_read() usage from lockdep which causes state corruption on !X86 architectures. - Make the nr_unused_locks accounting in lockdep correct again" * tag 'locking-urgent-2020-11-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: lockdep: Fix nr_unused_locks accounting locking/lockdep: Remove more raw_cpu_read() usage futex: Fix incorrect should_fail_futex() handling lockdep: Fix preemption WARN for spurious IRQ-enable

Linus Torvalds committed 6 years ago

Commit 8d990842 parents 31f0200 1a393402 files · +10 −14Browse files

Unified · Split

2 files
  1. kernel/futex.c +3 −1
  2. kernel/locking/lockdep.c +7 −13
kernel/futex.c+3−1
@@ -1503,8 +1503,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ · 1502 unmodified lines
15031503 */
15041504 newval = FUTEX_WAITERS | task_pid_vnr(new_owner);
15051505
1506− if (unlikely(should_fail_futex(true)))
1506+ if (unlikely(should_fail_futex(true))) {
15071507 ret = -EFAULT;
1508+ goto out_unlock;
1509+ }
15081510
15091511 ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval);
15101512 if (!ret && (curval != uval)) {
kernel/locking/lockdep.c+7−13
@@ -84,7 +84,7 @@ static inline bool lockdep_enabled(void) · 83 unmodified lines
8484 if (!debug_locks)
8585 return false;
8686
87− if (raw_cpu_read(lockdep_recursion))
87+ if (this_cpu_read(lockdep_recursion))
8888 return false;
8989
9090 if (current->lockdep_recursion)
@@ -4057,7 +4057,7 @@ void lockdep_hardirqs_on_prepare(unsigned long ip) · 3966 unmodified lines
40574057 if (unlikely(in_nmi()))
40584058 return;
40594059
4060− if (unlikely(__this_cpu_read(lockdep_recursion)))
4060+ if (unlikely(this_cpu_read(lockdep_recursion)))
40614061 return;
40624062
40634063 if (unlikely(lockdep_hardirqs_enabled())) {
@@ -4126,7 +4126,7 @@ void noinstr lockdep_hardirqs_on(unsigned long ip) · 62 unmodified lines
41264126 goto skip_checks;
41274127 }
41284128
4129− if (unlikely(__this_cpu_read(lockdep_recursion)))
4129+ if (unlikely(this_cpu_read(lockdep_recursion)))
41304130 return;
41314131
41324132 if (lockdep_hardirqs_enabled()) {
@@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, · 263 unmodified lines
43964396 if (unlikely(hlock_class(this)->usage_mask & new_mask))
43974397 goto unlock;
43984398
4399+ if (!hlock_class(this)->usage_mask)
4400+ debug_atomic_dec(nr_unused_locks);
4401+
43994402 hlock_class(this)->usage_mask |= new_mask;
44004403
44014404 if (new_bit < LOCK_TRACE_STATES) {
@@ -4403,19 +4406,10 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, · 1 unmodified line
44034406 return 0;
44044407 }
44054408
4406− switch (new_bit) {
4407− case 0 ... LOCK_USED-1:
4409+ if (new_bit < LOCK_USED) {
44084410 ret = mark_lock_irq(curr, this, new_bit);
44094411 if (!ret)
44104412 return 0;
4411− break;
4412−
4413− case LOCK_USED:
4414− debug_atomic_dec(nr_unused_locks);
4415− break;
4416−
4417− default:
4418− break;
44194413 }
44204414
44214415 unlock: