Linux-mm Archive on lore.kernel.org
 help / color / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>,
	 Axel Rasmussen <axelrasmussen@google.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Vlastimil Babka <vbabka@suse.cz>,
	 Michel Lespinasse <walken@google.com>,
	 Daniel Jordan <daniel.m.jordan@oracle.com>,
	 Davidlohr Bueso <dbueso@suse.de>, Linux MM <linux-mm@kvack.org>,
	 Ingo Molnar <mingo@kernel.org>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH 0/3 v2] tracing/mm: Add tracepoint_enabled() helper function for headers
Date: Fri, 25 Sep 2020 18:23:34 -0400 (EDT)
Message-ID: <606086581.69952.1601072614802.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <20200925172640.701ca0a7@oasis.local.home>

No worries, I'll get it from lore.

Thanks,

Mathieu

----- Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> Bah, My cut-and-paste of my "quilt mail --send" chopped off Mathieu's email.
> 
> Mathieu, I didn't meant to not Cc you on this. Do you need me to bounce
> the rest to you or you can get it from lore?
> 
> -- Steve
> 
> 
> On Fri, 25 Sep 2020 17:12:06 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
> 
> > 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. Not
> > to mention it also will bloat the code being in commonly used inline
> > functions.
> > 
> > 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 not 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")
> >  commit 7f47d8cc039f ("x86, tracing, perf: Add trace point for MSR accesses")
> > 
> > does this (back in 2015). 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, and third converts over msr.h.
> > 
> > Steven Rostedt (VMware) (3):
> >       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
> >       x86: Use tracepoint_enabled() for msr tracepoints instead of open coding it
> > 
> > ----
> > 
> > Changes since v1 (https://lore.kernel.org/r/20200924170928.466191266@goodmis.org):
> > 
> >  - Fixed using "trace_enabled()" instead of "tracepoint_enabled()"
> >    (Mathieu Desnoyers reported)
> > 
> >  - Reworded to include comments about bloating the kernel when tracepoints
> >    are used in commonly used inlined functions.
> > 
> >  - Added the msr update as well.
> > 
> > 
> >  Documentation/trace/tracepoints.rst | 27 ++++++++++++++++++++++++
> >  arch/x86/include/asm/msr.h          | 18 +++++++---------
> >  include/linux/page_ref.h            | 42 ++++++++++++++++++-------------------
> >  include/linux/tracepoint-defs.h     | 34 ++++++++++++++++++++++++++++++
> >  4 files changed, 90 insertions(+), 31 deletions(-)
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


      reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 21:12 Steven Rostedt
2020-09-25 21:12 ` [PATCH 1/3 v2] tracepoints: Add helper to test if tracepoint is enabled in a header Steven Rostedt
2020-09-25 21:36   ` Axel Rasmussen
2020-09-25 21:59     ` Steven Rostedt
2020-10-20 11:59   ` Vlastimil Babka
2020-10-20 20:43     ` Steven Rostedt
2020-09-25 21:12 ` [PATCH 2/3 v2] mm/page_ref: Convert the open coded tracepoint enabled to the new helper Steven Rostedt
2020-10-20 12:10   ` Vlastimil Babka
2020-09-25 21:12 ` [PATCH 3/3 v2] x86: Use tracepoint_enabled() for msr tracepoints instead of open coding it Steven Rostedt
2020-09-26  6:55   ` kernel test robot
2020-09-25 21:26 ` [PATCH 0/3 v2] tracing/mm: Add tracepoint_enabled() helper function for headers Steven Rostedt
2020-09-25 22:23   ` Mathieu Desnoyers [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=606086581.69952.1601072614802.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=daniel.m.jordan@oracle.com \
    --cc=dbueso@suse.de \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=vbabka@suse.cz \
    --cc=walken@google.com \
    /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

Linux-mm Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mm/0 linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ https://lore.kernel.org/linux-mm \
		linux-mm@kvack.org
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kvack.linux-mm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git