Skip to content

Commit

Permalink
selftests/bpf: Fix a btf_dump selftest failure
Browse files Browse the repository at this point in the history
Jakub reported bpf selftest "btf_dump" failure after forwarding to
v6.11-rc1 with netdev.
  Error: torvalds#33 btf_dump
  Error: torvalds#33/15 btf_dump/btf_dump: var_data
    btf_dump_data:FAIL:find type id unexpected find type id: actual -2 < expected 0

The reason for the failure is due to
  commit 94ede2a ("profiling: remove stale percpu flip buffer variables")
where percpu static variable "cpu_profile_flip" is removed.

Let us replace "cpu_profile_flip" with a variable in bpf subsystem
so whenever that variable gets deleted or renamed, we can detect the
failure immediately. In this case, I picked a static percpu variable
"bpf_cgrp_storage_busy" which is defined in kernel/bpf/bpf_cgrp_storage.c.

Reported-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
Yonghong Song authored and NipaLocal committed Sep 3, 2024
1 parent b4dc00b commit 61d8ca8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/btf_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,8 @@ static void test_btf_dump_var_data(struct btf *btf, struct btf_dump *d,
TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int, BTF_F_COMPACT,
"int cpu_number = (int)100", 100);
#endif
TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_profile_flip", int, BTF_F_COMPACT,
"static int cpu_profile_flip = (int)2", 2);
TEST_BTF_DUMP_VAR(btf, d, NULL, str, "bpf_cgrp_storage_busy", int, BTF_F_COMPACT,
"static int bpf_cgrp_storage_busy = (int)2", 2);
}

static void test_btf_datasec(struct btf *btf, struct btf_dump *d, char *str,
Expand Down

0 comments on commit 61d8ca8

Please sign in to comment.