Skip to contentSkip to conversation

File not found: /sys/kernel/debug/tracing/events/syscalls

PATCH Superseded Naresh Kamboju 6 participants 15 messages Nov 27, 2018 – Nov 29, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

While debugging the selftests/bpf: get_cgroup_id_user test failure on arm64 where the test is expecting trace file /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id but this path not enabled after enabling required kernel configuration also. CONFIG_FTRACE_SYSCALLS=y

strace output:
open(\"/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id\", O_RDONLY) = -1 ENOENT (No such file or directory)

This problem noticed on Linux mainline kernel version 4.20.0-rc3.

Best regards
Naresh Kamboju

#1 lore raw

Hi,

I found that the commit 4378a7d4be30 ("arm64: implement syscall wrappers") changed
the syscall wrapper function names by adding __arm64_ prefix. So arm64 kernel should
have its own arch_syscall_match_sym_name().

Thank you,

2018年11月28日(水) 0:22 Naresh Kamboju <[email protected]>:

Quoted 15 lines

While debugging the selftests/bpf: get_cgroup_id_user test failure on arm64 where the test is expecting trace file /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id but this path not enabled after enabling required kernel configuration also. CONFIG_FTRACE_SYSCALLS=y

strace output:
open(\"/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id\", O_RDONLY) = -1 ENOENT (No such file or directory)

This problem noticed on Linux mainline kernel version 4.20.0-rc3.

Best regards
Naresh Kamboju

Signature · 1 line
Masami Hiramatsu
maintainer
#2 lore raw

PATCH 1/1 arm64: ftrace: Fix to enable syscall events on arm64

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

Fixes 4378a7d4be30 ("arm64: implement syscall wrappers")
---
 arch/arm64/include/asm/ftrace.h |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/include/asm/ftrace.h +9 -0
index caa955f10e19..a710f79db442 100644
@@ -56,6 +56,15 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
 {
 	return is_compat_task();
 }
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+					       const char *name)
+{
+	/* Since all syscall functions have __arm64_ prefix, we must skip it */
+	return !strcmp(sym + 8, name);
+}
 #endif /* ifndef __ASSEMBLY__ */
 
 #endif /* __ASM_FTRACE_H */
maintainer Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 11 lines · On Wed, 28 Nov 2018 01:29:45 +0900 Masami Hiramatsu <[email protected]> wrote:

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

-- Steve

Quoted 28 lines
Fixes 4378a7d4be30 ("arm64: implement syscall wrappers")
---
 arch/arm64/include/asm/ftrace.h |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/include/asm/ftrace.h +9 -0
index caa955f10e19..a710f79db442 100644
@@ -56,6 +56,15 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
 {
 	return is_compat_task();
 }
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+					       const char *name)
+{
+	/* Since all syscall functions have __arm64_ prefix, we must skip it */
+	return !strcmp(sym + 8, name);
+}
 #endif /* ifndef __ASSEMBLY__ */
 
 #endif /* __ASM_FTRACE_H */
#4 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

In reply to Masami Hiramatsu

Hi Masami,

Quoted 26 lines · Masami Hiramatsu

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

Fixes 4378a7d4be30 ("arm64: implement syscall wrappers")
---
 arch/arm64/include/asm/ftrace.h |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/include/asm/ftrace.h +0 -0
index caa955f10e19..a710f79db442 100644
@@ -56,6 +56,15 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
 {
 	return is_compat_task();

arch/arm64/include/asm/ftrace.h static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) · line 67

Quoted 10 lines
arch/arm64/include/asm/ftrace.h +9 -0
 }
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+					       const char *name)
+{
+	/* Since all syscall functions have __arm64_ prefix, we must skip it */
+	return !strcmp(sym + 8, name);
+}

This looks fine to me, but I'm curious about whether this is supposed to work with compat syscalls as well, where the prefix is "__arm64_compat_".

If we broadly follow the x86 lead, we'd have:

	return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
		(!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));

Do we need to handle compat (i.e. 32-bit) tasks here?

Will

maintainer
#5 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 9 lines · On Tue, 27 Nov 2018 16:58:49 +0000 Will Deacon <[email protected]> wrote:

This looks fine to me, but I'm curious about whether this is supposed to work with compat syscalls as well, where the prefix is "__arm64_compat_".

If we broadly follow the x86 lead, we'd have:

	return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
		(!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));

Do we need to handle compat (i.e. 32-bit) tasks here?

Only if you want to trace compat syscalls as well ;-)

-- Steve

maintainer
#6 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Hi Will,

Quoted 6 lines · On Tue, 27 Nov 2018 13:18:59 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Tue, 27 Nov 2018 16:58:49 +0000 Will Deacon <[email protected]> wrote:

This looks fine to me, but I'm curious about whether this is supposed to work with compat syscalls as well, where the prefix is "__arm64_compat_".

Quoted 8 lines
Quoted 6 lines

If we broadly follow the x86 lead, we'd have:

	return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
		(!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));

Do we need to handle compat (i.e. 32-bit) tasks here?

Only if you want to trace compat syscalls as well ;-)

Actually I thought about that, but I found below comment in arch/arm64/include/asm/ftrace.h

* Because AArch32 mode does not share the same syscall table with AArch64,
* tracing compat syscalls may result in reporting bogus syscalls or even
* hang-up, so just do not trace them.

That's why I dropped compat syscall support.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
Acked-by
#7 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Hi Masami,

Quoted 18 lines · Masami Hiramatsu
Quoted 6 lines · On Tue, 27 Nov 2018 13:18:59 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 3 lines · On Tue, 27 Nov 2018 16:58:49 +0000 Will Deacon <[email protected]> wrote:

This looks fine to me, but I'm curious about whether this is supposed to work with compat syscalls as well, where the prefix is "__arm64_compat_".

Quoted 8 lines
Quoted 6 lines

If we broadly follow the x86 lead, we'd have:

	return (!strncmp(sym, "__arm64_", 8) && !strcmp(sym + 8, name)) ||
		(!strncmp(sym, "__arm64_compat_", 15) && !strcmp(sym + 15, name));

Do we need to handle compat (i.e. 32-bit) tasks here?

Only if you want to trace compat syscalls as well ;-)

Quoted 8 lines

Actually I thought about that, but I found below comment in arch/arm64/include/asm/ftrace.h

* Because AArch32 mode does not share the same syscall table with AArch64,
* tracing compat syscalls may result in reporting bogus syscalls or even
* hang-up, so just do not trace them.

That's why I dropped compat syscall support.

Ok! Then please add a comment to arch_syscall_match_sym_name() along those lines, and you can add my ack:

Thanks,

Will

maintainer
#8 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 4 lines · On Wed, 28 Nov 2018 12:05:02 +0000 Will Deacon <[email protected]> wrote:

Ok! Then please add a comment to arch_syscall_match_sym_name() along those lines, and you can add my ack:

Shouldn't this go through your tree?

-- Steve

#9 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 9 lines · Steven Rostedt
Quoted 4 lines · On Wed, 28 Nov 2018 12:05:02 +0000 Will Deacon <[email protected]> wrote:

Ok! Then please add a comment to arch_syscall_match_sym_name() along those lines, and you can add my ack:

Shouldn't this go through your tree?

Yup; I'm hoping Catalin will pick it up as a fix for 4.20 (we take it in turns, so I'm looking at stuff for 4.21 atm).

Will

maintainer
#10 lore raw

Re: [PATCH] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 7 lines · On Wed, 28 Nov 2018 19:59:22 +0000 Will Deacon <[email protected]> wrote:
Quoted 6 lines · Steven Rostedt
Quoted 3 lines · On Wed, 28 Nov 2018 12:05:02 +0000 Will Deacon <[email protected]> wrote:

Ok! Then please add a comment to arch_syscall_match_sym_name() along those lines, and you can add my ack:

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Shouldn't this go through your tree?

Yup; I'm hoping Catalin will pick it up as a fix for 4.20 (we take it in turns, so I'm looking at stuff for 4.21 atm).

OK, I'll add a comment about compat syscalls. BTW, this should be applied to 4.19 too, since without this, no one can use syscall events on arm64.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#11 lore raw

PATCH v2 1/1 arm64: ftrace: Fix to enable syscall events on arm64

In reply to Will Deacon

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

---
 arch/arm64/include/asm/ftrace.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm64/include/asm/ftrace.h +13 -0
index caa955f10e19..fac54fb050d0 100644
@@ -56,6 +56,19 @@ static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
 {
 	return is_compat_task();
 }
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+					       const char *name)
+{
+	/*
+	 * Since all syscall functions have __arm64_ prefix, we must skip it.
+	 * However, as we described above, we decided to ignore compat
+	 * syscalls, so we don't care about __arm64_compat_ prefix here.
+	 */
+	return !strcmp(sym + 8, name);
+}
 #endif /* ifndef __ASSEMBLY__ */
 
 #endif /* __ASM_FTRACE_H */
maintainer Applied
#12 lore raw

Re: [PATCH v2] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 11 lines · Masami Hiramatsu

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

Quoted 6 lines

Queued for 4.20. Thanks.

Signature · 1 line
Catalin
maintainer
#13 lore raw

Re: [PATCH v2] arm64: ftrace: Fix to enable syscall events on arm64

Quoted 12 lines · On Thu, 29 Nov 2018 16:53:30 +0000 Catalin Marinas <[email protected]>…
Quoted 11 lines · Masami Hiramatsu

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

Quoted 8 lines
Quoted 6 lines

Queued for 4.20. Thanks.

Thank you Catalin!

Quoted 3 lines
Signature · 2 lines
-- 
Catalin
Signature · 1 line
Masami Hiramatsu <[email protected]>
author Tested-by
#14 lore raw
In reply to Masami Hiramatsu

Hi Masami San,

Thanks for the patch it solved the problem.

Quoted 8 lines · Masami Hiramatsu

Hi,

I found that the commit 4378a7d4be30 ("arm64: implement syscall wrappers") changed
the syscall wrapper function names by adding __arm64_ prefix. So arm64 kernel should
have its own arch_syscall_match_sym_name().

arm64: ftrace: Fix to enable syscall events on arm64

From: Masami Hiramatsu <[email protected]>

Since commit 4378a7d4be30 ("arm64: implement syscall wrappers") introduced "__arm64_" prefix to all syscall wrapper symbols in sys_call_table, syscall tracer can not find corresponding metadata from syscall name. In the result, we have no syscall ftrace events on arm64 kernel, and some bpf testcases are failed on arm64.

To fix this issue, this introduces custom arch_syscall_match_sym_name() which skips first 8 bytes when comparing the syscall and symbol names.

Fixes 4378a7d4be30 ("arm64: implement syscall wrappers")
---
 arch/arm64/include/asm/ftrace.h |    9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm64/include/asm/ftrace.h +0 -0
index caa955f10e19..a710f79db442 100644
@@ -56,6 +56,15 @@ static inline bool

arch_trace_is_compat_syscall(struct pt_regs *regs)
{
return is_compat_task();
}
+
+#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
+
+static inline bool arch_syscall_match_sym_name(const char *sym,
+ const char *name)
+{
+ /* Since all syscall functions have __arm64_ prefix, we must skip it */
+ return !strcmp(sym + 8, name);
+}
#endif /* ifndef __ASSEMBLY__ */

#endif /* __ASM_FTRACE_H */

Quoted 24 lines

Thank you,

2018年11月28日(水) 0:22 Naresh Kamboju <[email protected]>:

Quoted 7 lines

While debugging the selftests/bpf: get_cgroup_id_user test failure on arm64 where the test is expecting trace file /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id but this path not enabled after enabling required kernel configuration also. CONFIG_FTRACE_SYSCALLS=y

Quoted 8 lines

strace output:
open(\"/sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id\", O_RDONLY) = -1 ENOENT (No such file or directory)

This problem noticed on Linux mainline kernel version 4.20.0-rc3.

Best regards
Naresh Kamboju

--
Masami Hiramatsu