Skip to content

Commit 893c6da

Browse files
olsajiriKernel Patches Daemon
authored andcommitted
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 <[email protected]>
1 parent 7989051 commit 893c6da

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

include/linux/ftrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ enum ftrace_ops_cmd {
403403
* Negative on failure. The return value is dependent on the
404404
* callback.
405405
*/
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);
407407

408408
#ifdef CONFIG_DYNAMIC_FTRACE
409409

kernel/bpf/trampoline.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static DEFINE_MUTEX(trampoline_mutex);
3333
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
3434
static int bpf_trampoline_update(struct bpf_trampoline *tr, bool lock_direct_mutex);
3535

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)
3738
{
3839
struct bpf_trampoline *tr = ops->private;
3940
int ret = 0;

kernel/trace/ftrace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,7 @@ static int __ftrace_hash_update_ipmodify(struct ftrace_ops *ops,
20492049
*/
20502050
if (!ops->ops_func)
20512051
return -EBUSY;
2052-
ret = ops->ops_func(ops, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF);
2052+
ret = ops->ops_func(ops, rec->ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF);
20532053
if (ret)
20542054
return ret;
20552055
} else if (is_ipmodify) {
@@ -8983,7 +8983,7 @@ static int prepare_direct_functions_for_ipmodify(struct ftrace_ops *ops)
89838983
if (!op->ops_func)
89848984
return -EBUSY;
89858985

8986-
ret = op->ops_func(op, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER);
8986+
ret = op->ops_func(op, ip, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER);
89878987
if (ret)
89888988
return ret;
89898989
}
@@ -9030,7 +9030,7 @@ static void cleanup_direct_functions_after_ipmodify(struct ftrace_ops *ops)
90309030

90319031
/* The cleanup is optional, ignore any errors */
90329032
if (found_op && op->ops_func)
9033-
op->ops_func(op, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER);
9033+
op->ops_func(op, ip, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER);
90349034
}
90359035
}
90369036
mutex_unlock(&direct_mutex);

0 commit comments

Comments
 (0)