ftrace: Use hash argument for tmp_ops in update_ftrace_direct_mod
Jiri Olsa
reviewerPATCH 1/1 ftrace: Use hash argument for tmp_ops in update_ftrace_direct_mod
The modify logic registers temporary ftrace_ops object (tmp_ops) to trigger the slow path for all direct callers to be able to safely modify attached addresses.
At the moment we use ops->func_hash for tmp_ops filter, which represents all the systems attachments. It's faster to use just the passed hash filter, which contains only the modified sites is always a subset of the ops->func_hash.
--- kernel/trace/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
@@ -6608,7 +6608,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b/* Enable the tmp_ops to have the same functions as the direct ops */ ftrace_ops_init (&tmp_ops); - tmp_ops.func_hash = ops->func_hash; + tmp_ops.func_hash->filter_hash = hash; err =register_ftrace_function_nolock (&tmp_ops);if (err)
Signature · 1 line
2.53.0
[email protected]
AI reviewThe comment above says "Enable the tmp_ops to have the same functions as the direct ops", but after this change tmp_ops only gets the modified subset via the hash argument, not all of the direct ops…
kernel/trace/ftrace.c int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b · line 6611
Quoted 10 lines
kernel/trace/ftrace.c +1
-1@@ -6608,7 +6608,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b/* Enable the tmp_ops to have the same functions as the direct ops */ ftrace_ops_init (&tmp_ops); - tmp_ops.func_hash = ops->func_hash; + tmp_ops.func_hash->filter_hash = hash;
The comment above says "Enable the tmp_ops to have the same functions as the direct ops", but after this change tmp_ops only gets the modified subset via the hash argument, not all of the direct ops functions. Should the comment be updated to reflect this?
Also, the commit message has a minor grammar issue:
Quoted 2 lines
which contains only the modified sites is always a subset of the
ops->func_hash.
Reads like it is missing an "and" between "sites" and "is".
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/23000924618
Quoted 16 lines · On Thu, Mar 12, 2026 at 12:24:24PM +0000, [email protected] wrote:
kernel/trace/ftrace.c int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b · line 6611
Quoted 10 lines
kernel/trace/ftrace.c +1
-1@@ -6608,7 +6608,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b/* Enable the tmp_ops to have the same functions as the direct ops */ ftrace_ops_init (&tmp_ops); - tmp_ops.func_hash = ops->func_hash; + tmp_ops.func_hash->filter_hash = hash;The comment above says "Enable the
tmp_opsto have the same functions as the direct ops", but after this changetmp_opsonly gets the modified subset via the hash argument, not all of the direct ops functions. Should the comment be updated to reflect this?
Quoted 6 lines
Also, the commit message has a minor grammar issue:
Quoted 2 lines
which contains only the modified sites is always a subset of the
ops->func_hash.Reads like it is missing an "and" between "sites" and "is".
yep, sent v2
jirka