Message ID | 20220211073913.3455777-1-yhs@fb.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: fix a bpf_timer initialization issue | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for bpf |
netdev/apply | fail | Patch does not apply to bpf |
bpf/vmtest-bpf-PR | fail | merge-conflict |
On 2/11/22 8:39 AM, Yonghong Song wrote: > Previously, the following code in check_and_init_map_value() > *(struct bpf_timer *)(dst + map->timer_off) = > (struct bpf_timer){}; > can help generate bpf_timer definition in vmlinuxBTF. > But previous patch replaced the above code with memset > so bpf_timer definition disappears from vmlinuxBTF. > Let us emit the type explicitly so bpf program can continue > to use it from vmlinux.h. > > Signed-off-by: Yonghong Song <yhs@fb.com> Needs at minimum rebase for the bpf tree as target, see also: https://github.com/kernel-patches/bpf/pull/2549 Thanks, Daniel
On 2/11/22 3:48 PM, Daniel Borkmann wrote: > On 2/11/22 8:39 AM, Yonghong Song wrote: >> Previously, the following code in check_and_init_map_value() >> *(struct bpf_timer *)(dst + map->timer_off) = >> (struct bpf_timer){}; >> can help generate bpf_timer definition in vmlinuxBTF. >> But previous patch replaced the above code with memset >> so bpf_timer definition disappears from vmlinuxBTF. >> Let us emit the type explicitly so bpf program can continue >> to use it from vmlinux.h. >> >> Signed-off-by: Yonghong Song <yhs@fb.com> > > Needs at minimum rebase for the bpf tree as target, see also: > > https://github.com/kernel-patches/bpf/pull/2549 (Nevermind, noticed the dependency too late, sry for noise.)
On 2/11/22 6:52 AM, Daniel Borkmann wrote: > On 2/11/22 3:48 PM, Daniel Borkmann wrote: >> On 2/11/22 8:39 AM, Yonghong Song wrote: >>> Previously, the following code in check_and_init_map_value() >>> *(struct bpf_timer *)(dst + map->timer_off) = >>> (struct bpf_timer){}; >>> can help generate bpf_timer definition in vmlinuxBTF. >>> But previous patch replaced the above code with memset >>> so bpf_timer definition disappears from vmlinuxBTF. >>> Let us emit the type explicitly so bpf program can continue >>> to use it from vmlinux.h. >>> >>> Signed-off-by: Yonghong Song <yhs@fb.com> >> >> Needs at minimum rebase for the bpf tree as target, see also: >> >> https://github.com/kernel-patches/bpf/pull/2549 > > (Nevermind, noticed the dependency too late, sry for noise.) Thanks! The patch is prepared based on bpf-next. Just rebased locally and tested against bpf tree. Will submit version 2 soon.
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 4e5969fde0b3..d7fc3c270a4c 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -17,6 +17,7 @@ #include <linux/proc_ns.h> #include <linux/security.h> #include <linux/btf_ids.h> +#include <linux/btf.h> #include "../../lib/kstrtox.h" @@ -1109,6 +1110,7 @@ static enum hrtimer_restart bpf_timer_cb(struct hrtimer *hrtimer) void *key; u32 idx; + BTF_TYPE_EMIT(struct bpf_timer); callback_fn = rcu_dereference_check(t->callback_fn, rcu_read_lock_bh_held()); if (!callback_fn) goto out;
Previously, the following code in check_and_init_map_value() *(struct bpf_timer *)(dst + map->timer_off) = (struct bpf_timer){}; can help generate bpf_timer definition in vmlinuxBTF. But previous patch replaced the above code with memset so bpf_timer definition disappears from vmlinuxBTF. Let us emit the type explicitly so bpf program can continue to use it from vmlinux.h. Signed-off-by: Yonghong Song <yhs@fb.com> --- kernel/bpf/helpers.c | 2 ++ 1 file changed, 2 insertions(+)