Skip to content

Commit 7a562d5

Browse files
melverPeter Zijlstra
authored andcommitted
locking/rwlock: Fix write_trylock_irqsave() with CONFIG_INLINE_WRITE_TRYLOCK
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
1 parent 451c3a0 commit 7a562d5

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

include/linux/rwlock_api_smp.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ void __lockfunc
4141
_raw_write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
4242
__releases(lock);
4343

44-
static inline bool _raw_write_trylock_irqsave(rwlock_t *lock, unsigned long *flags)
45-
__cond_acquires(true, lock)
46-
{
47-
local_irq_save(*flags);
48-
if (_raw_write_trylock(lock))
49-
return true;
50-
local_irq_restore(*flags);
51-
return false;
52-
}
53-
5444
#ifdef CONFIG_INLINE_READ_LOCK
5545
#define _raw_read_lock(lock) __raw_read_lock(lock)
5646
#endif
@@ -147,6 +137,16 @@ static inline int __raw_write_trylock(rwlock_t *lock)
147137
return 0;
148138
}
149139

140+
static inline bool _raw_write_trylock_irqsave(rwlock_t *lock, unsigned long *flags)
141+
__cond_acquires(true, lock) __no_context_analysis
142+
{
143+
local_irq_save(*flags);
144+
if (_raw_write_trylock(lock))
145+
return true;
146+
local_irq_restore(*flags);
147+
return false;
148+
}
149+
150150
/*
151151
* If lockdep is enabled then we use the non-preemption spin-ops
152152
* even on CONFIG_PREEMPT, because lockdep assumes that interrupts are

0 commit comments

Comments
 (0)