linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Huang Pei <huangpei@loongson.cn>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>, ambrosehua@gmail.com
Cc: Bibo Mao <maobibo@loongson.cn>,
	linux-mips@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-mm@kvack.org, Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Paul Burton <paulburton@kernel.org>,
	Li Xuefeng <lixuefeng@loongson.cn>,
	Yang Tiezhu <yangtiezhu@loongson.cn>,
	Gao Juxin <gaojuxin@loongson.cn>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Jinyang He <hejinyang@loongson.cn>,
	"Maciej W . Rozycki" <macro@orcam.me.uk>,
	Steven Rostedt <rostedt@goodmis.org>,
	Jisheng Zhang <Jisheng.Zhang@synaptics.com>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: [PATCH 5/6] ftrace: introduce FTRACE_IP_EXTENSION
Date: Sat, 13 Mar 2021 14:41:48 +0800	[thread overview]
Message-ID: <20210313064149.29276-6-huangpei@loongson.cn> (raw)
In-Reply-To: <20210313064149.29276-1-huangpei@loongson.cn>

From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>

On some architectures, the DYNAMIC_FTRACE_WITH_REGS is implemented by
gcc's -fpatchable-function-entry option. Take arm64 for example, arm64
makes use of GCC -fpatchable-function-entry=2 option to insert two
nops. When the function is traced, the first nop will be modified to
the LR saver, then the second nop to "bl <ftrace-entry>". we need to
update ftrace_location() to recognise these two instructions  as being
part of ftrace. To do this, we introduce FTRACE_IP_EXTENSION to let
ftrace_location search IP, IP + FTRACE_IP_EXTENSION range.

Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
Suggested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/linux/ftrace.h | 4 ++++
 kernel/trace/ftrace.c  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 1bd3a0356ae4..c1e1fbde8a04 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -20,6 +20,10 @@
 
 #include <asm/ftrace.h>
 
+#ifndef FTRACE_IP_EXTENSION
+#define  FTRACE_IP_EXTENSION 0
+#endif
+
 /*
  * If the arch supports passing the variable contents of
  * function_trace_op as the third parameter back from the
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 9c1bba8cc51b..a6f0e3db2479 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1583,7 +1583,7 @@ unsigned long ftrace_location_range(unsigned long start, unsigned long end)
  */
 unsigned long ftrace_location(unsigned long ip)
 {
-	return ftrace_location_range(ip, ip);
+	return ftrace_location_range(ip, ip + FTRACE_IP_EXTENSION);
 }
 
 /**
-- 
2.17.1



  parent reply	other threads:[~2021-03-13  6:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-13  6:41 [RFC PATCH V2]: add DYNAMC_FTRACE_WITH_REGS and Huang Pei
2021-03-13  6:41 ` [PATCH 1/6] MIPS: replace -pg with CC_FLAGS_FTRACE Huang Pei
2021-03-25 19:38   ` Steven Rostedt
2021-03-26  1:48     ` Huang Pei
2021-03-13  6:41 ` [PATCH 2/6] MIPS: move FTRACE_SYSCALLS from ftrace.c into syscall.c Huang Pei
2021-03-25 19:38   ` Steven Rostedt
2021-03-26 14:01     ` Huang Pei
2021-03-13  6:41 ` [PATCH 3/6] MIPS: prepare for new ftrace implementation Huang Pei
2021-03-25 19:39   ` Steven Rostedt
2021-03-13  6:41 ` [PATCH 4/6] kprobes/ftrace: Use ftrace_location() when [dis]arming probes Huang Pei
2021-03-25 19:44   ` Steven Rostedt
2021-03-26 14:12     ` Huang Pei
2021-03-26 14:23       ` Steven Rostedt
2021-03-13  6:41 ` Huang Pei [this message]
2021-03-13  9:26   ` [PATCH 5/6] ftrace: introduce FTRACE_IP_EXTENSION Sergei Shtylyov
2021-03-13  6:41 ` [PATCH 6/6] MIPS: add DYNAMIC_FTRACE_WITH_REGS and KPROBES_ON_FTACE Huang Pei
2021-03-13 21:37   ` kernel test robot

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=20210313064149.29276-6-huangpei@loongson.cn \
    --to=huangpei@loongson.cn \
    --cc=Jisheng.Zhang@synaptics.com \
    --cc=ambrosehua@gmail.com \
    --cc=chenhuacai@loongson.cn \
    --cc=gaojuxin@loongson.cn \
    --cc=hejinyang@loongson.cn \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lixuefeng@loongson.cn \
    --cc=macro@orcam.me.uk \
    --cc=maobibo@loongson.cn \
    --cc=mhiramat@kernel.org \
    --cc=paulburton@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=yangtiezhu@loongson.cn \
    /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).