mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	x86@kernel.org
Subject: Re: [PATCH v2] ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function
Date: Thu, 26 May 2022 09:14:40 -0400	[thread overview]
Message-ID: <20220526091440.7c40a577@gandalf.local.home> (raw)
In-Reply-To: <20220526073949.GL2578@worktop.programming.kicks-ass.net>

On Thu, 26 May 2022 09:39:49 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> > If CONFIG_HAVE_FENTRY is defined for x86, define FTRACE_MCOUNT_MAX_OFFSET
> > to zero, which will have ftrace ignore all locations that are not at the
> > start of the function.  
> 
> ^^^ that paragraph is obsolete by your own changes thing below :-)

Well, it is partially correct (if X86_KERNEL_IBT is disabled).

I'll update the change log to reflect the update.

> 
> > [1] https://lore.kernel.org/all/20220412094923.0abe90955e5db486b7bca279@kernel.org/
> > 
> > Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> > ---
> > Changes since v1: https://lore.kernel.org/all/20220503150410.2d9e88aa@rorschach.local.home/
> > 
> >  - Changed MAX_OFFSET to 4 on x86 if KERNEL_IBT is enabled
> >    (Reminded by Peter Zijlstra)
> > 
> >  arch/x86/include/asm/ftrace.h | 10 +++++++
> >  kernel/trace/ftrace.c         | 50 +++++++++++++++++++++++++++++++++--
> >  2 files changed, 58 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
> > index 024d9797646e..53675fe2d847 100644
> > --- a/arch/x86/include/asm/ftrace.h
> > +++ b/arch/x86/include/asm/ftrace.h
> > @@ -9,6 +9,16 @@
> >  # define MCOUNT_ADDR		((unsigned long)(__fentry__))
> >  #define MCOUNT_INSN_SIZE	5 /* sizeof mcount call */
> >  
> > +/* Ignore unused weak functions which will have non zero offsets */
> > +#ifdef CONFIG_HAVE_FENTRY
> > +# ifdef CONFIG_X86_KERNEL_IBT
> > +/* endbr64 is 4 bytes in front of the fentry */
> > +#  define FTRACE_MCOUNT_MAX_OFFSET	4
> > +# else
> > +#  define FTRACE_MCOUNT_MAX_OFFSET	0
> > +# endif
> > +#endif  
> 
> #define FTRACE_MCOUNT_MAX_OFFSET ENDBR_INSN_SIZE
> 
> Should do the same I think, less lines etc..

Thanks, I figured there was something else I could use besides hard coding
it. But I may add that as a separate patch after this gets merged, because
my branch doesn't have that code in it yet, so it wont compile.

-- Steve

      reply	other threads:[~2022-05-26 13:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25 22:05 Steven Rostedt
2022-05-26  2:50 ` Ingo Molnar
2022-05-26 13:11   ` Steven Rostedt
2022-05-27 10:04     ` Ingo Molnar
2022-05-27 20:36       ` Steven Rostedt
2022-05-26  7:39 ` Peter Zijlstra
2022-05-26 13:14   ` Steven Rostedt [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=20220526091440.7c40a577@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=songliubraving@fb.com \
    --cc=x86@kernel.org \
    --cc=yhs@fb.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
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

all inboxes | Powered by JetHome®