Skip to content

Commit 3bd916e

Browse files
yonghong-songAlexei Starovoitov
authored andcommitted
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 <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent acc3c47 commit 3bd916e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/bpf/helpers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
33
*/
44
#include <linux/bpf.h>
5+
#include <linux/btf.h>
56
#include <linux/bpf-cgroup.h>
67
#include <linux/rcupdate.h>
78
#include <linux/random.h>
@@ -1075,6 +1076,7 @@ static enum hrtimer_restart bpf_timer_cb(struct hrtimer *hrtimer)
10751076
void *key;
10761077
u32 idx;
10771078

1079+
BTF_TYPE_EMIT(struct bpf_timer);
10781080
callback_fn = rcu_dereference_check(t->callback_fn, rcu_read_lock_bh_held());
10791081
if (!callback_fn)
10801082
goto out;

0 commit comments

Comments
 (0)