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
Unified · Split
| @@ -1503,8 +1503,10 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ · 1502 unmodified lines | ||
| 1503 | 1503 | */ |
| 1504 | 1504 | newval = FUTEX_WAITERS | task_pid_vnr(new_owner); |
| 1505 | 1505 | |
| 1506 | − if (unlikely(should_fail_futex(true))) | |
| 1506 | + if (unlikely(should_fail_futex(true))) { | |
| 1507 | 1507 | ret = -EFAULT; |
| 1508 | + goto out_unlock; | |
| 1509 | + } | |
| 1508 | 1510 | |
| 1509 | 1511 | ret = cmpxchg_futex_value_locked(&curval, uaddr, uval, newval); |
| 1510 | 1512 | if (!ret && (curval != uval)) { |
| @@ -84,7 +84,7 @@ static inline bool lockdep_enabled(void) · 83 unmodified lines | ||
| 84 | 84 | if (!debug_locks) |
| 85 | 85 | return false; |
| 86 | 86 | |
| 87 | − if (raw_cpu_read(lockdep_recursion)) | |
| 87 | + if (this_cpu_read(lockdep_recursion)) | |
| 88 | 88 | return false; |
| 89 | 89 | |
| 90 | 90 | if (current->lockdep_recursion) |
| @@ -4057,7 +4057,7 @@ void lockdep_hardirqs_on_prepare(unsigned long ip) · 3966 unmodified lines | ||
| 4057 | 4057 | if (unlikely(in_nmi())) |
| 4058 | 4058 | return; |
| 4059 | 4059 | |
| 4060 | − if (unlikely(__this_cpu_read(lockdep_recursion))) | |
| 4060 | + if (unlikely(this_cpu_read(lockdep_recursion))) | |
| 4061 | 4061 | return; |
| 4062 | 4062 | |
| 4063 | 4063 | if (unlikely(lockdep_hardirqs_enabled())) { |
| @@ -4126,7 +4126,7 @@ void noinstr lockdep_hardirqs_on(unsigned long ip) · 62 unmodified lines | ||
| 4126 | 4126 | goto skip_checks; |
| 4127 | 4127 | } |
| 4128 | 4128 | |
| 4129 | − if (unlikely(__this_cpu_read(lockdep_recursion))) | |
| 4129 | + if (unlikely(this_cpu_read(lockdep_recursion))) | |
| 4130 | 4130 | return; |
| 4131 | 4131 | |
| 4132 | 4132 | if (lockdep_hardirqs_enabled()) { |
| @@ -4396,6 +4396,9 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this, · 263 unmodified lines | ||
| 4396 | 4396 | if (unlikely(hlock_class(this)->usage_mask & new_mask)) |
| 4397 | 4397 | goto unlock; |
| 4398 | 4398 | |
| 4399 | + if (!hlock_class(this)->usage_mask) | |
| 4400 | + debug_atomic_dec(nr_unused_locks); | |
| 4401 | + | |
| 4399 | 4402 | hlock_class(this)->usage_mask |= new_mask; |
| 4400 | 4403 | |
| 4401 | 4404 | 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 | ||
| 4403 | 4406 | return 0; |
| 4404 | 4407 | } |
| 4405 | 4408 | |
| 4406 | − switch (new_bit) { | |
| 4407 | − case 0 ... LOCK_USED-1: | |
| 4409 | + if (new_bit < LOCK_USED) { | |
| 4408 | 4410 | ret = mark_lock_irq(curr, this, new_bit); |
| 4409 | 4411 | if (!ret) |
| 4410 | 4412 | return 0; |
| 4411 | − break; | |
| 4412 | − | |
| 4413 | − case LOCK_USED: | |
| 4414 | − debug_atomic_dec(nr_unused_locks); | |
| 4415 | − break; | |
| 4416 | − | |
| 4417 | − default: | |
| 4418 | − break; | |
| 4419 | 4413 | } |
| 4420 | 4414 | |
| 4421 | 4415 | unlock: |