Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ftrace: Factor ftrace_ops ops_func interface

We are going to remove "ftrace_ops->private == bpf_trampoline" setup
in following changes.

Adding ip argument to ftrace_ops_func_t callback function, so we can
use it to look up the trampoline.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/bpf/20251230145010.103439-9-jolsa@kernel.org

authored by

Jiri Olsa and committed by
Andrii Nakryiko
956747ef 7d045249

+6 -5
+1 -1
include/linux/ftrace.h
··· 403 403 * Negative on failure. The return value is dependent on the 404 404 * callback. 405 405 */ 406 - typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, enum ftrace_ops_cmd cmd); 406 + typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, unsigned long ip, enum ftrace_ops_cmd cmd); 407 407 408 408 #ifdef CONFIG_DYNAMIC_FTRACE 409 409
+2 -1
kernel/bpf/trampoline.c
··· 33 33 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 34 34 static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mutex); 35 35 36 - static int bpf_tramp_ftrace_ops_func(struct ftrace_ops *ops, enum ftrace_ops_cmd cmd) 36 + static int bpf_tramp_ftrace_ops_func(struct ftrace_ops *ops, unsigned long ip, 37 + enum ftrace_ops_cmd cmd) 37 38 { 38 39 struct bpf_trampoline *tr = ops->private; 39 40 int ret = 0;
+3 -3
kernel/trace/ftrace.c
··· 2075 2075 */ 2076 2076 if (!ops->ops_func) 2077 2077 return -EBUSY; 2078 - ret = ops->ops_func(ops, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF); 2078 + ret = ops->ops_func(ops, rec->ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF); 2079 2079 if (ret) 2080 2080 return ret; 2081 2081 } else if (is_ipmodify) { ··· 9061 9061 if (!op->ops_func) 9062 9062 return -EBUSY; 9063 9063 9064 - ret = op->ops_func(op, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER); 9064 + ret = op->ops_func(op, ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER); 9065 9065 if (ret) 9066 9066 return ret; 9067 9067 } ··· 9108 9108 9109 9109 /* The cleanup is optional, ignore any errors */ 9110 9110 if (found_op && op->ops_func) 9111 - op->ops_func(op, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER); 9111 + op->ops_func(op, ip, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER); 9112 9112 } 9113 9113 } 9114 9114 mutex_unlock(&direct_mutex);