bpf: keep module BTF until the vmlinux BTF is available
TL;DR: Nits only: in kernel/bpf/btf.c, btf_drop_deferred_vmlinux_regs() could
reuse the new btf_free_deferred_regs() helper, and the module and vmlinux
apply loops look duplicated. No bug.
quoted hunk ↗ jump to hunk
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 96241dc62dc3..4d51fb212218 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -10967,6 +11252,16 @@ static void btf_apply_deferred_regs(struct btf *btf, struct list_head *regs)
}
}
+static void btf_free_deferred_regs(struct list_head *regs)
+{
+ struct btf_deferred_reg *reg, *tmp;
+
+ list_for_each_entry_safe(reg, tmp, regs, list) {
+ list_del(®->list);
+ btf_free_deferred_reg(reg);
+ }
+}
+
This isn't a bug, but could btf_drop_deferred_vmlinux_regs() call the new
btf_free_deferred_regs(®s) instead of keeping its own copy of the loop?
The tail of btf_drop_deferred_vmlinux_regs() still open-codes the same
thing on its local list:
list_for_each_entry_safe(reg, tmp, ®s, list) {
list_del(®->list);
btf_free_deferred_reg(reg);
}
The splice / unlock / apply / relock loop in btf_module_apply_regs() is
also the same as the one in btf_apply_deferred_vmlinux_regs(), just with a
different mutex.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/36938681172