On 6/14/21 8:33 PM, Alexei Starovoitov wrote:
On Fri, Jun 11, 2021 at 3:12 PM Yonghong Song <yhs@xxxxxx> wrote:
+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!