Skip to contentSkip to conversation

spinlock: Fix failing build for PREEMPT_RT

PATCH Applied Leonardo Bras 2 participants 3 messages Jan 15, 2024 – Jan 16, 2024 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spinlock: Fix failing build for PREEMPT_RT

Since 1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to spinlock.h") build fails for PREEMPT_RT, since there is no definition available of either spin_needbreak() and rwlock_needbreak().

Since it was moved on the mentioned commit, it was placed inside a !PREEMPT_RT part of the code, making it out of reach for an RT kernel.

Fix this by moving code it a few lines down so it can be reached by an RT build, where it can also make use of the *_is_contended() definition added by the spinlock_rt.h.

Fixes d1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to

spinlock.h")

---
 include/linux/spinlock.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/spinlock.h +6 -6
index eaac8b0da25b8..3fcd20de6ca88 100644
@@ -449,6 +449,12 @@ static __always_inline int spin_is_contended(spinlock_t *lock)
 	return raw_spin_is_contended(&lock->rlock);
 }
 
+#define assert_spin_locked(lock)	assert_raw_spin_locked(&(lock)->rlock)
+
+#else  /* !CONFIG_PREEMPT_RT */
+# include <linux/spinlock_rt.h>
+#endif /* CONFIG_PREEMPT_RT */
+
 /*
  * Does a critical section need to be broken due to another
  * task waiting?: (technically does not depend on CONFIG_PREEMPTION,
@@ -480,12 +486,6 @@ static inline int rwlock_needbreak(rwlock_t *lock)
 #endif
 }
 
-#define assert_spin_locked(lock)	assert_raw_spin_locked(&(lock)->rlock)
-
-#else  /* !CONFIG_PREEMPT_RT */
-# include <linux/spinlock_rt.h>
-#endif /* CONFIG_PREEMPT_RT */
-
 /*
  * Pull the atomic_t declaration:
  * (asm-mips/atomic.h needs above definitions)
Signature · 1 line
2.43.0
#1 lore raw
Quoted 7 lines · Leonardo Bras

Since 1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to spinlock.h") build fails for PREEMPT_RT, since there is no definition available of either spin_needbreak() and rwlock_needbreak().

Since it was moved on the mentioned commit, it was placed inside a !PREEMPT_RT part of the code, making it out of reach for an RT kernel.

Quoted 7 lines

Fix this by moving code it a few lines down so it can be reached by an RT build, where it can also make use of the *_is_contended() definition added by the spinlock_rt.h.

Fixes d1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to

spinlock.h")

I've picked this up - thanks!

#2 lore raw
Quoted 12 lines · Kent Overstreet
Quoted 11 lines · Leonardo Bras

Since 1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to spinlock.h") build fails for PREEMPT_RT, since there is no definition available of either spin_needbreak() and rwlock_needbreak().

Since it was moved on the mentioned commit, it was placed inside a !PREEMPT_RT part of the code, making it out of reach for an RT kernel.

Fix this by moving code it a few lines down so it can be reached by an RT build, where it can also make use of the *_is_contended() definition added by the spinlock_rt.h.

Quoted 6 lines
Quoted 3 lines
Fixes d1d71b30e1f85 ("sched.h: Move (spin|rwlock)_needbreak() to

spinlock.h")

I've picked this up - thanks!

Awesome! Thanks!

Leo