Linux Trace Kernel
 help / color / mirror / Atom feed
From: Frederic Weisbecker <frederic@kernel.org>
To: Junxuan Liao <ljx@cs.wisc.edu>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: Re: Interface for enabling context tracking
Date: Fri, 11 Apr 2025 23:51:39 +0200	[thread overview]
Message-ID: <Z_mO6_m0bV-Q8NEa@pavilion.home> (raw)
In-Reply-To: <4a90f134-82ac-428e-be5b-916cf031157e@cs.wisc.edu>

Le Fri, Apr 11, 2025 at 12:41:37PM -0500, Junxuan Liao a écrit :
> 
> > > Are you interested in working on joining the noble quest of getting the
> > > rest of the nohz_full support in place?  (Full disclosure: This stuff
> > > is non-trivial.)
> > 
> > I believe the request is more of just tracing entry and exit from the
> > kernel, which just needs a simple trace event at the border crossings.
> 
> Yeah I'm more interested in just tracing this for now.
> 
> > It's been on my todo list to add one for page
> > fault exit (as I do care for how long they last.
> 
> I've added a tracepoint similar to page_fault_user for that but I'm not
> sure if it's the best way to do it. Should I send a patch for review?

If you do so, it may be a good idea to remove page_fault_user and
page_fault_kernel and introduce page_fault_user_enter/page_fault_user_exit
and page_fault_kernel_enter/page_fault_kernel_exit.

But the following is also possible (and then trace/events/context_tracking.h
should be renamed into trace/events/entry.h):

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index fc61d0205c97..83b1764078f7 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -15,6 +15,8 @@
 
 #include <asm/entry-common.h>
 
+#include <trace/events/context_tracking.h>
+
 /*
  * Define dummy _TIF work flags if not defined by the architecture or for
  * disabled functionality.
@@ -115,6 +117,7 @@ static __always_inline void enter_from_user_mode(struct pt_regs *regs)
 	instrumentation_begin();
 	kmsan_unpoison_entry_regs(regs);
 	trace_hardirqs_off_finish();
+	trace_user_exit(0);
 	instrumentation_end();
 }
 
@@ -357,6 +360,7 @@ static __always_inline void exit_to_user_mode_prepare(struct pt_regs *regs)
 static __always_inline void exit_to_user_mode(void)
 {
 	instrumentation_begin();
+	trace_user_enter(0);
 	trace_hardirqs_on_prepare();
 	lockdep_hardirqs_on_prepare();
 	instrumentation_end();
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index fb5be6e9b423..e9395936bded 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -428,9 +428,6 @@ static __always_inline void ct_kernel_enter(bool user, int offset) { }
 
 #ifdef CONFIG_CONTEXT_TRACKING_USER
 
-#define CREATE_TRACE_POINTS
-#include <trace/events/context_tracking.h>
-
 DEFINE_STATIC_KEY_FALSE_RO(context_tracking_key);
 EXPORT_SYMBOL_GPL(context_tracking_key);
 
@@ -486,7 +483,6 @@ void noinstr __ct_user_enter(enum ctx_state state)
 			 */
 			if (state == CT_STATE_USER) {
 				instrumentation_begin();
-				trace_user_enter(0);
 				vtime_user_enter(current);
 				instrumentation_end();
 			}
@@ -623,7 +619,6 @@ void noinstr __ct_user_exit(enum ctx_state state)
 			if (state == CT_STATE_USER) {
 				instrumentation_begin();
 				vtime_user_exit(current);
-				trace_user_exit(0);
 				instrumentation_end();
 			}
 





-- 
Frederic Weisbecker
SUSE Labs

      reply	other threads:[~2025-04-11 21:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 18:51 Interface for enabling context tracking Junxuan Liao
2025-04-10 19:05 ` Steven Rostedt
2025-04-10 20:31   ` Junxuan Liao
2025-04-17 19:10   ` Junxuan Liao
2025-04-17 20:34     ` Steven Rostedt
2025-04-10 19:10 ` Paul E. McKenney
2025-04-10 19:32   ` Steven Rostedt
2025-04-11 17:41     ` Junxuan Liao
2025-04-11 21:51       ` Frederic Weisbecker [this message]

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=Z_mO6_m0bV-Q8NEa@pavilion.home \
    --to=frederic@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljx@cs.wisc.edu \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=rostedt@goodmis.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