Message ID | 20210826193922.66204-14-jolsa@kernel.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | x86/ftrace/bpf: Add batch support for direct/tracing attach | expand |
Context | Check | Description |
---|---|---|
bpf/vmtest | fail | Kernel LATEST + selftests |
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | fail | Series longer than 15 patches |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 2 maintainers not CCed: kpsingh@kernel.org andrii@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: From:/Signed-off-by: email address mismatch: 'From: Jiri Olsa <jolsa@redhat.com>' != 'Signed-off-by: Jiri Olsa <jolsa@kernel.org>' |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
bpf/vmtest-bpf-next | fail | Kernel LATEST + selftests |
diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c index 6dba43266e0b..8aa0aca38b3a 100644 --- a/kernel/bpf/trampoline.c +++ b/kernel/bpf/trampoline.c @@ -522,18 +522,16 @@ struct bpf_trampoline *bpf_trampoline_get(u64 key, return tr; } -void bpf_trampoline_put(struct bpf_trampoline *tr) +static void __bpf_trampoline_put(struct bpf_trampoline *tr) { - if (!tr) - return; - mutex_lock(&trampoline_mutex); + lockdep_assert_held(&trampoline_mutex); if (!refcount_dec_and_test(&tr->refcnt)) - goto out; + return; WARN_ON_ONCE(mutex_is_locked(&tr->mutex)); if (WARN_ON_ONCE(!hlist_empty(&tr->progs_hlist[BPF_TRAMP_FENTRY]))) - goto out; + return; if (WARN_ON_ONCE(!hlist_empty(&tr->progs_hlist[BPF_TRAMP_FEXIT]))) - goto out; + return; /* This code will be executed even when the last bpf_tramp_image * is alive. All progs are detached from the trampoline and the * trampoline image is patched with jmp into epilogue to skip @@ -542,7 +540,14 @@ void bpf_trampoline_put(struct bpf_trampoline *tr) */ hlist_del(&tr->hlist); kfree(tr); -out: +} + +void bpf_trampoline_put(struct bpf_trampoline *tr) +{ + if (!tr) + return; + mutex_lock(&trampoline_mutex); + __bpf_trampoline_put(tr); mutex_unlock(&trampoline_mutex); }
Separating out __bpf_trampoline_put function, so it can be used from other places in following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> --- kernel/bpf/trampoline.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)