Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17

When compiling sched_ext selftests using clang 17.0.6, it raised
compiler crash and build error:

Error at line 68: Unsupport signed division for DAG: 0x55b2f9a60240:
i64 = sdiv 0x55b2f9a609b0, Constant:i64<100>, peek_dsq.bpf.c:68:25 @[
peek_dsq.bpf.c:95:4 @[ peek_dsq.bpf.c:169:8 @[ peek
_dsq.bpf.c:140:6 ] ] ]Please convert to unsigned div/mod

After digging, it's not a compiler error, clang supported Signed division
only when using -mcpu=v4, while we use -mcpu=v3 currently, the better way
is to use unsigned div, see [1] for details.

[1] https://github.com/llvm/llvm-project/issues/70433

Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Zhao Mengmeng and committed by
Tejun Heo
75ad5182 01a867c2

+2 -2
+2 -2
tools/testing/selftests/sched_ext/peek_dsq.bpf.c
··· 58 58 { 59 59 u32 slot_key; 60 60 long *slot_pid_ptr; 61 - int ix; 61 + u32 ix; 62 62 63 63 if (pid <= 0) 64 64 return; 65 65 66 66 /* Find an empty slot or one with the same PID */ 67 67 bpf_for(ix, 0, 10) { 68 - slot_key = (pid + ix) % MAX_SAMPLES; 68 + slot_key = ((u64)pid + ix) % MAX_SAMPLES; 69 69 slot_pid_ptr = bpf_map_lookup_elem(&peek_results, &slot_key); 70 70 if (!slot_pid_ptr) 71 71 continue;