Skip to content

Commit 0771cee

Browse files
committed
Merge tag 'ftrace-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull ftrace updates from Steven Rostedt: - Fix regression of pid filtering of function graph tracer When the function graph tracer allowed multiple instances of graph tracing using subops, the filtering by pid broke. The ftrace_ops->private that was used for pid filtering wasn't updated on creation. The wrong function entry callback was used when pid filtering was enabled when the function graph tracer started, which meant that the pid filtering wasn't happening. - Remove no longer needed ftrace_trace_task() With PID filtering working via ftrace_pids_enabled() and fgraph_pid_func(), the coarse-grained ftrace_trace_task() check in graph_entry() is obsolete. It was only a fallback for uninitialized op->private (now fixed), and its removal ensures consistent PID filtering with standard function tracing. * tag 'ftrace-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: fgraph: Remove coarse PID filtering from graph_entry() fgraph: Check ftrace_pids_enabled on registration for early filtering fgraph: Initialize ftrace_ops->private for function graph ops
2 parents 69c5079 + c264534 commit 0771cee

3 files changed

Lines changed: 8 additions & 14 deletions

File tree

kernel/trace/fgraph.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,7 @@ void fgraph_init_ops(struct ftrace_ops *dst_ops,
10161016
mutex_init(&dst_ops->local_hash.regex_lock);
10171017
INIT_LIST_HEAD(&dst_ops->subop_list);
10181018
dst_ops->flags |= FTRACE_OPS_FL_INITIALIZED;
1019+
dst_ops->private = src_ops->private;
10191020
}
10201021
#endif
10211022
}
@@ -1368,6 +1369,13 @@ int register_ftrace_graph(struct fgraph_ops *gops)
13681369

13691370
ftrace_graph_active++;
13701371

1372+
/* Always save the function, and reset at unregistering */
1373+
gops->saved_func = gops->entryfunc;
1374+
#ifdef CONFIG_DYNAMIC_FTRACE
1375+
if (ftrace_pids_enabled(&gops->ops))
1376+
gops->entryfunc = fgraph_pid_func;
1377+
#endif
1378+
13711379
if (ftrace_graph_active == 2)
13721380
ftrace_graph_disable_direct(true);
13731381

@@ -1387,8 +1395,6 @@ int register_ftrace_graph(struct fgraph_ops *gops)
13871395
} else {
13881396
init_task_vars(gops->idx);
13891397
}
1390-
/* Always save the function, and reset at unregistering */
1391-
gops->saved_func = gops->entryfunc;
13921398

13931399
gops->ops.flags |= FTRACE_OPS_FL_GRAPH;
13941400

kernel/trace/trace.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,11 +1162,6 @@ struct ftrace_func_command {
11621162
char *params, int enable);
11631163
};
11641164
extern bool ftrace_filter_param __initdata;
1165-
static inline int ftrace_trace_task(struct trace_array *tr)
1166-
{
1167-
return this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid) !=
1168-
FTRACE_PID_IGNORE;
1169-
}
11701165
extern int ftrace_is_dead(void);
11711166
int ftrace_create_function_files(struct trace_array *tr,
11721167
struct dentry *parent);
@@ -1184,10 +1179,6 @@ void ftrace_clear_pids(struct trace_array *tr);
11841179
int init_function_trace(void);
11851180
void ftrace_pid_follow_fork(struct trace_array *tr, bool enable);
11861181
#else
1187-
static inline int ftrace_trace_task(struct trace_array *tr)
1188-
{
1189-
return 1;
1190-
}
11911182
static inline int ftrace_is_dead(void) { return 0; }
11921183
static inline int
11931184
ftrace_create_function_files(struct trace_array *tr,

kernel/trace/trace_functions_graph.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,6 @@ static int graph_entry(struct ftrace_graph_ent *trace,
251251
return 1;
252252
}
253253

254-
if (!ftrace_trace_task(tr))
255-
return 0;
256-
257254
if (ftrace_graph_ignore_func(gops, trace))
258255
return 0;
259256

0 commit comments

Comments
 (0)