Skip to content

Commit b842148

Browse files
committed
function_graph: Move graph notrace bit to shadow stack global var
The use of the task->trace_recursion for the logic used for the function graph no-trace was a bit of an abuse of that variable. Now that there exists global vars that are per stack for registered graph traces, use that instead. Link: https://lore.kernel.org/linux-trace-kernel/171509107907.162236.6564679266777519065.stgit@devnote2 Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Mark Rutland <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Florent Revest <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: bpf <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Alan Maguire <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Guo Ren <[email protected]> Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 068da09 commit b842148

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

include/linux/trace_recursion.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ enum {
4444
*/
4545
TRACE_IRQ_BIT,
4646

47-
/*
48-
* To implement set_graph_notrace, if this bit is set, we ignore
49-
* function graph tracing of called functions, until the return
50-
* function is called to clear it.
51-
*/
52-
TRACE_GRAPH_NOTRACE_BIT,
53-
5447
/* Used to prevent recursion recording from recursing. */
5548
TRACE_RECORD_RECURSION_BIT,
5649
};

kernel/trace/trace.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,17 @@ enum {
919919

920920
TRACE_GRAPH_DEPTH_START_BIT,
921921
TRACE_GRAPH_DEPTH_END_BIT,
922+
923+
/*
924+
* To implement set_graph_notrace, if this bit is set, we ignore
925+
* function graph tracing of called functions, until the return
926+
* function is called to clear it.
927+
*/
928+
TRACE_GRAPH_NOTRACE_BIT,
922929
};
923930

931+
#define TRACE_GRAPH_NOTRACE (1 << TRACE_GRAPH_NOTRACE_BIT)
932+
924933
static inline unsigned long ftrace_graph_depth(unsigned long *task_var)
925934
{
926935
return (*task_var >> TRACE_GRAPH_DEPTH_START_BIT) & 3;

kernel/trace/trace_functions_graph.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ static inline int ftrace_graph_ignore_irqs(void)
130130
int trace_graph_entry(struct ftrace_graph_ent *trace,
131131
struct fgraph_ops *gops)
132132
{
133+
unsigned long *task_var = fgraph_get_task_var(gops);
133134
struct trace_array *tr = gops->private;
134135
struct trace_array_cpu *data;
135136
unsigned long flags;
@@ -138,7 +139,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace,
138139
int ret;
139140
int cpu;
140141

141-
if (trace_recursion_test(TRACE_GRAPH_NOTRACE_BIT))
142+
if (*task_var & TRACE_GRAPH_NOTRACE)
142143
return 0;
143144

144145
/*
@@ -149,7 +150,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace,
149150
* returning from the function.
150151
*/
151152
if (ftrace_graph_notrace_addr(trace->func)) {
152-
trace_recursion_set(TRACE_GRAPH_NOTRACE_BIT);
153+
*task_var |= TRACE_GRAPH_NOTRACE_BIT;
153154
/*
154155
* Need to return 1 to have the return called
155156
* that will clear the NOTRACE bit.
@@ -240,6 +241,7 @@ void __trace_graph_return(struct trace_array *tr,
240241
void trace_graph_return(struct ftrace_graph_ret *trace,
241242
struct fgraph_ops *gops)
242243
{
244+
unsigned long *task_var = fgraph_get_task_var(gops);
243245
struct trace_array *tr = gops->private;
244246
struct trace_array_cpu *data;
245247
unsigned long flags;
@@ -249,8 +251,8 @@ void trace_graph_return(struct ftrace_graph_ret *trace,
249251

250252
ftrace_graph_addr_finish(gops, trace);
251253

252-
if (trace_recursion_test(TRACE_GRAPH_NOTRACE_BIT)) {
253-
trace_recursion_clear(TRACE_GRAPH_NOTRACE_BIT);
254+
if (*task_var & TRACE_GRAPH_NOTRACE) {
255+
*task_var &= ~TRACE_GRAPH_NOTRACE;
254256
return;
255257
}
256258

0 commit comments

Comments
 (0)