diff options
author | Namhyung Kim <namhyung@kernel.org> | 2022-03-22 11:57:09 -0700 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2022-04-05 10:24:35 +0200 |
commit | ee042be16cb455116d0fe99b77c6bc8baf87c8c6 (patch) | |
tree | d5de58e2f2882f0a433ab90a74d23fbee67aa7be /kernel/locking/semaphore.c | |
parent | 16edd9b511a13e7760ed4b92ba4e39bacda5c86f (diff) | |
download | linux-ee042be16cb455116d0fe99b77c6bc8baf87c8c6.tar.gz linux-ee042be16cb455116d0fe99b77c6bc8baf87c8c6.tar.bz2 linux-ee042be16cb455116d0fe99b77c6bc8baf87c8c6.zip |
locking: Apply contention tracepoints in the slow path
Adding the lock contention tracepoints in various lock function slow
paths. Note that each arch can define spinlock differently, I only
added it only to the generic qspinlock for now.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
Link: https://lkml.kernel.org/r/20220322185709.141236-3-namhyung@kernel.org
Diffstat (limited to 'kernel/locking/semaphore.c')
-rw-r--r-- | kernel/locking/semaphore.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c index 9ee381e4d2a4..f2654d2fe43a 100644 --- a/kernel/locking/semaphore.c +++ b/kernel/locking/semaphore.c @@ -32,6 +32,7 @@ #include <linux/semaphore.h> #include <linux/spinlock.h> #include <linux/ftrace.h> +#include <trace/events/lock.h> static noinline void __down(struct semaphore *sem); static noinline int __down_interruptible(struct semaphore *sem); @@ -205,7 +206,7 @@ struct semaphore_waiter { * constant, and thus optimised away by the compiler. Likewise the * 'timeout' parameter for the cases without timeouts. */ -static inline int __sched __down_common(struct semaphore *sem, long state, +static inline int __sched ___down_common(struct semaphore *sem, long state, long timeout) { struct semaphore_waiter waiter; @@ -236,6 +237,18 @@ static inline int __sched __down_common(struct semaphore *sem, long state, return -EINTR; } +static inline int __sched __down_common(struct semaphore *sem, long state, + long timeout) +{ + int ret; + + trace_contention_begin(sem, 0); + ret = ___down_common(sem, state, timeout); + trace_contention_end(sem, ret); + + return ret; +} + static noinline void __sched __down(struct semaphore *sem) { __down_common(sem, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); |