diff options
author | Yonghong Song <yhs@fb.com> | 2022-02-11 11:49:48 -0800 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-02-11 13:21:47 -0800 |
commit | 3bd916ee0ecbbdd902fc24845f2fef332b2a310c (patch) | |
tree | da6ca95ebff9eb46e37000d5d8aded9c722bf6f2 /kernel | |
parent | acc3c47394a1790b4023ca316ac46e798338dd1a (diff) |
bpf: Emit bpf_timer in vmlinux BTF
Currently 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 the code above may not zero the whole structure
due to anonymour members and that code will be replaced
by memset in the subsequent patch and
bpf_timer definition will disappear 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>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220211194948.3141529-1-yhs@fb.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/helpers.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 01cfdf40c838..55c084251fab 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -2,6 +2,7 @@ /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com */ #include <linux/bpf.h> +#include <linux/btf.h> #include <linux/bpf-cgroup.h> #include <linux/rcupdate.h> #include <linux/random.h> @@ -1075,6 +1076,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; |