* [PATCH v2] tracing: Fix oops caused by graph notrace filter
@ 2016-06-22 11:54 Chunyu Hu
2016-07-02 23:23 ` kbuild test robot
2016-07-02 23:24 ` kbuild test robot
0 siblings, 2 replies; 3+ messages in thread
From: Chunyu Hu @ 2016-06-22 11:54 UTC (permalink / raw)
To: rostedt; +Cc: linux-kernel
wakeup tracer can use function_graph trace when display_graph trace
option is setup by user via tracefs, and bypass the set_graph_function
and set_graph_notrace. But the bypass of set_graph_notrace is not clean.
Although wakeup_graph_entry does most of the bypass, and both the enry
and exit event will be submitted to the trace ring buffer, the ret_stack
index, which will be assigned to depth field of graph enrty event is not
handled. The issue is that the depth is used as the array index of
fgraph_cpu_data and can cause an oops when it's negative. irqsoff tracer
has same issue. To see the oops:
echo 1 > options/display_graph
echo schedule > set_graph_notrace
echo wakeup > current_tracer
cat trace
cat trace
Making ftrace_graph_notrace_addr always return false when tracers need
to bypass it is a proposed fix.
Signed-off-by: Chunyu Hu <chuhu@redhat.com>
---
kernel/trace/ftrace.c | 1 +
kernel/trace/trace.h | 4 ++++
kernel/trace/trace_functions_graph.c | 2 ++
kernel/trace/trace_irqsoff.c | 10 ++++++++++
kernel/trace/trace_sched_wakeup.c | 11 +++++++++++
5 files changed, 28 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index a680482..bb06828 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4471,6 +4471,7 @@ static DEFINE_MUTEX(graph_lock);
int ftrace_graph_count;
int ftrace_graph_notrace_count;
+int ftrace_graph_ignore_notrace;
unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly;
unsigned long ftrace_graph_notrace_funcs[FTRACE_GRAPH_MAX_FUNCS] __read_mostly;
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 5167c36..b089e04 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -757,6 +757,7 @@ extern void __trace_graph_return(struct trace_array *tr,
extern int ftrace_graph_count;
extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS];
extern int ftrace_graph_notrace_count;
+extern int ftrace_graph_ignore_notrace;
extern unsigned long ftrace_graph_notrace_funcs[FTRACE_GRAPH_MAX_FUNCS];
static inline int ftrace_graph_addr(unsigned long addr)
@@ -791,6 +792,9 @@ static inline int ftrace_graph_notrace_addr(unsigned long addr)
if (!ftrace_graph_notrace_count)
return 0;
+ if (unlikely(ftrace_graph_ignore_notrace))
+ return 0;
+
for (i = 0; i < ftrace_graph_notrace_count; i++) {
if (addr == ftrace_graph_notrace_funcs[i])
return 1;
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index 3a0244f..24d92f0 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -822,6 +822,8 @@ print_graph_entry_nested(struct trace_iterator *iter,
cpu_data = per_cpu_ptr(data->cpu_data, cpu);
cpu_data->depth = call->depth;
+ WARN(call->depth < 0, "call->depth = %d\n", call->depth);
+
/* Save this function pointer to see if the exit matches */
if (call->depth < FTRACE_RETFUNC_DEPTH)
cpu_data->enter_funcs[call->depth] = call->func;
diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 03cdff8..cb6ebcb 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -58,6 +58,7 @@ irq_trace(void)
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
static int irqsoff_display_graph(struct trace_array *tr, int set);
+extern int ftrace_graph_ignore_notrace;
# define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH)
#else
static inline int irqsoff_display_graph(struct trace_array *tr, int set)
@@ -629,6 +630,11 @@ static int __irqsoff_tracer_init(struct trace_array *tr)
ftrace_init_array_ops(tr, irqsoff_tracer_call);
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ /* bypass function_graph notrace filter */
+ ftrace_graph_ignore_notrace = 1;
+#endif
+
/* Only toplevel instance supports graph tracing */
if (start_irqsoff_tracer(tr, (tr->flags & TRACE_ARRAY_FL_GLOBAL &&
is_graph(tr))))
@@ -650,6 +656,10 @@ static void irqsoff_tracer_reset(struct trace_array *tr)
ftrace_reset_array_ops(tr);
irqsoff_busy = false;
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ ftrace_graph_ignore_notrace = 0;
+#endif
}
static void irqsoff_tracer_start(struct trace_array *tr)
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 9d4399b..d521e43 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -38,6 +38,7 @@ static void __wakeup_reset(struct trace_array *tr);
static int save_flags;
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+extern int ftrace_graph_ignore_notrace;
static int wakeup_display_graph(struct trace_array *tr, int set);
# define is_graph(tr) ((tr)->trace_flags & TRACE_ITER_DISPLAY_GRAPH)
#else
@@ -672,6 +673,12 @@ static int __wakeup_tracer_init(struct trace_array *tr)
tr->max_latency = 0;
wakeup_trace = tr;
ftrace_init_array_ops(tr, wakeup_tracer_call);
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ /* bypass function_graph notrace filter */
+ ftrace_graph_ignore_notrace = 1;
+#endif
+
start_wakeup_tracer(tr);
wakeup_busy = true;
@@ -721,6 +728,10 @@ static void wakeup_tracer_reset(struct trace_array *tr)
set_tracer_flag(tr, TRACE_ITER_OVERWRITE, overwrite_flag);
ftrace_reset_array_ops(tr);
wakeup_busy = false;
+
+#ifdef CONFIG_FUNCTION_GRAPH_TRACER
+ ftrace_graph_ignore_notrace = 0;
+#endif
}
static void wakeup_tracer_start(struct trace_array *tr)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tracing: Fix oops caused by graph notrace filter
2016-06-22 11:54 [PATCH v2] tracing: Fix oops caused by graph notrace filter Chunyu Hu
@ 2016-07-02 23:23 ` kbuild test robot
2016-07-02 23:24 ` kbuild test robot
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-07-02 23:23 UTC (permalink / raw)
To: Chunyu Hu; +Cc: kbuild-all, rostedt, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]
Hi,
[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.7-rc5 next-20160701]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Chunyu-Hu/tracing-Fix-oops-caused-by-graph-notrace-filter/20160622-195615
config: x86_64-randconfig-s4-07030618 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
kernel/built-in.o: In function `__irqsoff_tracer_init':
trace_irqsoff.c:(.text+0x85cbc): undefined reference to `ftrace_graph_ignore_notrace'
kernel/built-in.o: In function `irqsoff_tracer_reset':
trace_irqsoff.c:(.text+0x85daa): undefined reference to `ftrace_graph_ignore_notrace'
kernel/built-in.o: In function `__wakeup_tracer_init':
>> trace_sched_wakeup.c:(.text+0x866fe): undefined reference to `ftrace_graph_ignore_notrace'
kernel/built-in.o: In function `wakeup_tracer_reset':
trace_sched_wakeup.c:(.text+0x86bf2): undefined reference to `ftrace_graph_ignore_notrace'
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 24501 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] tracing: Fix oops caused by graph notrace filter
2016-06-22 11:54 [PATCH v2] tracing: Fix oops caused by graph notrace filter Chunyu Hu
2016-07-02 23:23 ` kbuild test robot
@ 2016-07-02 23:24 ` kbuild test robot
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-07-02 23:24 UTC (permalink / raw)
To: Chunyu Hu; +Cc: kbuild-all, rostedt, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1016 bytes --]
Hi,
[auto build test ERROR on tip/perf/core]
[also build test ERROR on v4.7-rc5 next-20160701]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Chunyu-Hu/tracing-Fix-oops-caused-by-graph-notrace-filter/20160622-195615
config: x86_64-randconfig-s0-07030621 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
kernel/built-in.o: In function `__irqsoff_tracer_init':
>> trace_irqsoff.c:(.text+0xd8a5f): undefined reference to `ftrace_graph_ignore_notrace'
kernel/built-in.o: In function `irqsoff_tracer_reset':
trace_irqsoff.c:(.text+0xd8b62): undefined reference to `ftrace_graph_ignore_notrace'
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 25578 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-02 23:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-22 11:54 [PATCH v2] tracing: Fix oops caused by graph notrace filter Chunyu Hu
2016-07-02 23:23 ` kbuild test robot
2016-07-02 23:24 ` kbuild test robot
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).