[PATCH 3/3] perf test: mmap-thread-lookup: use gettid

From: Riccardo Mancini
Date: Thu Jul 22 2021 - 11:34:30 EST


This patch replaces the manual syscall to get the current thread tid,
with the libc equivalent gettid.
Since it is only available from glibc 2.30, the libc_compat.h header is
included, which provides its definition in case gettid is not available.

Signed-off-by: Riccardo Mancini <rickyman7@xxxxxxxxx>
---
tools/perf/tests/mmap-thread-lookup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
index 8d9d4cbff76d17d5..055cc850a6061798 100644
--- a/tools/perf/tests/mmap-thread-lookup.c
+++ b/tools/perf/tests/mmap-thread-lookup.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <inttypes.h>
#include <unistd.h>
-#include <sys/syscall.h>
+#include <tools/libc_compat.h> // gettid
#include <sys/types.h>
#include <sys/mman.h>
#include <pthread.h>
@@ -45,7 +45,7 @@ static int thread_init(struct thread_data *td)
}

td->map = map;
- td->tid = syscall(SYS_gettid);
+ td->tid = gettid();

pr_debug("tid = %d, map = %p\n", td->tid, map);
return 0;
--
2.31.1