Skip to contentSkip to conversation

perf test workload: Use unsigned int in code_with_type instead of uint

PATCH In review Arnaldo Carvalho de Melo 4 participants 4 messages Sep 25 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

PATCH 1/1 perf test workload: Use unsigned int in code_with_type instead of uint

The declaration of the Rust helper test_rs() uses "uint", a BSD-ism that lives in <sys/types.h>, so on glibc it is only visible by
accident: glibc's <stdlib.h> includes <sys/types.h>, where uint is exposed under __USE_MISC, which is on by default.

musl does none of that: its <stdlib.h> doesn't include <sys/types.h> and it typedefs uint there only when _GNU_SOURCE/_BSD_SOURCE is defined, while nothing else in this translation unit includes <sys/types.h>. Building it on Alpine therefore fails with:

tests/workloads/code_with_type.c:9:21: error: unknown type name 'uint'; did you mean 'int'? tests/workloads/code_with_type.c:39:17: error: implicit declaration of function 'test_rs' [-Wimplicit-function-declaration]

The second error is a consequence of the first one: with the declaration at line 9 rejected, the call at line 39 has no prototype, which is an error since gcc 14.

The breakage is only visible when rustc is present, because tests/workloads/Build adds code_with_type.o when CONFIG_RUST_SUPPORT is detected, and tools/build/feature only checks for "rustc --version". That is why alpine:3.23 and alpine:3.24 fail while alpine:3.22 and alpine:edge, lacking rustc, build fine and hide it.

Use unsigned int, which needs no header at all.

Fixes 2e05bb52a12d3 ("perf test workload: Add code_with_type test workload")
Cc Dmitrii Dolgov <[email protected]>
Assisted-by LLM
---
 tools/perf/tests/workloads/code_with_type.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/workloads/code_with_type.c +1 -1
index 65d7be7dac24d411..d2d437b86e0c6dbd 100644
@@ -6,7 +6,7 @@
 #include <linux/compiler.h>
 #include "../tests.h"
 
-extern void test_rs(uint count);
+extern void test_rs(unsigned int count);
 
 static volatile sig_atomic_t done;
 
Signature · 1 line
2.55.0
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 23 lines

The declaration of the Rust helper test_rs() uses "uint", a BSD-ism that lives in <sys/types.h>, so on glibc it is only visible by
accident: glibc's <stdlib.h> includes <sys/types.h>, where uint is exposed under __USE_MISC, which is on by default.

musl does none of that: its <stdlib.h> doesn't include <sys/types.h> and it typedefs uint there only when _GNU_SOURCE/_BSD_SOURCE is defined, while nothing else in this translation unit includes <sys/types.h>. Building it on Alpine therefore fails with:

tests/workloads/code_with_type.c:9:21: error: unknown type name 'uint'; did you mean 'int'? tests/workloads/code_with_type.c:39:17: error: implicit declaration of function 'test_rs' [-Wimplicit-function-declaration]

The second error is a consequence of the first one: with the declaration at line 9 rejected, the call at line 39 has no prototype, which is an error since gcc 14.

The breakage is only visible when rustc is present, because tests/workloads/Build adds code_with_type.o when CONFIG_RUST_SUPPORT is detected, and tools/build/feature only checks for "rustc --version". That is why alpine:3.23 and alpine:3.24 fail while alpine:3.22 and alpine:edge, lacking rustc, build fine and hide it.

Quoted 6 lines

Use unsigned int, which needs no header at all.

Fixes 2e05bb52a12d3 ("perf test workload: Add code_with_type test workload")
Cc Dmitrii Dolgov <[email protected]>
Assisted-by LLM

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/araUAt-S6YM_bbAf@x2?part=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 24 lines · Arnaldo Carvalho de Melo

The declaration of the Rust helper test_rs() uses "uint", a BSD-ism that lives in <sys/types.h>, so on glibc it is only visible by
accident: glibc's <stdlib.h> includes <sys/types.h>, where uint is exposed under __USE_MISC, which is on by default.

musl does none of that: its <stdlib.h> doesn't include <sys/types.h> and it typedefs uint there only when _GNU_SOURCE/_BSD_SOURCE is defined, while nothing else in this translation unit includes <sys/types.h>. Building it on Alpine therefore fails with:

tests/workloads/code_with_type.c:9:21: error: unknown type name 'uint'; did you mean 'int'? tests/workloads/code_with_type.c:39:17: error: implicit declaration of function 'test_rs' [-Wimplicit-function-declaration]

The second error is a consequence of the first one: with the declaration at line 9 rejected, the call at line 39 has no prototype, which is an error since gcc 14.

The breakage is only visible when rustc is present, because tests/workloads/Build adds code_with_type.o when CONFIG_RUST_SUPPORT is detected, and tools/build/feature only checks for "rustc --version". That is why alpine:3.23 and alpine:3.24 fail while alpine:3.22 and alpine:edge, lacking rustc, build fine and hide it.

Quoted 6 lines

Use unsigned int, which needs no header at all.

Fixes 2e05bb52a12d3 ("perf test workload: Add code_with_type test workload")
Cc Dmitrii Dolgov <[email protected]>
Assisted-by LLM

Thanks,
Ian

Quoted 20 lines
---
 tools/perf/tests/workloads/code_with_type.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/workloads/code_with_type.c +1 -2
index 65d7be7dac24d411..d2d437b86e0c6dbd 100644
@@ -6,7 +6,7 @@
 #include <linux/compiler.h>
 #include "../tests.h"
 
-extern void test_rs(uint count);
+extern void test_rs(unsigned int count);
 
 static volatile sig_atomic_t done;
 
--

2.55.0

maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 23 lines · Arnaldo Carvalho de Melo

The declaration of the Rust helper test_rs() uses "uint", a BSD-ism that lives in <sys/types.h>, so on glibc it is only visible by
accident: glibc's <stdlib.h> includes <sys/types.h>, where uint is exposed under __USE_MISC, which is on by default.

musl does none of that: its <stdlib.h> doesn't include <sys/types.h> and it typedefs uint there only when _GNU_SOURCE/_BSD_SOURCE is defined, while nothing else in this translation unit includes <sys/types.h>. Building it on Alpine therefore fails with:

tests/workloads/code_with_type.c:9:21: error: unknown type name 'uint'; did you mean 'int'? tests/workloads/code_with_type.c:39:17: error: implicit declaration of function 'test_rs' [-Wimplicit-function-declaration]

The second error is a consequence of the first one: with the declaration at line 9 rejected, the call at line 39 has no prototype, which is an error since gcc 14.

The breakage is only visible when rustc is present, because tests/workloads/Build adds code_with_type.o when CONFIG_RUST_SUPPORT is detected, and tools/build/feature only checks for "rustc --version". That is why alpine:3.23 and alpine:3.24 fail while alpine:3.22 and alpine:edge, lacking rustc, build fine and hide it.

Quoted 6 lines

Use unsigned int, which needs no header at all.

Fixes 2e05bb52a12d3 ("perf test workload: Add code_with_type test workload")
Cc Dmitrii Dolgov <[email protected]>
Assisted-by LLM

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/tests/workloads/code_with_type.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/tests/workloads/code_with_type.c +1 -1
index 65d7be7dac24d411..d2d437b86e0c6dbd 100644
@@ -6,7 +6,7 @@
 #include <linux/compiler.h>
 #include "../tests.h"
 
-extern void test_rs(uint count);
+extern void test_rs(unsigned int count);
 
 static volatile sig_atomic_t done;
 
Signature · 1 line
2.55.0