Re: [PATCH] Locking: Let PREEMPT_RT compile again with new rwsem asserts.
From: Matthew Wilcox
Date: Tue Mar 19 2024 - 09:38:19 EST
On Tue, Mar 19, 2024 at 08:05:50AM +0100, Sebastian Andrzej Siewior wrote:
> -static inline void rwsem_assert_held_write_nolockdep(const struct rw_semaphore *sem)
> +static __always_inline bool rwsem_held_write(const struct rw_semaphore *sem)
The locking maintainers were very clear that this predicate Should Not
Exist. It encourages people to write bad code. Assertions only!
> {
> - rw_base_assert_held_write(sem);
> + return rw_base_is_write_locked(&sem->rwbase);
> +}
> +
> +static __always_inline void rwsem_assert_held_write_nolockdep(const struct rw_semaphore *sem)
> +{
> + WARN_ON(!rwsem_held_write(sem));
> }
>
> static __always_inline int rwsem_is_contended(struct rw_semaphore *sem)
> --
> 2.43.0
>