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/bpf: More open-coded gettid syscall cleanup

Commit 0e2fb011a0ba ("selftests/bpf: Clean up open-coded gettid syscall
invocations") addressed the issue that older libc may not have a gettid()
function call wrapper for the associated syscall.

A few more instances have crept into tests, use sys_gettid() instead, and
poison raw gettid() usage to avoid future issues.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20250911163056.543071-1-alan.maguire@oracle.com

authored by

Alan Maguire and committed by
Daniel Borkmann
3ae4c527 61ee2cce

+8 -5
+3
tools/testing/selftests/bpf/bpf_util.h
··· 67 67 #define sys_gettid() syscall(SYS_gettid) 68 68 #endif 69 69 70 + /* and poison usage to ensure it does not creep back in. */ 71 + #pragma GCC poison gettid 72 + 70 73 #ifndef ENOTSUPP 71 74 #define ENOTSUPP 524 72 75 #endif
+1 -1
tools/testing/selftests/bpf/network_helpers.c
··· 457 457 if (end + 8 > sz) 458 458 return -1; 459 459 460 - sprintf(&str[end], "%07d", gettid()); 460 + sprintf(&str[end], "%07ld", sys_gettid()); 461 461 str[end + 7] = '\0'; 462 462 463 463 return 0;
+1 -1
tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c
··· 44 44 if (!ASSERT_OK_PTR(skel, "read_cgroupfs_xattr__open_and_load")) 45 45 goto out; 46 46 47 - skel->bss->target_pid = gettid(); 47 + skel->bss->target_pid = sys_gettid(); 48 48 49 49 if (!ASSERT_OK(read_cgroupfs_xattr__attach(skel), "read_cgroupfs_xattr__attach")) 50 50 goto out;
+1 -1
tools/testing/selftests/bpf/prog_tests/kernel_flag.c
··· 16 16 if (!ASSERT_OK_PTR(lsm_skel, "lsm_skel")) 17 17 return; 18 18 19 - lsm_skel->bss->monitored_tid = gettid(); 19 + lsm_skel->bss->monitored_tid = sys_gettid(); 20 20 21 21 ret = test_kernel_flag__attach(lsm_skel); 22 22 if (!ASSERT_OK(ret, "test_kernel_flag__attach"))
+1 -1
tools/testing/selftests/bpf/prog_tests/task_local_data.h
··· 158 158 void *data_alloc = NULL; 159 159 int err, tid_fd = -1; 160 160 161 - tid_fd = syscall(SYS_pidfd_open, gettid(), O_EXCL); 161 + tid_fd = syscall(SYS_pidfd_open, sys_gettid(), O_EXCL); 162 162 if (tid_fd < 0) { 163 163 err = -errno; 164 164 goto out;
+1 -1
tools/testing/selftests/bpf/prog_tests/test_task_local_data.c
··· 63 63 if (!ASSERT_OK_PTR(value2, "tld_get_data")) 64 64 goto out; 65 65 66 - tid = gettid(); 66 + tid = sys_gettid(); 67 67 68 68 *value0 = tid + 0; 69 69 *value1 = tid + 1;