Skip to content

Commit d899926

Browse files
frdesorostedt
authored andcommitted
selftest/ftrace: Move kprobe selftest function to separate compile unit
Move selftest function to its own compile unit so it can be compiled with the ftrace cflags (CC_FLAGS_FTRACE) allowing it to be probed during the ftrace startup tests. Link: http://lkml.kernel.org/r/153294604271.32740.16490677128630177030.stgit@devbox Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 45408c4 commit d899926

File tree

4 files changed

+23
-11
lines changed

4 files changed

+23
-11
lines changed

kernel/trace/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ obj-y += trace_selftest_dynamic.o
1313
endif
1414
endif
1515

16+
ifdef CONFIG_FTRACE_STARTUP_TEST
17+
CFLAGS_trace_kprobe_selftest.o = $(CC_FLAGS_FTRACE)
18+
obj-$(CONFIG_KPROBE_EVENTS) += trace_kprobe_selftest.o
19+
endif
20+
1621
# If unlikely tracing is enabled, do not trace these files
1722
ifdef CONFIG_TRACING_BRANCHES
1823
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING

kernel/trace/trace_kprobe.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/rculist.h>
2424
#include <linux/error-injection.h>
2525

26+
#include "trace_kprobe_selftest.h"
2627
#include "trace_probe.h"
2728

2829
#define KPROBE_EVENT_SYSTEM "kprobes"
@@ -1587,17 +1588,6 @@ fs_initcall(init_kprobe_trace);
15871588

15881589

15891590
#ifdef CONFIG_FTRACE_STARTUP_TEST
1590-
/*
1591-
* The "__used" keeps gcc from removing the function symbol
1592-
* from the kallsyms table. 'noinline' makes sure that there
1593-
* isn't an inlined version used by the test method below
1594-
*/
1595-
static __used __init noinline int
1596-
kprobe_trace_selftest_target(int a1, int a2, int a3, int a4, int a5, int a6)
1597-
{
1598-
return a1 + a2 + a3 + a4 + a5 + a6;
1599-
}
1600-
16011591
static __init struct trace_event_file *
16021592
find_trace_probe_file(struct trace_kprobe *tk, struct trace_array *tr)
16031593
{

kernel/trace/trace_kprobe_selftest.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Function used during the kprobe self test. This function is in a separate
4+
* compile unit so it can be compile with CC_FLAGS_FTRACE to ensure that it
5+
* can be probed by the selftests.
6+
*/
7+
int kprobe_trace_selftest_target(int a1, int a2, int a3, int a4, int a5, int a6)
8+
{
9+
return a1 + a2 + a3 + a4 + a5 + a6;
10+
}

kernel/trace/trace_kprobe_selftest.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Function used during the kprobe self test. This function is in a separate
4+
* compile unit so it can be compile with CC_FLAGS_FTRACE to ensure that it
5+
* can be probed by the selftests.
6+
*/
7+
int kprobe_trace_selftest_target(int a1, int a2, int a3, int a4, int a5, int a6);

0 commit comments

Comments
 (0)