Commit 72b8944f authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

Pull locking updates from Ingo Molnar:
 "Locking primitives:

   - Mark devm_mutex_init() as __must_check and fix drivers that didn't
     check the return code (Thomas Weißschuh)

   - Reorganize <linux/local_lock.h> to better expose the internal APIs
     to local variables (Sebastian Andrzej Siewior)

   - Remove OWNER_SPINNABLE in rwsem (Jinliang Zheng)

   - Remove redundant #ifdefs in the mutex code (Ran Xiaokai)

  Lockdep:

   - Avoid returning struct in lock_stats() (Arnd Bergmann)

   - Change `static const` into enum for LOCKF_*_IRQ_* (Arnd Bergmann)

   - Temporarily use synchronize_rcu_expedited() in
     lockdep_unregister_key() to speed things up. (Breno Leitao)

  Rust runtime:

   - Add #[must_use] to Lock::try_lock() (Jason Devers)"

* tag 'locking-core-2025-07-29' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  lockdep: Speed up lockdep_unregister_key() with expedited RCU synchronization
  locking/mutex: Remove redundant #ifdefs
  locking/lockdep: Change 'static const' variables to enum values
  locking/lockdep: Avoid struct return in lock_stats()
  locking/rwsem: Use OWNER_NONSPINNABLE directly instead of OWNER_SPINNABLE
  rust: sync: Add #[must_use] to Lock::try_lock()
  locking/mutex: Mark devm_mutex_init() as __must_check
  leds: lp8860: Check return value of devm_mutex_init()
  spi: spi-nxp-fspi: Check return value of devm_mutex_init()
  local_lock: Move this_cpu_ptr() notation from internal to main header
parents bcb48dd3 ba28549b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -307,7 +307,9 @@ static int lp8860_probe(struct i2c_client *client)
	led->client = client;
	led->led_dev.brightness_set_blocking = lp8860_brightness_set;

	devm_mutex_init(&client->dev, &led->lock);
	ret = devm_mutex_init(&client->dev, &led->lock);
	if (ret)
		return dev_err_probe(&client->dev, ret, "Failed to initialize lock\n");

	led->regmap = devm_regmap_init_i2c(client, &lp8860_regmap_config);
	if (IS_ERR(led->regmap)) {
+3 −1
Original line number Diff line number Diff line
@@ -1272,7 +1272,9 @@ static int nxp_fspi_probe(struct platform_device *pdev)
	if (ret)
		return dev_err_probe(dev, ret, "Failed to request irq\n");

	devm_mutex_init(dev, &f->lock);
	ret = devm_mutex_init(dev, &f->lock);
	if (ret)
		return dev_err_probe(dev, ret, "Failed to initialize lock\n");

	ctlr->bus_num = -1;
	ctlr->num_chipselect = NXP_FSPI_MAX_CHIPSELECT;
+10 −10
Original line number Diff line number Diff line
@@ -13,13 +13,13 @@
 * local_lock - Acquire a per CPU local lock
 * @lock:	The lock variable
 */
#define local_lock(lock)		__local_lock(lock)
#define local_lock(lock)		__local_lock(this_cpu_ptr(lock))

/**
 * local_lock_irq - Acquire a per CPU local lock and disable interrupts
 * @lock:	The lock variable
 */
#define local_lock_irq(lock)		__local_lock_irq(lock)
#define local_lock_irq(lock)		__local_lock_irq(this_cpu_ptr(lock))

/**
 * local_lock_irqsave - Acquire a per CPU local lock, save and disable
@@ -28,19 +28,19 @@
 * @flags:	Storage for interrupt flags
 */
#define local_lock_irqsave(lock, flags)				\
	__local_lock_irqsave(lock, flags)
	__local_lock_irqsave(this_cpu_ptr(lock), flags)

/**
 * local_unlock - Release a per CPU local lock
 * @lock:	The lock variable
 */
#define local_unlock(lock)		__local_unlock(lock)
#define local_unlock(lock)		__local_unlock(this_cpu_ptr(lock))

/**
 * local_unlock_irq - Release a per CPU local lock and enable interrupts
 * @lock:	The lock variable
 */
#define local_unlock_irq(lock)		__local_unlock_irq(lock)
#define local_unlock_irq(lock)		__local_unlock_irq(this_cpu_ptr(lock))

/**
 * local_unlock_irqrestore - Release a per CPU local lock and restore
@@ -49,7 +49,7 @@
 * @flags:      Interrupt flags to restore
 */
#define local_unlock_irqrestore(lock, flags)			\
	__local_unlock_irqrestore(lock, flags)
	__local_unlock_irqrestore(this_cpu_ptr(lock), flags)

/**
 * local_lock_init - Runtime initialize a lock instance
@@ -64,7 +64,7 @@
 * locking constrains it will _always_ fail to acquire the lock in NMI or
 * HARDIRQ context on PREEMPT_RT.
 */
#define local_trylock(lock)		__local_trylock(lock)
#define local_trylock(lock)		__local_trylock(this_cpu_ptr(lock))

/**
 * local_trylock_irqsave - Try to acquire a per CPU local lock, save and disable
@@ -77,7 +77,7 @@
 * HARDIRQ context on PREEMPT_RT.
 */
#define local_trylock_irqsave(lock, flags)			\
	__local_trylock_irqsave(lock, flags)
	__local_trylock_irqsave(this_cpu_ptr(lock), flags)

DEFINE_GUARD(local_lock, local_lock_t __percpu*,
	     local_lock(_T),
@@ -91,10 +91,10 @@ DEFINE_LOCK_GUARD_1(local_lock_irqsave, local_lock_t __percpu,
		    unsigned long flags)

#define local_lock_nested_bh(_lock)				\
	__local_lock_nested_bh(_lock)
	__local_lock_nested_bh(this_cpu_ptr(_lock))

#define local_unlock_nested_bh(_lock)				\
	__local_unlock_nested_bh(_lock)
	__local_unlock_nested_bh(this_cpu_ptr(_lock))

DEFINE_GUARD(local_lock_nested_bh, local_lock_t __percpu*,
	     local_lock_nested_bh(_T),
+15 −15
Original line number Diff line number Diff line
@@ -99,14 +99,14 @@ do { \
		local_trylock_t *tl;					\
		local_lock_t *l;					\
									\
		l = (local_lock_t *)this_cpu_ptr(lock);			\
		l = (local_lock_t *)(lock);				\
		tl = (local_trylock_t *)l;				\
		_Generic((lock),					\
			__percpu local_trylock_t *: ({			\
			local_trylock_t *: ({				\
				lockdep_assert(tl->acquired == 0);	\
				WRITE_ONCE(tl->acquired, 1);		\
			}),						\
			__percpu local_lock_t *: (void)0);		\
			local_lock_t *: (void)0);			\
		local_lock_acquire(l);					\
	} while (0)

@@ -133,7 +133,7 @@ do { \
		local_trylock_t *tl;				\
								\
		preempt_disable();				\
		tl = this_cpu_ptr(lock);			\
		tl = (lock);					\
		if (READ_ONCE(tl->acquired)) {			\
			preempt_enable();			\
			tl = NULL;				\
@@ -150,7 +150,7 @@ do { \
		local_trylock_t *tl;				\
								\
		local_irq_save(flags);				\
		tl = this_cpu_ptr(lock);			\
		tl = (lock);					\
		if (READ_ONCE(tl->acquired)) {			\
			local_irq_restore(flags);		\
			tl = NULL;				\
@@ -167,15 +167,15 @@ do { \
		local_trylock_t *tl;					\
		local_lock_t *l;					\
									\
		l = (local_lock_t *)this_cpu_ptr(lock);			\
		l = (local_lock_t *)(lock);				\
		tl = (local_trylock_t *)l;				\
		local_lock_release(l);					\
		_Generic((lock),					\
			__percpu local_trylock_t *: ({			\
			local_trylock_t *: ({				\
				lockdep_assert(tl->acquired == 1);	\
				WRITE_ONCE(tl->acquired, 0);		\
			}),						\
			__percpu local_lock_t *: (void)0);		\
			local_lock_t *: (void)0);			\
	} while (0)

#define __local_unlock(lock)					\
@@ -199,11 +199,11 @@ do { \
#define __local_lock_nested_bh(lock)				\
	do {							\
		lockdep_assert_in_softirq();			\
		local_lock_acquire(this_cpu_ptr(lock));	\
		local_lock_acquire((lock));			\
	} while (0)

#define __local_unlock_nested_bh(lock)				\
	local_lock_release(this_cpu_ptr(lock))
	local_lock_release((lock))

#else /* !CONFIG_PREEMPT_RT */

@@ -227,7 +227,7 @@ typedef spinlock_t local_trylock_t;
#define __local_lock(__lock)					\
	do {							\
		migrate_disable();				\
		spin_lock(this_cpu_ptr((__lock)));		\
		spin_lock((__lock));				\
	} while (0)

#define __local_lock_irq(lock)			__local_lock(lock)
@@ -241,7 +241,7 @@ typedef spinlock_t local_trylock_t;

#define __local_unlock(__lock)					\
	do {							\
		spin_unlock(this_cpu_ptr((__lock)));		\
		spin_unlock((__lock));				\
		migrate_enable();				\
	} while (0)

@@ -252,12 +252,12 @@ typedef spinlock_t local_trylock_t;
#define __local_lock_nested_bh(lock)				\
do {								\
	lockdep_assert_in_softirq_func();			\
	spin_lock(this_cpu_ptr(lock));				\
	spin_lock((lock));					\
} while (0)

#define __local_unlock_nested_bh(lock)				\
do {								\
	spin_unlock(this_cpu_ptr((lock)));			\
	spin_unlock((lock));					\
} while (0)

#define __local_trylock(lock)					\
@@ -268,7 +268,7 @@ do { \
			__locked = 0;				\
		} else {					\
			migrate_disable();			\
			__locked = spin_trylock(this_cpu_ptr((lock)));	\
			__locked = spin_trylock((lock));	\
			if (!__locked)				\
				migrate_enable();		\
		}						\
+1 −1
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ struct lock_class_stats {
	unsigned long			bounces[nr_bounce_types];
};

struct lock_class_stats lock_stats(struct lock_class *class);
void lock_stats(struct lock_class *class, struct lock_class_stats *stats);
void clear_lock_stats(struct lock_class *class);
#endif

Loading