summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/powerpc/tm/tm-poison.c
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2020-08-13 11:34:43 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2020-09-08 22:23:42 +1000
commitc0176429b7b07893a5c1fd38baff055c919ba9e3 (patch)
tree620f668966ad6c1b4a75a918f22f8d509f62757b /tools/testing/selftests/powerpc/tm/tm-poison.c
parent10bf59d923c2766ec8d6f0243481c865c7db9979 (diff)
selftests/powerpc: Fix TM tests when CPU 0 is offline
Several of the TM tests fail spuriously if CPU 0 is offline, because they blindly try to affinitise to CPU 0. Fix them by picking any online CPU and using that instead. Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200813013445.686464-1-mpe@ellerman.id.au
Diffstat (limited to 'tools/testing/selftests/powerpc/tm/tm-poison.c')
-rw-r--r--tools/testing/selftests/powerpc/tm/tm-poison.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/testing/selftests/powerpc/tm/tm-poison.c b/tools/testing/selftests/powerpc/tm/tm-poison.c
index 977558497c16..29e5f26af7b9 100644
--- a/tools/testing/selftests/powerpc/tm/tm-poison.c
+++ b/tools/testing/selftests/powerpc/tm/tm-poison.c
@@ -26,7 +26,7 @@
int tm_poison_test(void)
{
- int pid;
+ int cpu, pid;
cpu_set_t cpuset;
uint64_t poison = 0xdeadbeefc0dec0fe;
uint64_t unknown = 0;
@@ -35,10 +35,13 @@ int tm_poison_test(void)
SKIP_IF(!have_htm());
- /* Attach both Child and Parent to CPU 0 */
+ cpu = pick_online_cpu();
+ FAIL_IF(cpu < 0);
+
+ // Attach both Child and Parent to the same CPU
CPU_ZERO(&cpuset);
- CPU_SET(0, &cpuset);
- sched_setaffinity(0, sizeof(cpuset), &cpuset);
+ CPU_SET(cpu, &cpuset);
+ FAIL_IF(sched_setaffinity(0, sizeof(cpuset), &cpuset) != 0);
pid = fork();
if (!pid) {