Skip to content

Commit e30dd21

Browse files
committed
Merge tag 'ftrace-v6.13-rc5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull ftrace fixes from Steven Rostedt: - Add needed READ_ONCE() around access to the fgraph array element The updates to the fgraph array can happen when callbacks are registered and unregistered. The __ftrace_return_to_handler() can handle reading either the old value or the new value. But once it reads that value it must stay consistent otherwise the check that looks to see if the value is a stub may show false, but if the compiler decides to re-read after that check, it can be true which can cause the code to crash later on. - Make function profiler use the top level ops for filtering again When function graph became available for instances, its filter ops became independent from the top level set_ftrace_filter. In the process the function profiler received its own filter ops as well. But the function profiler uses the top level set_ftrace_filter file and does not have one of its own. In giving it its own filter ops, it lost any user interface it once had. Make it use the top level set_ftrace_filter file again. This fixes a regression. * tag 'ftrace-v6.13-rc5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: ftrace: Fix function profiler's filtering functionality fgraph: Add READ_ONCE() when accessing fgraph_array[]
2 parents 0bc21e7 + 789a8cf commit e30dd21

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

kernel/trace/fgraph.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ static unsigned long __ftrace_return_to_handler(struct fgraph_ret_regs *ret_regs
833833
#endif
834834
{
835835
for_each_set_bit(i, &bitmap, sizeof(bitmap) * BITS_PER_BYTE) {
836-
struct fgraph_ops *gops = fgraph_array[i];
836+
struct fgraph_ops *gops = READ_ONCE(fgraph_array[i]);
837837

838838
if (gops == &fgraph_stub)
839839
continue;

kernel/trace/ftrace.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -902,16 +902,13 @@ static void profile_graph_return(struct ftrace_graph_ret *trace,
902902
}
903903

904904
static struct fgraph_ops fprofiler_ops = {
905-
.ops = {
906-
.flags = FTRACE_OPS_FL_INITIALIZED,
907-
INIT_OPS_HASH(fprofiler_ops.ops)
908-
},
909905
.entryfunc = &profile_graph_entry,
910906
.retfunc = &profile_graph_return,
911907
};
912908

913909
static int register_ftrace_profiler(void)
914910
{
911+
ftrace_ops_set_global_filter(&fprofiler_ops.ops);
915912
return register_ftrace_graph(&fprofiler_ops);
916913
}
917914

@@ -922,12 +919,11 @@ static void unregister_ftrace_profiler(void)
922919
#else
923920
static struct ftrace_ops ftrace_profile_ops __read_mostly = {
924921
.func = function_profile_call,
925-
.flags = FTRACE_OPS_FL_INITIALIZED,
926-
INIT_OPS_HASH(ftrace_profile_ops)
927922
};
928923

929924
static int register_ftrace_profiler(void)
930925
{
926+
ftrace_ops_set_global_filter(&ftrace_profile_ops);
931927
return register_ftrace_function(&ftrace_profile_ops);
932928
}
933929

0 commit comments

Comments
 (0)