BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests/bpf: more open-coded gettid syscall cleanup
@ 2025-09-11  7:33 Alan Maguire
  2025-09-11 14:12 ` Andrii Nakryiko
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Maguire @ 2025-09-11  7:33 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: martin.lau, eddyz87, song, yonghong.song, john.fastabend, kpsingh,
	sdf, haoluo, jolsa, brauner, bboscaccy, ameryhung, emil, bpf,
	Alan Maguire

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.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-11 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  7:33 [PATCH bpf-next] selftests/bpf: more open-coded gettid syscall cleanup Alan Maguire
2025-09-11 14:12 ` Andrii Nakryiko
2025-09-11 15:20   ` Alan Maguire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox