On Thu, Sep 11, 2025 at 3:33 AM Alan Maguire <alan.maguire@xxxxxxxxxx> wrote: > > 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. we can poison gettid() to avoid this in the future? > > Signed-off-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > --- > tools/testing/selftests/bpf/network_helpers.c | 2 +- > tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c | 2 +- > tools/testing/selftests/bpf/prog_tests/kernel_flag.c | 2 +- > tools/testing/selftests/bpf/prog_tests/task_local_data.h | 2 +- > tools/testing/selftests/bpf/prog_tests/test_task_local_data.c | 2 +- > 5 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c > index 72b5c174ab3b..cdf7b6641444 100644 > --- a/tools/testing/selftests/bpf/network_helpers.c > +++ b/tools/testing/selftests/bpf/network_helpers.c > @@ -457,7 +457,7 @@ int append_tid(char *str, size_t sz) > if (end + 8 > sz) > return -1; > > - sprintf(&str[end], "%07d", gettid()); > + sprintf(&str[end], "%07ld", sys_gettid()); > str[end + 7] = '\0'; > > return 0; > diff --git a/tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c b/tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c > index e0dd966e4a3e..5ad904e9d15d 100644 > --- a/tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c > +++ b/tools/testing/selftests/bpf/prog_tests/cgroup_xattr.c > @@ -44,7 +44,7 @@ static void test_read_cgroup_xattr(void) > if (!ASSERT_OK_PTR(skel, "read_cgroupfs_xattr__open_and_load")) > goto out; > > - skel->bss->target_pid = gettid(); > + skel->bss->target_pid = sys_gettid(); > > if (!ASSERT_OK(read_cgroupfs_xattr__attach(skel), "read_cgroupfs_xattr__attach")) > goto out; > diff --git a/tools/testing/selftests/bpf/prog_tests/kernel_flag.c b/tools/testing/selftests/bpf/prog_tests/kernel_flag.c > index a133354ac9bc..97b00c7efe94 100644 > --- a/tools/testing/selftests/bpf/prog_tests/kernel_flag.c > +++ b/tools/testing/selftests/bpf/prog_tests/kernel_flag.c > @@ -16,7 +16,7 @@ void test_kernel_flag(void) > if (!ASSERT_OK_PTR(lsm_skel, "lsm_skel")) > return; > > - lsm_skel->bss->monitored_tid = gettid(); > + lsm_skel->bss->monitored_tid = sys_gettid(); > > ret = test_kernel_flag__attach(lsm_skel); > if (!ASSERT_OK(ret, "test_kernel_flag__attach")) > diff --git a/tools/testing/selftests/bpf/prog_tests/task_local_data.h b/tools/testing/selftests/bpf/prog_tests/task_local_data.h > index a408d10c3688..2de38776a2d4 100644 > --- a/tools/testing/selftests/bpf/prog_tests/task_local_data.h > +++ b/tools/testing/selftests/bpf/prog_tests/task_local_data.h > @@ -158,7 +158,7 @@ static int __tld_init_data_p(int map_fd) > void *data_alloc = NULL; > int err, tid_fd = -1; > > - tid_fd = syscall(SYS_pidfd_open, gettid(), O_EXCL); > + tid_fd = syscall(SYS_pidfd_open, sys_gettid(), O_EXCL); > if (tid_fd < 0) { > err = -errno; > goto out; > diff --git a/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c b/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c > index 3b5cd2cd89c7..9fd6306b455c 100644 > --- a/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c > +++ b/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c > @@ -63,7 +63,7 @@ void *test_task_local_data_basic_thread(void *arg) > if (!ASSERT_OK_PTR(value2, "tld_get_data")) > goto out; > > - tid = gettid(); > + tid = sys_gettid(); > > *value0 = tid + 0; > *value1 = tid + 1; > -- > 2.31.1 >