selftests/bench: use syscall(SYS_gettid) as libc support for gettid() is sometimes absent
Subsystems (3)
PATCH 1/1 selftests/bench: use syscall(SYS_gettid) as libc support for gettid() is sometimes absent
With glibc 2.28, selftests compilation fails for benchs/bench_trigger.c:
benchs/bench_trigger.c: In function ‘inc_counter’:benchs/bench_trigger.c:25:23: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
25 | tid = gettid();
| ^~~~~~
| getgidcc1: all warnings being treated as errors
It appears support for the gettid() wrapper is variable across glibc versions, so may be safer to use syscall(SYS_gettid) instead.
--- tools/testing/selftests/bpf/benchs/bench_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/benchs/bench_trigger.c +1 -1
@@ -22,7 +22,7 @@ static __always_inline void inc_counter(struct counter *counters)unsigned slot;if (unlikely (tid ==0 )) - tid =gettid (); + tid =syscall (SYS_gettid);/* multiplicative hashing, it's fast */ slot =2654435769U * tid;
Signature · 1 line
2.31.1
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 10 lines · On Fri, 22 Mar 2024 09:57:28 +0000 you wrote:
With glibc 2.28, selftests compilation fails for
benchs/bench_trigger.c:
benchs/bench_trigger.c: In function ‘inc_counter’:benchs/bench_trigger.c:25:23: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]25 | tid = gettid(); | ^~~~~~ | getgidcc1: all warnings being treated as errors
[...]
Here is the summary with links:
- [bpf-next] selftests/bench: use syscall(SYS_gettid) as libc support for gettid() is sometimes absent
https://git.kernel.org/bpf/bpf-next/c/1684d6eb99e4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html