[LTP] [PATCH v3 2/4] perf_event_open02: Use tst_bind_to_current_cpu() helper
Wei Gao
wegao@suse.com
Fri Nov 13 05:11:31 CET 2026
Replace the local duplicate bind_to_current_cpu() implementation
with the tst_bind_to_current_cpu() library helper.
Signed-off-by: Wei Gao <wegao@suse.com>
---
.../perf_event_open/perf_event_open02.c | 22 +------------------
1 file changed, 1 insertion(+), 21 deletions(-)
diff --git a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
index e38c3f133..1e100982e 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -174,26 +174,6 @@ static int count_hardware_counters(void)
}
#endif /* __s390__ */
-static void bind_to_current_cpu(void)
-{
-#ifdef HAVE_SCHED_GETCPU
- int cpu = sched_getcpu();
- size_t mask_size;
- cpu_set_t *mask;
-
- if (cpu == -1)
- tst_brk(TBROK | TERRNO, "sched_getcpu() failed");
-
- mask = CPU_ALLOC(cpu + 1);
- mask_size = CPU_ALLOC_SIZE(cpu + 1);
- CPU_ZERO_S(mask_size, mask);
- CPU_SET(cpu, mask);
- if (sched_setaffinity(0, mask_size, mask) == -1)
- tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");
- CPU_FREE(mask);
-#endif
-}
-
static void setup(void)
{
int i;
@@ -214,7 +194,7 @@ static void setup(void)
if (access(PATH_KERN_PERF_EVENT_PARANOID, F_OK) == -1)
tst_brk(TCONF, "Kernel doesn't have perf_event support");
- bind_to_current_cpu();
+ tst_bind_to_current_cpu();
#ifdef __s390__
/*
* On s390 the "time_enabled" and "time_running" values are always the
--
2.55.0
More information about the ltp
mailing list