On Tue, Jun 28, 2022 at 11:27 PM Yonghong Song <yhs@xxxxxx> wrote: > > > > On 6/28/22 12:43 AM, Yosry Ahmed wrote: > > On Mon, Jun 27, 2022 at 11:47 PM Yosry Ahmed <yosryahmed@xxxxxxxxxx> wrote: > >> > >> On Mon, Jun 27, 2022 at 11:14 PM Yonghong Song <yhs@xxxxxx> wrote: [...] > >>> btf_dump_data:FAIL:ensure expected/actual match unexpected ensure > >>> expected/actual match: actual '(union bpf_iter_link_info){.map = > >>> (struct){.map_fd = (__u32)1,},.cgroup ' > >>> test_btf_dump_struct_data:PASS:find struct sk_buff 0 nsec > >>> > >> > >> Yeah I see what happened there. bpf_iter_link_info was changed by the > >> patch that introduced cgroup_iter, and this specific union is used by > >> the test to test the "union with nested struct" btf dumping. I will > >> add a patch in the next version that updates the btf_dump_data test > >> accordingly. Thanks. > >> > > > > So I actually tried the attached diff to updated the expected dump of > > bpf_iter_link_info in this test, but the test still failed: > > > > btf_dump_data:FAIL:ensure expected/actual match unexpected ensure > > expected/actual match: actual '(union bpf_iter_link_info){.map = > > (struct){.map_fd = (__u32)1,},.cgroup = (struct){.cgroup_fd = > > (__u32)1,},}' != expected '(union bpf_iter_link_info){.map = > > (struct){.map_fd = (__u32)1,},.cgroup = (struct){.cgroup_fd = > > (__u32)1,.traversal_order = (__u32)1},}' > > > > It seems to me that the actual output in this case is not right, it is > > missing traversal_order. Did we accidentally find a bug in btf dumping > > of unions with nested structs, or am I missing something here? > > Probably there is an issue in btf_dump_data() function in > tools/lib/bpf/btf_dump.c. Could you take a look at it? > Regarding this failure of btf_dump_data, the cause seems that: I added a new struct in 'union bpf_iter_link_info' in this patch series, which expanded bpf_iter_link_info's size from 32bit to 64bit. However, the test still used the old struct to initialize, which makes a temporary stack variable (of type bpf_iter_link_info) partially initialized. If I initialize the type by the larger new struct only, btf_dump_data will output the correct content and the said test will pass. Yosry, we need to fold the said solution in the patch which introduced changes to bpf_iter_link_info, so that it won't break the test. I haven't dug into btf_dump_data() on why partially initialized union fails. I need to look at the get_cgroup_vmscan_delay selftest in this patch now. Hao