hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/testing/selftests/powerpc/tm/tm-trap.c
....@@ -1,6 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2017, Gustavo Romero, IBM Corp.
3
- * Licensed under GPLv2.
44 *
55 * Check if thread endianness is flipped inadvertently to BE on trap
66 * caught in TM whilst MSR.FP and MSR.VEC are zero (i.e. just after
....@@ -247,8 +247,7 @@
247247 int tm_trap_test(void)
248248 {
249249 uint16_t k = 1;
250
-
251
- int rc;
250
+ int cpu, rc;
252251
253252 pthread_attr_t attr;
254253 cpu_set_t cpuset;
....@@ -267,9 +266,12 @@
267266 usr1_sa.sa_sigaction = usr1_signal_handler;
268267 sigaction(SIGUSR1, &usr1_sa, NULL);
269268
270
- /* Set only CPU 0 in the mask. Both threads will be bound to cpu 0. */
269
+ cpu = pick_online_cpu();
270
+ FAIL_IF(cpu < 0);
271
+
272
+ // Set only one CPU in the mask. Both threads will be bound to that CPU.
271273 CPU_ZERO(&cpuset);
272
- CPU_SET(0, &cpuset);
274
+ CPU_SET(cpu, &cpuset);
273275
274276 /* Init pthread attribute */
275277 rc = pthread_attr_init(&attr);