From: Peter Zijlstra <peterz@infradead.org>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>,
Ingo Molnar <mingo@kernel.org>, Will Deacon <will@kernel.org>,
Waiman Long <longman@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Steven Rostedt <rostedt@goodmis.org>,
Byungchul Park <byungchul.park@lge.com>,
"Paul E. McKenney" <paulmck@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Arnd Bergmann <arnd@arndb.de>, Radoslaw Burny <rburny@google.com>,
linux-arch@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH 2/2] locking: Apply contention tracepoints in the slow path
Date: Fri, 18 Mar 2022 17:43:26 +0100 [thread overview]
Message-ID: <YjS2rlezTh9gdlDh@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <YjSBRNxzaE9c+F/1@boqun-archlinux>
On Fri, Mar 18, 2022 at 08:55:32PM +0800, Boqun Feng wrote:
> On Wed, Mar 16, 2022 at 03:45:48PM -0700, Namhyung Kim wrote:
> [...]
> > @@ -209,6 +210,7 @@ static inline int __sched __down_common(struct semaphore *sem, long state,
> > long timeout)
> > {
> > struct semaphore_waiter waiter;
> > + bool tracing = false;
> >
> > list_add_tail(&waiter.list, &sem->wait_list);
> > waiter.task = current;
> > @@ -220,18 +222,28 @@ static inline int __sched __down_common(struct semaphore *sem, long state,
> > if (unlikely(timeout <= 0))
> > goto timed_out;
> > __set_current_state(state);
> > + if (!tracing) {
> > + trace_contention_begin(sem, 0);
>
> This looks a littl ugly ;-/ Maybe we can rename __down_common() to
> ___down_common() and implement __down_common() as:
>
> static inline int __sched __down_common(...)
> {
> int ret;
> trace_contention_begin(sem, 0);
> ret = ___down_common(...);
> trace_contention_end(sem, ret);
> return ret;
> }
>
> Thoughts?
Yeah, that works, except I think he wants a few extra
__set_current_state()'s like so:
diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
index 9ee381e4d2a4..e2049a7e0ea4 100644
--- a/kernel/locking/semaphore.c
+++ b/kernel/locking/semaphore.c
@@ -205,8 +205,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,
- long timeout)
+static __always_inline int ___down_common(struct semaphore *sem, long state, long timeout)
{
struct semaphore_waiter waiter;
@@ -227,15 +226,28 @@ static inline int __sched __down_common(struct semaphore *sem, long state,
return 0;
}
- timed_out:
+timed_out:
list_del(&waiter.list);
return -ETIME;
- interrupted:
+interrupted:
list_del(&waiter.list);
return -EINTR;
}
+static __always_inline int __down_common(struct semaphore *sem, long state, long timeout)
+{
+ int ret;
+
+ __set_current_state(state);
+ trace_contention_begin(sem, 0);
+ ret = ___down_common(sem, state, timeout);
+ __set_current_state(TASK_RUNNING);
+ trace_contention_end(sem, ret);
+
+ return ret;
+}
+
static noinline void __sched __down(struct semaphore *sem)
{
__down_common(sem, TASK_UNINTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
next prev parent reply other threads:[~2022-03-18 16:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-16 22:45 [PATCH 0/2] locking: Add new lock contention tracepoints (v3) Namhyung Kim
2022-03-16 22:45 ` [PATCH 1/2] locking: Add lock contention tracepoints Namhyung Kim
2022-03-17 2:31 ` Steven Rostedt
2022-03-17 13:32 ` Mathieu Desnoyers
2022-03-17 16:07 ` Steven Rostedt
2022-03-17 16:37 ` Mathieu Desnoyers
2022-03-18 20:58 ` Namhyung Kim
2022-03-16 22:45 ` [PATCH 2/2] locking: Apply contention tracepoints in the slow path Namhyung Kim
2022-03-17 13:45 ` Mathieu Desnoyers
2022-03-17 16:10 ` Steven Rostedt
2022-03-17 16:43 ` Mathieu Desnoyers
2022-03-18 21:34 ` Namhyung Kim
2022-03-17 18:19 ` Hyeonggon Yoo
2022-03-18 21:43 ` Namhyung Kim
2022-03-18 12:55 ` Boqun Feng
2022-03-18 13:24 ` Hyeonggon Yoo
2022-03-18 13:28 ` Hyeonggon Yoo
2022-03-18 16:43 ` Peter Zijlstra [this message]
2022-03-18 21:55 ` Namhyung Kim
2022-03-18 22:07 ` Steven Rostedt
2022-03-19 0:11 ` Namhyung Kim
2022-03-22 5:31 ` Namhyung Kim
2022-03-22 12:59 ` Steven Rostedt
2022-03-22 16:39 ` Namhyung Kim
2022-03-17 17:32 ` [PATCH 0/2] locking: Add new lock contention tracepoints (v3) Hyeonggon Yoo
2022-03-18 21:12 ` Namhyung Kim
-- strict thread matches above, loose matches on Subject: below --
2022-03-22 18:57 [PATCH 0/2] locking: Add new lock contention tracepoints (v4) Namhyung Kim
2022-03-22 18:57 ` [PATCH 2/2] locking: Apply contention tracepoints in the slow path Namhyung Kim
2022-03-28 11:29 ` Peter Zijlstra
2022-03-28 17:41 ` Namhyung Kim
2022-03-28 11:39 ` Peter Zijlstra
2022-03-28 17:48 ` Namhyung Kim
2022-03-30 11:08 ` Peter Zijlstra
2022-03-30 19:03 ` Namhyung Kim
2022-03-31 11:59 ` Peter Zijlstra
2022-04-01 6:26 ` Namhyung Kim
2022-04-01 9:25 ` Peter Zijlstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YjS2rlezTh9gdlDh@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=arnd@arndb.de \
--cc=boqun.feng@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=byungchul.park@lge.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulmck@kernel.org \
--cc=rburny@google.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox