]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ftrace: Factor ftrace_ops ops_func interface
authorJiri Olsa <jolsa@kernel.org>
Tue, 30 Dec 2025 14:50:09 +0000 (15:50 +0100)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 28 Jan 2026 19:44:57 +0000 (11:44 -0800)
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
include/linux/ftrace.h
kernel/bpf/trampoline.c
kernel/trace/ftrace.c

index b8461e541b9dde0e78fe55e85747b9e528d6e4f0..705db0a6d995a3d9806745f352d03c258a53d553 100644 (file)
@@ -403,7 +403,7 @@ enum ftrace_ops_cmd {
  *        Negative on failure. The return value is dependent on the
  *        callback.
  */
-typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, enum ftrace_ops_cmd cmd);
+typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, unsigned long ip, enum ftrace_ops_cmd cmd);
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 
index 1d4f618c2402b4e2e24c7a9d8d0abd9b5a59d8b9..64556aa0007b09ef47c777a9220c38ee049a70eb 100644 (file)
@@ -33,7 +33,8 @@ static DEFINE_MUTEX(trampoline_mutex);
 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
 static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mutex);
 
-static int bpf_tramp_ftrace_ops_func(struct ftrace_ops *ops, enum ftrace_ops_cmd cmd)
+static int bpf_tramp_ftrace_ops_func(struct ftrace_ops *ops, unsigned long ip,
+                                    enum ftrace_ops_cmd cmd)
 {
        struct bpf_trampoline *tr = ops->private;
        int ret = 0;
index 794ab5e22398ab9c2a93a513cc2a8c5ea9eaf113..ee2d7b8a43724dbf1bffdd73d29f0b266fb08ca7 100644 (file)
@@ -2075,7 +2075,7 @@ static int __ftrace_hash_update_ipmodify(struct ftrace_ops *ops,
                                 */
                                if (!ops->ops_func)
                                        return -EBUSY;
-                               ret = ops->ops_func(ops, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF);
+                               ret = ops->ops_func(ops, rec->ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF);
                                if (ret)
                                        return ret;
                        } else if (is_ipmodify) {
@@ -9061,7 +9061,7 @@ static int prepare_direct_functions_for_ipmodify(struct ftrace_ops *ops)
                                if (!op->ops_func)
                                        return -EBUSY;
 
-                               ret = op->ops_func(op, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER);
+                               ret = op->ops_func(op, ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER);
                                if (ret)
                                        return ret;
                        }
@@ -9108,7 +9108,7 @@ static void cleanup_direct_functions_after_ipmodify(struct ftrace_ops *ops)
 
                        /* The cleanup is optional, ignore any errors */
                        if (found_op && op->ops_func)
-                               op->ops_func(op, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER);
+                               op->ops_func(op, ip, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER);
                }
        }
        mutex_unlock(&direct_mutex);