mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
5c2e7736e2
When PREEMPT_RT=y, spin locks are mapped to rt_mutex types, so using
spinlock_check() + __raw_spin_lock_init() to initialize spin locks is
incorrect, and would cause build errors.
Introduce __spin_lock_init() to initialize a spin lock with lockdep
rquired information for PREEMPT_RT builds, and use it in the Rust
helper.
Fixes: d2d6422f8b
("x86: Allow to enable PREEMPT_RT.")
Closes: https://lore.kernel.org/oe-kbuild-all/202409251238.vetlgXE9-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Eder Zulian <ezulian@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Tested-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20241107163223.2092690-2-ezulian@redhat.com
29 lines
672 B
C
29 lines
672 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <linux/export.h>
|
|
#include <linux/spinlock.h>
|
|
|
|
void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
|
|
struct lock_class_key *key)
|
|
{
|
|
#ifdef CONFIG_DEBUG_SPINLOCK
|
|
# if defined(CONFIG_PREEMPT_RT)
|
|
__spin_lock_init(lock, name, key, false);
|
|
# else /*!CONFIG_PREEMPT_RT */
|
|
__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
|
|
# endif /* CONFIG_PREEMPT_RT */
|
|
#else /* !CONFIG_DEBUG_SPINLOCK */
|
|
spin_lock_init(lock);
|
|
#endif /* CONFIG_DEBUG_SPINLOCK */
|
|
}
|
|
|
|
void rust_helper_spin_lock(spinlock_t *lock)
|
|
{
|
|
spin_lock(lock);
|
|
}
|
|
|
|
void rust_helper_spin_unlock(spinlock_t *lock)
|
|
{
|
|
spin_unlock(lock);
|
|
}
|