Re: [PATCH v2 bpf-next 1/3] bpf: Introduce bpf_timer
flat view
From: Yonghong Song <hidden>
Date: 2021-06-15 04:21:54
Also in:
bpf
On 6/14/21 8:33 PM, Alexei Starovoitov wrote:
On Fri, Jun 11, 2021 at 3:12 PM Yonghong Song [off-list ref] wrote:quoted
quoted
+struct bpf_hrtimer { + struct hrtimer timer; + struct bpf_map *map; + struct bpf_prog *prog; + void *callback_fn; + void *value; +}; + +/* the actual struct hidden inside uapi struct bpf_timer */ +struct bpf_timer_kern { + struct bpf_hrtimer *timer; + struct bpf_spin_lock lock; +};Looks like in 32bit system, sizeof(struct bpf_timer_kern) is 64 and sizeof(struct bpf_timer) is 128. struct bpf_spin_lock { __u32 val; }; struct bpf_timer { __u64 :64; __u64 :64; }; Checking the code, we may not have issues as structure "bpf_timer" is only used to reserve spaces and map copy value routine handles that properly. Maybe we can still make it consistent with two fields in bpf_timer_kern mapping to two fields in bpf_timer? struct bpf_timer_kern { __bpf_md_ptr(struct bpf_hrtimer *, timer); struct bpf_spin_lock lock; };Such alignment of fields is not necessary, since the fields are not accessible directly from bpf prog. struct bpf_timer_kern needs to fit into struct bpf_timer and alignof these two structs needs to be the same. That's all. I'll add build_bug_on to make sure.
Sounds good to me. Thanks!