Commit 8838a1a2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'locking-core-2025-01-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull locking updates from Ingo Molnar:
 "Lockdep:

   - Improve and fix lockdep bitsize limits, clarify the Kconfig
     documentation (Carlos Llamas)

   - Fix lockdep build warning on Clang related to
     chain_hlock_class_idx() inlining (Andy Shevchenko)

   - Relax the requirements of PROVE_RAW_LOCK_NESTING arch support by
     not tying it to ARCH_SUPPORTS_RT unnecessarily (Waiman Long)

  Rust integration:

   - Support lock pointers managed by the C side (Lyude Paul)

   - Support guard types (Lyude Paul)

   - Update MAINTAINERS file filters to include the Rust locking code
     (Boqun Feng)

  Wake-queues:

   - Add raw_spin_*wake() helpers to simplify locking code (John Stultz)

  SMP cross-calls:

   - Fix potential data update race by evaluating the local cond_func()
     before IPI side-effects (Mathieu Desnoyers)

  Guard primitives:

   - Ease [c]tags based searches by including the cleanup/guard type
     primitives (Peter Zijlstra)

  ww_mutexes:

   - Simplify the ww_mutex self-test code via swap() (Thorsten Blum)

  Static calls:

   - Update the static calls MAINTAINERS file-pattern (Jiri Slaby)"

* tag 'locking-core-2025-01-20' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  MAINTAINERS: Add static_call_inline.c to STATIC BRANCH/CALL
  cleanup, tags: Create tags for the cleanup primitives
  sched/wake_q: Add helper to call wake_up_q after unlock with preemption disabled
  rust: sync: Add lock::Backend::assert_is_held()
  rust: sync: Add SpinLockGuard type alias
  rust: sync: Add MutexGuard type alias
  rust: sync: Make Guard::new() public
  rust: sync: Add Lock::from_raw() for Lock<(), B>
  locking: MAINTAINERS: Start watching Rust locking primitives
  lockdep: Move lockdep_assert_locked() under #ifdef CONFIG_PROVE_LOCKING
  lockdep: Mark chain_hlock_class_idx() with __maybe_unused
  lockdep: Document MAX_LOCKDEP_CHAIN_HLOCKS calculation
  lockdep: Clarify size for LOCKDEP_*_BITS configs
  lockdep: Fix upper limit for LOCKDEP_*_BITS configs
  locking/ww_mutex/test: Use swap() macro
  smp/scf: Evaluate local cond_func() before IPI side-effects
  locking/lockdep: Enforce PROVE_RAW_LOCK_NESTING only if ARCH_SUPPORTS_RT
parents b9d8a295 cb4ccc70
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -13439,8 +13439,8 @@ LOCKING PRIMITIVES
M:	Peter Zijlstra <peterz@infradead.org>
M:	Ingo Molnar <mingo@redhat.com>
M:	Will Deacon <will@kernel.org>
M:	Boqun Feng <boqun.feng@gmail.com> (LOCKDEP & RUST)
R:	Waiman Long <longman@redhat.com>
R:	Boqun Feng <boqun.feng@gmail.com> (LOCKDEP)
L:	linux-kernel@vger.kernel.org
S:	Maintained
T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/core
@@ -13454,6 +13454,11 @@ F: include/linux/seqlock.h
F:	include/linux/spinlock*.h
F:	kernel/locking/
F:	lib/locking*.[ch]
F:	rust/helpers/mutex.c
F:	rust/helpers/spinlock.c
F:	rust/kernel/sync/lock.rs
F:	rust/kernel/sync/lock/
F:	rust/kernel/sync/locked_by.rs
X:	kernel/locking/locktorture.c
LOGICAL DISK MANAGER SUPPORT (LDM, Windows 2000/XP/Vista Dynamic Disks)
@@ -22467,7 +22472,7 @@ F: arch/*/kernel/static_call.c
F:	include/linux/jump_label*.h
F:	include/linux/static_call*.h
F:	kernel/jump_label.c
F:	kernel/static_call.c
F:	kernel/static_call*.c
STI AUDIO (ASoC) DRIVERS
M:	Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
+34 −0
Original line number Diff line number Diff line
@@ -63,4 +63,38 @@ extern void wake_q_add(struct wake_q_head *head, struct task_struct *task);
extern void wake_q_add_safe(struct wake_q_head *head, struct task_struct *task);
extern void wake_up_q(struct wake_q_head *head);

/* Spin unlock helpers to unlock and call wake_up_q with preempt disabled */
static inline
void raw_spin_unlock_wake(raw_spinlock_t *lock, struct wake_q_head *wake_q)
{
	guard(preempt)();
	raw_spin_unlock(lock);
	if (wake_q) {
		wake_up_q(wake_q);
		wake_q_init(wake_q);
	}
}

static inline
void raw_spin_unlock_irq_wake(raw_spinlock_t *lock, struct wake_q_head *wake_q)
{
	guard(preempt)();
	raw_spin_unlock_irq(lock);
	if (wake_q) {
		wake_up_q(wake_q);
		wake_q_init(wake_q);
	}
}

static inline
void raw_spin_unlock_irqrestore_wake(raw_spinlock_t *lock, unsigned long flags,
				     struct wake_q_head *wake_q)
{
	guard(preempt)();
	raw_spin_unlock_irqrestore(lock, flags);
	if (wake_q) {
		wake_up_q(wake_q);
		wake_q_init(wake_q);
	}
}
#endif /* _LINUX_SCHED_WAKE_Q_H */
+1 −4
Original line number Diff line number Diff line
@@ -1020,10 +1020,7 @@ int futex_lock_pi(u32 __user *uaddr, unsigned int flags, ktime_t *time, int tryl
	 * it sees the futex_q::pi_state.
	 */
	ret = __rt_mutex_start_proxy_lock(&q.pi_state->pi_mutex, &rt_waiter, current, &wake_q);
	preempt_disable();
	raw_spin_unlock_irq(&q.pi_state->pi_mutex.wait_lock);
	wake_up_q(&wake_q);
	preempt_enable();
	raw_spin_unlock_irq_wake(&q.pi_state->pi_mutex.wait_lock, &wake_q);

	if (ret) {
		if (ret == 1)
+3 −1
Original line number Diff line number Diff line
@@ -157,10 +157,12 @@ static inline void lockdep_unlock(void)
	__this_cpu_dec(lockdep_recursion);
}

#ifdef CONFIG_PROVE_LOCKING
static inline bool lockdep_assert_locked(void)
{
	return DEBUG_LOCKS_WARN_ON(__owner != current);
}
#endif

static struct task_struct *lockdep_selftest_task_struct;

@@ -430,7 +432,7 @@ static inline u16 hlock_id(struct held_lock *hlock)
	return (hlock->class_idx | (hlock->read << MAX_LOCKDEP_KEYS_BITS));
}

static inline unsigned int chain_hlock_class_idx(u16 hlock_id)
static inline __maybe_unused unsigned int chain_hlock_class_idx(u16 hlock_id)
{
	return hlock_id & (MAX_LOCKDEP_KEYS - 1);
}
+2 −1
Original line number Diff line number Diff line
@@ -119,7 +119,8 @@ static const unsigned long LOCKF_USED_IN_IRQ_READ =

#define MAX_LOCKDEP_CHAINS	(1UL << MAX_LOCKDEP_CHAINS_BITS)

#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS*5)
#define AVG_LOCKDEP_CHAIN_DEPTH		5
#define MAX_LOCKDEP_CHAIN_HLOCKS (MAX_LOCKDEP_CHAINS * AVG_LOCKDEP_CHAIN_DEPTH)

extern struct lock_chain lock_chains[];

Loading