Skip to content

Commit 1991fd0

Browse files
anakryikogregkh
authored andcommitted
selftests/bpf: adjust strobemeta loop to satisfy latest clang
[ Upstream commit 4670d68 ] Some recent changes in latest Clang started causing the following warning when unrolling strobemeta test case main loop: progs/strobemeta.h:416:2: warning: loop not unrolled: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Wpass-failed=transform-warning] This patch simplifies loop's exit condition to depend only on constant max iteration number (STROBE_MAX_MAP_ENTRIES), while moving early termination logic inside the loop body. The changes are equivalent from program logic standpoint, but fixes the warning. It also appears to improve generated BPF code, as it fixes previously failing non-unrolled strobemeta test cases. Cc: Alexei Starovoitov <ast@fb.com> Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 2189138 commit 1991fd0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎tools/testing/selftests/bpf/progs/strobemeta.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,10 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg,
413413
#else
414414
#pragma unroll
415415
#endif
416-
for (int i = 0; i < STROBE_MAX_MAP_ENTRIES && i < map.cnt; ++i) {
416+
for (int i = 0; i < STROBE_MAX_MAP_ENTRIES; ++i) {
417+
if (i >= map.cnt)
418+
break;
419+
417420
descr->key_lens[i] = 0;
418421
len = bpf_probe_read_str(payload, STROBE_MAX_STR_LEN,
419422
map.entries[i].key);

0 commit comments

Comments
 (0)