Re: [PATCH v2 1/5] locking: Add rwsem_assert_held() and rwsem_assert_held_write()

From: Dave Chinner
Date: Sun Oct 08 2023 - 17:54:37 EST


On Sat, Oct 07, 2023 at 09:35:39PM +0100, Matthew Wilcox (Oracle) wrote:
> Modelled after lockdep_assert_held() and lockdep_assert_held_write(),
> but are always active, even when lockdep is disabled. Of course, they
> don't test that _this_ thread is the owner, but it's sufficient to catch
> many bugs and doesn't incur the same performance penalty as lockdep.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
.....
> @@ -169,6 +189,18 @@ static __always_inline int rwsem_is_contended(struct rw_semaphore *sem)
> * the RT specific variant.
> */
>
> +static inline void rwsem_assert_held(const struct rw_semaphore *sem)
> +{
> + lockdep_assert_held(sem);
> + __rwsem_assert_held(sem);
> +}

if (IS_ENABLED(CONFIG_LOCKDEP))
lockdep_assert_held(sem);
else
__rwsem_assert_held(sem);

-Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx