linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] tracing/mm: Add tracepoint_enabled() helper function for headers
@ 2020-09-24 17:09 Steven Rostedt
  2020-09-24 17:09 ` [PATCH 1/2] tracepoints: Add helper to test if tracepoint is enabled in a header Steven Rostedt
  2020-09-24 17:09 ` [PATCH 2/2] mm/page_ref: Convert the open coded tracepoint enabled to the new helper Steven Rostedt
  0 siblings, 2 replies; 21+ messages in thread
From: Steven Rostedt @ 2020-09-24 17:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Yafang Shao, Axel Rasmussen, Andrew Morton, Vlastimil Babka,
	Michel Lespinasse, Daniel Jordan, Davidlohr Bueso, Linux MM,
	Ingo Molnar, Joonsoo Kim, Mathieu Desnoyers

Tracepoints are not safe to be called directly from header files as they may
be included by C code that has CREATE_TRACE_POINTS defined, and this would
cause side effects and possibly break the build in hard to debug ways.

Instead, it is recommended to call a tracepoint helper function that is
defined in a C file that calls the tracepoint. But we would only want this
function to be called if the tracepoint is enabled, as function calls add
overhead.

The trace_<tracepoint>_enabled() function is also no safe to be called in a
header file as it is created by the tracepoint header, which suffers the
same fate if CREATE_TRACE_POINTS is defined. Instead, the tracepoint needs
to be declared as an extern, and the helper function can test the static key
to call the helper function that calls the tracepoint.

This has been done by open coding the tracepoint extern and calling the
static key directly:

 commit 95813b8faa0cd ("mm/page_ref: add tracepoint to track down page
    reference manipulation")

does this (back in 2016). Now we have another use case, so a helper function
should be created to keep the internals of the tracepoints from being spread
out in other subsystems.

 Link: https://lore.kernel.org/r/20200922125113.12ef1e03@gandalf.local.home

This adds tracepoint_enabled() helper macro and DECLARE_TRACEPOINT() macro
to allow this to be done without exposing the internals of the tracepoints.

The first patch adds the infrastructure, the second converts page_ref over
to it. I also noticed that the msr tracepoint needs to be converted as well.


Steven Rostedt (VMware) (2):
      tracepoints: Add helper to test if tracepoint is enabled in a header
      mm/page_ref: Convert the open coded tracepoint enabled to the new helper

----
 Documentation/trace/tracepoints.rst | 25 ++++++++++++++++++++++
 include/linux/page_ref.h            | 42 ++++++++++++++++++-------------------
 include/linux/tracepoint-defs.h     | 33 +++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 21 deletions(-)

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2020-09-25 17:05 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24 17:09 [PATCH 0/2] tracing/mm: Add tracepoint_enabled() helper function for headers Steven Rostedt
2020-09-24 17:09 ` [PATCH 1/2] tracepoints: Add helper to test if tracepoint is enabled in a header Steven Rostedt
2020-09-24 17:42   ` Mathieu Desnoyers
2020-09-24 18:19     ` Axel Rasmussen
2020-09-24 18:27       ` Mathieu Desnoyers
2020-09-24 18:30     ` Steven Rostedt
2020-09-24 19:08       ` Mathieu Desnoyers
2020-09-24 19:35         ` Steven Rostedt
2020-09-24 19:40           ` Steven Rostedt
2020-09-24 20:25             ` Mathieu Desnoyers
2020-09-24 20:05           ` Mathieu Desnoyers
2020-09-24 20:13             ` Steven Rostedt
2020-09-24 20:27               ` Mathieu Desnoyers
2020-09-24 20:33                 ` Steven Rostedt
2020-09-25 14:41                   ` Mathieu Desnoyers
2020-09-25 15:14                     ` Steven Rostedt
2020-09-25 15:30                       ` Mathieu Desnoyers
2020-09-25 16:26                         ` Steven Rostedt
2020-09-25 17:05                           ` Mathieu Desnoyers
2020-09-24 20:04         ` Axel Rasmussen
2020-09-24 17:09 ` [PATCH 2/2] mm/page_ref: Convert the open coded tracepoint enabled to the new helper Steven Rostedt

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).