Skip to contentSkip to conversation

rt: add rwsem_is_contended() definition to rwsem_rt.h

PATCH In review Clark Williams 2 participants 3 messages Aug 27, 2014 – Feb 17, 2015 Locking primitives

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt: add rwsem_is_contended() definition to rwsem_rt.h

Thomas,

The latest btrfs code uses rwsem_is_contended() in the function caching_thread(). On RT systems, include/linux/rwsem.h is replaced with include/linux/rwsem_rt.h which does not provide a definition for rwsem_is_contended(). This commit provides a definition that should work on RT (where the lock is actually an rt_mutex).

---
 include/linux/rwsem_rt.h | 5 +++++
 1 file changed, 5 insertions(+)
include/linux/rwsem_rt.h +5 -0
index e94d945c5844..77035d7abc04 100644
@@ -125,4 +125,9 @@ static inline void down_write_nest_lock(struct rw_semaphore *sem,
        rt_down_write_nested_lock(sem, NULL);
 }
 #endif
+
+static inline int rwsem_is_contended(struct rw_semaphore *sem)
+{
+       return !plist_head_empty(&sem->lock.wait_list);
+}
 #endif
#1 lore raw
Quoted 7 lines · * Clark Williams | 2014-08-27 16:09:28 [-0500]:

Thomas,

The latest btrfs code uses rwsem_is_contended() in the function caching_thread(). On RT systems, include/linux/rwsem.h is replaced with include/linux/rwsem_rt.h which does not provide a definition for rwsem_is_contended(). This commit provides a definition that should work on RT (where the lock is actually an rt_mutex).

I see that I added rwsem_is_contended() in v3.14-rt1 which does:

|static inline int rwsem_is_contended(struct rw_semaphore *sem)
|{
|      /* rt_mutex_has_waiters() */
|      return !RB_EMPTY_ROOT(&sem->lock.waiters);
|}

Do you lack this in kernel prior to v3.14?

Sebastian

#2 lore raw
Quoted 17 lines · On Tue, 17 Feb 2015 11:09:11 +0100 Sebastian Andrzej Siewior…
Quoted 7 lines · * Clark Williams | 2014-08-27 16:09:28 [-0500]:

Thomas,

The latest btrfs code uses rwsem_is_contended() in the function caching_thread(). On RT systems, include/linux/rwsem.h is replaced with include/linux/rwsem_rt.h which does not provide a definition for rwsem_is_contended(). This commit provides a definition that should work on RT (where the lock is actually an rt_mutex).

I see that I added rwsem_is_contended() in v3.14-rt1 which does:

|static inline int rwsem_is_contended(struct rw_semaphore *sem)
|{
|      /* rt_mutex_has_waiters() */
|      return !RB_EMPTY_ROOT(&sem->lock.waiters);
|}
Quoted 3 lines

Do you lack this in kernel prior to v3.14?

Sebastian

Yes, that was the problem. I was back-porting to a 3.10 and was missing the definition. Sorry for the noise.

Clark