Skip to content

Commit 92cc5d0

Browse files
johnstultz-workPeter Zijlstra
authored andcommitted
locking/rwsem: Add __always_inline annotation to __down_read_common() and inlined callers
Apparently despite it being marked inline, the compiler may not inline __down_read_common() which makes it difficult to identify the cause of lock contention, as the blocked function in traceevents will always be listed as __down_read_common(). So this patch adds __always_inline annotation to the common function (as well as the inlined helper callers) to force it to be inlined so the blocking function will be listed (via Wchan) in traceevents. Fixes: c995e63 ("locking/rwsem: Fold __down_{read,write}*()") Reported-by: Tim Murray <timmurray@google.com> Signed-off-by: John Stultz <jstultz@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Waiman Long <longman@redhat.com> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20230503023351.2832796-1-jstultz@google.com
1 parent ac9a786 commit 92cc5d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

kernel/locking/rwsem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ static struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem)
12401240
/*
12411241
* lock for reading
12421242
*/
1243-
static inline int __down_read_common(struct rw_semaphore *sem, int state)
1243+
static __always_inline int __down_read_common(struct rw_semaphore *sem, int state)
12441244
{
12451245
int ret = 0;
12461246
long count;
@@ -1258,17 +1258,17 @@ static inline int __down_read_common(struct rw_semaphore *sem, int state)
12581258
return ret;
12591259
}
12601260

1261-
static inline void __down_read(struct rw_semaphore *sem)
1261+
static __always_inline void __down_read(struct rw_semaphore *sem)
12621262
{
12631263
__down_read_common(sem, TASK_UNINTERRUPTIBLE);
12641264
}
12651265

1266-
static inline int __down_read_interruptible(struct rw_semaphore *sem)
1266+
static __always_inline int __down_read_interruptible(struct rw_semaphore *sem)
12671267
{
12681268
return __down_read_common(sem, TASK_INTERRUPTIBLE);
12691269
}
12701270

1271-
static inline int __down_read_killable(struct rw_semaphore *sem)
1271+
static __always_inline int __down_read_killable(struct rw_semaphore *sem)
12721272
{
12731273
return __down_read_common(sem, TASK_KILLABLE);
12741274
}

0 commit comments

Comments
 (0)