Skip to content

Commit 75ad518

Browse files
Zhao Mengmenghtejun
authored andcommitted
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] llvm/llvm-project#70433 Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn> Reviewed-by: Andrea Righi <arighi@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 01a867c commit 75ad518

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/sched_ext/peek_dsq.bpf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ static void record_peek_result(long pid)
5858
{
5959
u32 slot_key;
6060
long *slot_pid_ptr;
61-
int ix;
61+
u32 ix;
6262

6363
if (pid <= 0)
6464
return;
6565

6666
/* Find an empty slot or one with the same PID */
6767
bpf_for(ix, 0, 10) {
68-
slot_key = (pid + ix) % MAX_SAMPLES;
68+
slot_key = ((u64)pid + ix) % MAX_SAMPLES;
6969
slot_pid_ptr = bpf_map_lookup_elem(&peek_results, &slot_key);
7070
if (!slot_pid_ptr)
7171
continue;

0 commit comments

Comments
 (0)