mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Merge branch 'bpf-two-trampoline-cleanups'
Leon Hwang says: ==================== bpf: Two trampoline cleanups Split these two cleanups for trampoline from the series "[PATCH bpf-next v2 00/21] bpf: Add tracing_multi link support for bpf progs" [1]. Since the tr->ip is ftrace_location()-ed in bpf_trampoline_lookup(), no need to call ftrace_location(tr->ip) again in register/unregister/modify_fentry_multi(). Also no need to call ftrace_location() for the target addr in register_fentry(), when initialize ftrace_managed in bpf_trampoline_get(). Links: [1] https://lore.kernel.org/bpf/20261012154024.29423-1-leon.hwang@linux.dev/ ==================== Link: https://patch.msgid.link/20261016142014.12420-1-leon.hwang@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
aaae5e500a
|
|
@ -475,18 +475,11 @@ static int register_fentry(struct bpf_trampoline *tr, struct bpf_tramp_image *im
|
|||
void *data __maybe_unused)
|
||||
{
|
||||
void *new_addr = im->image;
|
||||
void *ip = tr->func.addr;
|
||||
unsigned long faddr;
|
||||
int ret;
|
||||
|
||||
faddr = ftrace_location((unsigned long)ip);
|
||||
if (faddr) {
|
||||
if (tr->func.ftrace_managed) {
|
||||
if (!tr->fops)
|
||||
return -ENOTSUPP;
|
||||
tr->func.ftrace_managed = true;
|
||||
}
|
||||
|
||||
if (tr->func.ftrace_managed) {
|
||||
ret = direct_ops_add(tr, new_addr);
|
||||
} else {
|
||||
ret = bpf_trampoline_update_fentry(tr, 0, NULL, new_addr);
|
||||
|
|
@ -1286,6 +1279,7 @@ struct bpf_trampoline *bpf_trampoline_get(u64 key,
|
|||
|
||||
memcpy(&tr->func.model, &tgt_info->fmodel, sizeof(tgt_info->fmodel));
|
||||
tr->func.addr = (void *)tgt_info->tgt_addr;
|
||||
tr->func.ftrace_managed = tr->ip != 0;
|
||||
out:
|
||||
trampoline_unlock(tr);
|
||||
return tr;
|
||||
|
|
@ -1635,8 +1629,8 @@ static void ftrace_hash_add(struct ftrace_hash *hash, struct ftrace_func_entry *
|
|||
static int register_fentry_multi(struct bpf_trampoline *tr, struct bpf_tramp_image *im, void *ptr)
|
||||
{
|
||||
unsigned long addr = (unsigned long) im->image;
|
||||
unsigned long ip = ftrace_location(tr->ip);
|
||||
struct bpf_tracing_multi_data *data = ptr;
|
||||
unsigned long ip = tr->ip;
|
||||
|
||||
/*
|
||||
* Different BTF ids get different trampolines, but they can still
|
||||
|
|
@ -1649,7 +1643,6 @@ static int register_fentry_multi(struct bpf_trampoline *tr, struct bpf_tramp_ima
|
|||
if (bpf_trampoline_use_jmp(tr->flags))
|
||||
addr = ftrace_jmp_set(addr);
|
||||
|
||||
tr->func.ftrace_managed = true;
|
||||
ftrace_hash_add(data->reg, data->entry, ip, addr);
|
||||
tr->cur_image = im;
|
||||
return 0;
|
||||
|
|
@ -1658,13 +1651,12 @@ static int register_fentry_multi(struct bpf_trampoline *tr, struct bpf_tramp_ima
|
|||
static int unregister_fentry_multi(struct bpf_trampoline *tr, u32 orig_flags, void *ptr)
|
||||
{
|
||||
unsigned long addr = (unsigned long) tr->cur_image->image;
|
||||
unsigned long ip = ftrace_location(tr->ip);
|
||||
struct bpf_tracing_multi_data *data = ptr;
|
||||
|
||||
if (bpf_trampoline_use_jmp(tr->flags))
|
||||
addr = ftrace_jmp_set(addr);
|
||||
|
||||
ftrace_hash_add(data->unreg, data->entry, ip, addr);
|
||||
ftrace_hash_add(data->unreg, data->entry, tr->ip, addr);
|
||||
tr->cur_image = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1673,13 +1665,12 @@ static int modify_fentry_multi(struct bpf_trampoline *tr, u32 orig_flags, struct
|
|||
bool lock_direct_mutex, void *ptr)
|
||||
{
|
||||
unsigned long addr = (unsigned long) im->image;
|
||||
unsigned long ip = ftrace_location(tr->ip);
|
||||
struct bpf_tracing_multi_data *data = ptr;
|
||||
|
||||
if (bpf_trampoline_use_jmp(tr->flags))
|
||||
addr = ftrace_jmp_set(addr);
|
||||
|
||||
ftrace_hash_add(data->modify, data->entry, ip, addr);
|
||||
ftrace_hash_add(data->modify, data->entry, tr->ip, addr);
|
||||
tr->cur_image = im;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user