linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	jochensp@jochen.sprickerhof.de, peter.griffin@linaro.org
Subject: [PATCH 0/3] tracing: Add ':mod:' command to set_event to enable events in modules
Date: Thu, 16 Jan 2025 09:33:34 -0500	[thread overview]
Message-ID: <20250116143334.073917300@goodmis.org> (raw)


I was asked if there was a way to enable events for a module on boot
up. Unfortunately there currently isn't a way to do so. I decided to
added the ":mod:" feature that set_ftrace_filter has to the set_event
file as well as to the kernel command line (which uses the same code
as what the set_event file takes).

Now you can enable events for a given module without having to know
what events that module has.

 echo ':mod:<module' > set_event

You can enable some events or event systems for a module too:

 echo '<system>:<event>:mod:<module>' > set_event

Where either <system> or <event> can be missing or "*".

For the following:

 echo '<match>:mod:<module>' > set_event

It will enable any system or event that has the name <match>.

If the module is not loaded, then the string is saved, and when the
module is loaded, it will be executed on that module before the module
executes. This means any module event that is called in its init
functions will also be traced.

This works on the kernel command line as well:

  trace_event=:mod:<module>

Will enable all the events for <module> when it is loaded.

I also added a thorough test to test this feature, although it doest
obviously test the kernel command line.

This is based on top of

  git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git
  trace/for-next

Steven Rostedt (3):
      tracing: Add ':mod:' command to enabled module events
      tracing: Cache ":mod:" events for modules not loaded yet
      selftests/ftrace: Add test that tests event :mod: commands

----
 Documentation/admin-guide/kernel-parameters.txt    |   8 +
 Documentation/trace/events.rst                     |  24 ++
 kernel/trace/ftrace.c                              |  17 --
 kernel/trace/trace.c                               |  28 ++
 kernel/trace/trace.h                               |  12 +
 kernel/trace/trace_events.c                        | 300 +++++++++++++++++++--
 .../selftests/ftrace/test.d/event/event-mod.tc     | 192 +++++++++++++
 7 files changed, 540 insertions(+), 41 deletions(-)
 create mode 100644 tools/testing/selftests/ftrace/test.d/event/event-mod.tc

             reply	other threads:[~2025-01-16 14:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 14:33 Steven Rostedt [this message]
2025-01-16 14:33 ` [PATCH 1/3] tracing: Add :mod: command to enabled module events Steven Rostedt
2025-01-16 14:33 ` [PATCH 2/3] tracing: Cache ":mod:" events for modules not loaded yet Steven Rostedt
2025-01-16 14:33 ` [PATCH 3/3] selftests/ftrace: Add test that tests event :mod: commands Steven Rostedt

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=20250116143334.073917300@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=jochensp@jochen.sprickerhof.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=peter.griffin@linaro.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;
as well as URLs for NNTP newsgroup(s).