Re: [PATCH 2/9] ftrace: Add register_ftrace_direct_hash function
From: Jiri Olsa <hidden>
Date: 2025-09-24 14:37:07
Also in:
bpf, linux-arm-kernel, lkml
On Wed, Sep 24, 2025 at 05:04:15AM -0400, Steven Rostedt wrote:
On Tue, 23 Sep 2025 23:51:40 +0200 Jiri Olsa [off-list ref] wrote:quoted
Adding register_ftrace_direct_hash function that registers all entries (ip -> direct) provided in hash argument. The difference to current register_ftrace_direct is - hash argument that allows to register multiple ip -> direct entries at onceI'm a bit confused. How is this different? Doesn't register_ftrace_direct() register multiple ip -> direct entries at once too? But instead of using a passed in hash, it uses the hash from within the ftrace_ops.
right, but that assumes that we can touch the hash in ftrace_ops directly, but register_ftrace_direct_hash semantics is bit different, because it allows to register new (ip,addr) entries on already 'running' ftrace_ops, in which case you can't change the ftrace_ops hash directly
quoted
- we can call register_ftrace_direct_hash multiple times on the same ftrace_ops object, becase after first registration with register_ftrace_function_nolock, it uses ftrace_update_ops to update the ftrace_ops objectOK, I don't like the name "register" here. "register" should be for the first instance and then it is registered. If you call it multiple times on the same ops without "unregister" it should give an error. Perhaps call this "update_ftrace_direct()" where it can update a direct ftrace_ops from?
I agree the 'register' naming is confusing in here.. but we still need to use 3 functions for register/unregister/modify operations, so perhaps: update_ftrace_direct_add(ops, hash) update_ftrace_direct_del(ops, hash) update_ftrace_direct_mod(ops, hash) ?
quoted
This change will allow us to have simple ftrace_ops for all bpf direct interface users in following changes.After applying all the patches, I have this: $ git grep register_ftrace_direct_hash include/linux/ftrace.h:int register_ftrace_direct_hash(struct ftrace_ops *ops, struct ftrace_hash *hash); include/linux/ftrace.h:int unregister_ftrace_direct_hash(struct ftrace_ops *ops, struct ftrace_hash *hash); include/linux/ftrace.h:int register_ftrace_direct_hash(struct ftrace_ops *ops, struct ftrace_hash *hash) include/linux/ftrace.h:int unregister_ftrace_direct_hash(struct ftrace_ops *ops, struct ftrace_hash *hash) kernel/trace/ftrace.c: err = register_ftrace_direct_hash(ops, hash); kernel/trace/ftrace.c: err = unregister_ftrace_direct_hash(ops, hash); kernel/trace/ftrace.c:int register_ftrace_direct_hash(struct ftrace_ops *ops, struct ftrace_hash *hash) kernel/trace/ftrace.c:EXPORT_SYMBOL_GPL(register_ftrace_direct_hash); kernel/trace/ftrace.c:int unregister_ftrace_direct_hash(struct ftrace_ops *ops, struct ftrace_hash *hash) kernel/trace/ftrace.c:EXPORT_SYMBOL_GPL(unregister_ftrace_direct_hash); Where I do not see it is used outside of ftrace.c. Why is it exported?
I have bpf changes using this that I did not post yet, but even with that there's probably no reason to export this.. will remove thanks, jirka