linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ftrace: Match dot symbols when searching functions on ppc64
@ 2016-04-25 21:56 Thiago Jung Bauermann
  2016-04-26 13:36 ` Steven Rostedt
  2016-04-28 14:22 ` [v2] " Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2016-04-25 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thiago Jung Bauermann, Steven Rostedt, Ingo Molnar,
	Michael Ellerman, linuxppc-dev

In the ppc64 big endian ABI, function symbols point to function
descriptors. The symbols which point to the function entry points
have a dot in front of the function name. Consequently, when the
ftrace filter mechanism searches for the symbol corresponding to
an entry point address, it gets the dot symbol.

As a result, ftrace filter users have to be aware of this ABI detail on
ppc64 and prepend a dot to the function name when setting the filter.

The perf probe command insulates the user from this by ignoring the dot
in front of the symbol name when matching function names to symbols,
but the sysfs interface does not. This patch makes the ftrace filter
mechanism do the same when searching symbols.

Fixes the following failure in ftracetest's kprobe_ftrace.tc:

  .../kprobe_ftrace.tc: line 9: echo: write error: Invalid argument

That failure is on this line of kprobe_ftrace.tc:

  echo _do_fork > set_ftrace_filter

This is because there's no _do_fork entry in the functions list:

  # cat available_filter_functions | grep _do_fork
  ._do_fork

This change introduces no regressions on the perf and ftracetest
testsuite results.

Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
---

Notes:
    Changes from v1 to v2:
    - Use __weak mechanism instead of #ifdef.
    - Return modified pointer instead of changing it in the argument.

 arch/powerpc/kernel/ftrace.c | 10 ++++++++++
 kernel/trace/ftrace.c        | 12 ++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 9dac18dabd03..1123a4d8d8dd 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -607,3 +607,13 @@ unsigned long __init arch_syscall_addr(int nr)
 	return sys_call_table[nr*2];
 }
 #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
+
+#if defined(CONFIG_PPC64) && (!defined(_CALL_ELF) || _CALL_ELF != 2)
+char *arch_ftrace_match_adjust(char *str, const char *search)
+{
+	if (str[0] == '.' && search[0] != '.')
+		return str + 1;
+	else
+		return str;
+}
+#endif /* defined(CONFIG_PPC64) && (!defined(_CALL_ELF) || _CALL_ELF != 2) */
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b1870fbd2b67..a28322e3fed3 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3444,11 +3444,23 @@ struct ftrace_glob {
 	int type;
 };
 
+/*
+ * If symbols in an architecture don't correspond exactly to the user-visible
+ * name of what they represent, it is possible to define this function to
+ * perform the necessary adjustments.
+*/
+char * __weak arch_ftrace_match_adjust(char *str, const char *search)
+{
+	return str;
+}
+
 static int ftrace_match(char *str, struct ftrace_glob *g)
 {
 	int matched = 0;
 	int slen;
 
+	str = arch_ftrace_match_adjust(str, g->search);
+
 	switch (g->type) {
 	case MATCH_FULL:
 		if (strcmp(str, g->search) == 0)
-- 
1.9.1

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

* Re: [PATCH v2] ftrace: Match dot symbols when searching functions on ppc64
  2016-04-25 21:56 [PATCH v2] ftrace: Match dot symbols when searching functions on ppc64 Thiago Jung Bauermann
@ 2016-04-26 13:36 ` Steven Rostedt
  2016-04-28 14:22 ` [v2] " Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-04-26 13:36 UTC (permalink / raw)
  To: Thiago Jung Bauermann
  Cc: linux-kernel, Ingo Molnar, Michael Ellerman, linuxppc-dev

On Mon, 25 Apr 2016 18:56:14 -0300
Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> wrote:

> In the ppc64 big endian ABI, function symbols point to function
> descriptors. The symbols which point to the function entry points
> have a dot in front of the function name. Consequently, when the
> ftrace filter mechanism searches for the symbol corresponding to
> an entry point address, it gets the dot symbol.
> 
> As a result, ftrace filter users have to be aware of this ABI detail on
> ppc64 and prepend a dot to the function name when setting the filter.
> 
> The perf probe command insulates the user from this by ignoring the dot
> in front of the symbol name when matching function names to symbols,
> but the sysfs interface does not. This patch makes the ftrace filter
> mechanism do the same when searching symbols.
> 
> Fixes the following failure in ftracetest's kprobe_ftrace.tc:
> 
>   .../kprobe_ftrace.tc: line 9: echo: write error: Invalid argument
> 
> That failure is on this line of kprobe_ftrace.tc:
> 
>   echo _do_fork > set_ftrace_filter
> 
> This is because there's no _do_fork entry in the functions list:
> 
>   # cat available_filter_functions | grep _do_fork
>   ._do_fork
> 
> This change introduces no regressions on the perf and ftracetest
> testsuite results.
> 
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
> ---

Acked-by: Steven Rostedt <rostedt@goodmis.org>

This can go through the ppc tree.

-- Steve

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

* Re: [v2] ftrace: Match dot symbols when searching functions on ppc64
  2016-04-25 21:56 [PATCH v2] ftrace: Match dot symbols when searching functions on ppc64 Thiago Jung Bauermann
  2016-04-26 13:36 ` Steven Rostedt
@ 2016-04-28 14:22 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-04-28 14:22 UTC (permalink / raw)
  To: Thiago Jung Bauermann, linux-kernel
  Cc: Thiago Jung Bauermann, Ingo Molnar, linuxppc-dev, Steven Rostedt

On Mon, 2016-25-04 at 21:56:14 UTC, Thiago Jung Bauermann wrote:
> In the ppc64 big endian ABI, function symbols point to function
> descriptors. The symbols which point to the function entry points
> have a dot in front of the function name. Consequently, when the
> ftrace filter mechanism searches for the symbol corresponding to
> an entry point address, it gets the dot symbol.
...
> 
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
> Acked-by: Steven Rostedt <rostedt@goodmis.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/7132e2d669bd42c3783327f301

cheers

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

end of thread, other threads:[~2016-04-28 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-25 21:56 [PATCH v2] ftrace: Match dot symbols when searching functions on ppc64 Thiago Jung Bauermann
2016-04-26 13:36 ` Steven Rostedt
2016-04-28 14:22 ` [v2] " Michael Ellerman

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