diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2024-02-19 15:41:11 +0000 |
---|---|---|
committer | Chandan Babu R <chandanbabu@kernel.org> | 2024-02-19 21:19:33 +0530 |
commit | f70405afc99b1e5a3a1e60b6c05456fde2dbe622 (patch) | |
tree | 3d76b8b2cc4ffaffc0dafe89e94547971684af68 /include/linux/rwbase_rt.h | |
parent | 49c379d3a72ab86aafeafebe6b43577acb1ef359 (diff) |
locking: Add rwsem_assert_held() and rwsem_assert_held_write()
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.
Acked-by: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Acked-by: Waiman Long <longman@redhat.com>
Acked-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Diffstat (limited to 'include/linux/rwbase_rt.h')
-rw-r--r-- | include/linux/rwbase_rt.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/linux/rwbase_rt.h b/include/linux/rwbase_rt.h index 1d264dd08625..29c4e4f243e4 100644 --- a/include/linux/rwbase_rt.h +++ b/include/linux/rwbase_rt.h @@ -26,12 +26,17 @@ struct rwbase_rt { } while (0) -static __always_inline bool rw_base_is_locked(struct rwbase_rt *rwb) +static __always_inline bool rw_base_is_locked(const struct rwbase_rt *rwb) { return atomic_read(&rwb->readers) != READER_BIAS; } -static __always_inline bool rw_base_is_contended(struct rwbase_rt *rwb) +static inline void rw_base_assert_held_write(const struct rwbase_rt *rwb) +{ + WARN_ON(atomic_read(&rwb->readers) != WRITER_BIAS); +} + +static __always_inline bool rw_base_is_contended(const struct rwbase_rt *rwb) { return atomic_read(&rwb->readers) > 0; } |