Skip to content

Commit 793a22e

Browse files
paulmckrcupaniakin-aws
authored andcommitted
ftrace: Use asynchronous grace period for register_ftrace_direct()
commit 33f1371 upstream. When running heavy test workloads with KASAN enabled, RCU Tasks grace periods can extend for many tens of seconds, significantly slowing trace registration. Therefore, make the registration-side RCU Tasks grace period be asynchronous via call_rcu_tasks(). Link: https://lore.kernel.org/linux-trace-kernel/ac05be77-2972-475b-9b57-56bef15aa00a@paulmck-laptop Reported-by: Jakub Kicinski <kuba@kernel.org> Reported-by: Alexei Starovoitov <ast@kernel.org> Reported-by: Chris Mason <clm@fb.com> Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org> Signed-off-by: Mahmoud Adam <mngyadam@amazon.com>
1 parent 8cb6e22 commit 793a22e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

kernel/trace/ftrace.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -5612,6 +5612,13 @@ static void remove_direct_functions_hash(struct ftrace_hash *hash, unsigned long
56125612
}
56135613
}
56145614

5615+
static void register_ftrace_direct_cb(struct rcu_head *rhp)
5616+
{
5617+
struct ftrace_hash *fhp = container_of(rhp, struct ftrace_hash, rcu);
5618+
5619+
free_ftrace_hash(fhp);
5620+
}
5621+
56155622
/**
56165623
* register_ftrace_direct_multi - Call a custom trampoline directly
56175624
* for multiple functions registered in @ops
@@ -5709,10 +5716,8 @@ int register_ftrace_direct_multi(struct ftrace_ops *ops, unsigned long addr)
57095716
out_unlock:
57105717
mutex_unlock(&direct_mutex);
57115718

5712-
if (free_hash && free_hash != EMPTY_HASH) {
5713-
synchronize_rcu_tasks();
5714-
free_ftrace_hash(free_hash);
5715-
}
5719+
if (free_hash && free_hash != EMPTY_HASH)
5720+
call_rcu_tasks(&free_hash->rcu, register_ftrace_direct_cb);
57165721

57175722
if (new_hash)
57185723
free_ftrace_hash(new_hash);

0 commit comments

Comments
 (0)