]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
locking/rwlock: Fix write_trylock_irqsave() with CONFIG_INLINE_WRITE_TRYLOCK
authorMarco Elver <elver@google.com>
Tue, 3 Feb 2026 22:50:10 +0000 (23:50 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 5 Feb 2026 08:43:48 +0000 (09:43 +0100)
Move _raw_write_trylock_irqsave() after the _raw_write_trylock macro to
ensure it uses the inlined version, fixing a linker error when inlining
is enabled. This is the case on s390:

>> ld.lld: error: undefined symbol: _raw_write_trylock
   >>> referenced by rwlock_api_smp.h:48 (include/linux/rwlock_api_smp.h:48)
   >>>               lib/test_context-analysis.o:(test_write_trylock_extra) in archive vmlinux.a
   >>> referenced by rwlock_api_smp.h:48 (include/linux/rwlock_api_smp.h:48)
   >>>               lib/test_context-analysis.o:(test_write_trylock_extra) in archive vmlinux.a

Closes: https://lore.kernel.org/oe-kbuild-all/202602032101.dbxRfsWO-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20260203225114.3493538-1-elver@google.com
include/linux/rwlock_api_smp.h

index d903b17c46ca64f3303db356d762cd608b96d3ad..61a852609eab4f4165154c30e404d13dd8e86157 100644 (file)
@@ -41,16 +41,6 @@ void __lockfunc
 _raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
                                                        __releases(lock);
 
-static inline bool _raw_write_trylock_irqsave(rwlock_t *lock, unsigned long *flags)
-       __cond_acquires(true, lock)
-{
-       local_irq_save(*flags);
-       if (_raw_write_trylock(lock))
-               return true;
-       local_irq_restore(*flags);
-       return false;
-}
-
 #ifdef CONFIG_INLINE_READ_LOCK
 #define _raw_read_lock(lock) __raw_read_lock(lock)
 #endif
@@ -147,6 +137,16 @@ static inline int __raw_write_trylock(rwlock_t *lock)
        return 0;
 }
 
+static inline bool _raw_write_trylock_irqsave(rwlock_t *lock, unsigned long *flags)
+       __cond_acquires(true, lock) __no_context_analysis
+{
+       local_irq_save(*flags);
+       if (_raw_write_trylock(lock))
+               return true;
+       local_irq_restore(*flags);
+       return false;
+}
+
 /*
  * If lockdep is enabled then we use the non-preemption spin-ops
  * even on CONFIG_PREEMPT, because lockdep assumes that interrupts are