mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
To: <linux-kernel@vger.kernel.org>
Cc: <linux-api@vger.kernel.org>, <luto@amacapital.net>,
	<rostedt@goodmis.org>,
	Marcin Nowakowski <marcin.nowakowski@imgtec.com>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: [PATCH v4 03/12] tracing/syscalls: drop arch_syscall_match_sym_name
Date: Fri, 14 Oct 2016 10:35:05 +0200	[thread overview]
Message-ID: <1476434115-25428-4-git-send-email-marcin.nowakowski@imgtec.com> (raw)
In-Reply-To: <1476434115-25428-1-git-send-email-marcin.nowakowski@imgtec.com>

arch_syscall_match_sym_name has been previously added to allow arch to
override syscall_match_sym_name method, but only ppc arch implements it
and the only difference made is that a prefix is longer. This can be
simplified by using a #define specifying the prefix length difference
for a given arch.
Next commit will make syscall_match_sym_name implementation a bit
larger, so clean it up now to avoid further patching arch code whenever
the core method changes.

Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 Documentation/trace/ftrace-design.txt |  4 ----
 arch/powerpc/include/asm/ftrace.h     | 15 ++-------------
 kernel/trace/trace_syscalls.c         | 14 ++++++++------
 3 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index a273dd0..c30608e 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -237,10 +237,6 @@ You need very few things to get the syscalls tracing in an arch.
 - If the system call table on this arch is more complicated than a simple array
   of addresses of the system calls, implement an arch_syscall_addr to return
   the address of a given system call.
-- If the symbol names of the system calls do not match the function names on
-  this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and
-  implement arch_syscall_match_sym_name with the appropriate logic to return
-  true if the function name corresponds with the symbol name.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index 686c5f7..f266051 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -67,20 +67,9 @@ struct dyn_arch_ftrace {
 #endif
 #endif
 
-#if defined(CONFIG_FTRACE_SYSCALLS) && !defined(__ASSEMBLY__)
 #ifdef PPC64_ELF_ABI_v1
-#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
-static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
-{
-	/*
-	 * Compare the symbol name with the system call name. Skip the .sys or .SyS
-	 * prefix from the symbol name and the sys prefix from the system call name and
-	 * just match the rest. This is only needed on ppc64 since symbol names on
-	 * 32bit do not start with a period so the generic function will work.
-	 */
-	return !strcmp(sym + 4, name + 3);
-}
+/* On ppc64 ABIv1 (BE) we have to skip the leading '.' in the symbol name */
+#define ARCH_SYM_NAME_SKIP_CHARS 1
 #endif
-#endif /* CONFIG_FTRACE_SYSCALLS && !__ASSEMBLY__ */
 
 #endif /* _ASM_POWERPC_FTRACE */
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 9065db3..707a57c 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -31,8 +31,11 @@ extern struct syscall_metadata *__stop_syscalls_metadata[];
 
 static struct syscall_metadata **syscalls_metadata;
 
-#ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME
-static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+#ifndef ARCH_SYM_NAME_SKIP_CHARS
+#define ARCH_SYM_NAME_SKIP_CHARS 0
+#endif
+
+static inline bool syscall_match_sym_name(const char *sym, const char *name)
 {
 	/*
 	 * Only compare after the "sys" prefix. Archs that use
@@ -40,9 +43,8 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
 	 * with ".SyS" or ".sys" instead of "sys", leading to an unwanted
 	 * mismatch.
 	 */
-	return !strcmp(sym + 3, name + 3);
+	return !strcmp(sym + 3 + ARCH_SYM_NAME_SKIP_CHARS, name + 3);
 }
-#endif
 
 #ifdef ARCH_COMPAT_SYSCALL_NUMBERS_OVERLAP
 /*
@@ -86,11 +88,11 @@ find_syscall_meta(unsigned long syscall)
 	stop = __stop_syscalls_metadata;
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
-	if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))
+	if (syscall_match_sym_name(str, "sys_ni_syscall"))
 		return NULL;
 
 	for ( ; start < stop; start++) {
-		if ((*start)->name && arch_syscall_match_sym_name(str, (*start)->name))
+		if ((*start)->name && syscall_match_sym_name(str, (*start)->name))
 			return *start;
 	}
 	return NULL;
-- 
2.7.4

  parent reply	other threads:[~2016-10-14  8:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14  8:35 [PATCH v4 00/12] syscall/tracing: compat syscall support Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 01/12] tracing/syscalls: remove syscall_nr from syscall metadata Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 02/12] tracing/syscalls: add handling for compat tasks Marcin Nowakowski
2016-10-14  8:35 ` Marcin Nowakowski [this message]
2016-10-14  8:35 ` [PATCH v4 04/12] tracing/syscalls: add compat syscall metadata Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 05/12] syscall/tracing: allow arch to override syscall_get_nr for ftrace Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 05/12] tracing/syscalls: " Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 06/12] x86/tracing: fix compat syscall handling Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 07/12] s390/tracing: " Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 08/12] arm64/tracing: " Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 09/12] powerpc/tracing: " Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 10/12] tile/tracing: " Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 11/12] sparc/tracing: " Marcin Nowakowski
2016-10-14  8:35 ` [PATCH v4 12/12] parisc/tracing: " Marcin Nowakowski

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=1476434115-25428-4-git-send-email-marcin.nowakowski@imgtec.com \
    --to=marcin.nowakowski@imgtec.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mpe@ellerman.id.au \
    --cc=rostedt@goodmis.org \
    /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®