.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2017, Gustavo Romero, Breno Leitao, Cyril Bur, IBM Corp. |
---|
3 | | - * Licensed under GPLv2. |
---|
4 | 4 | * |
---|
5 | 5 | * Force FP, VEC and VSX unavailable exception during transaction in all |
---|
6 | 6 | * possible scenarios regarding the MSR.FP and MSR.VEC state, e.g. when FP |
---|
.. | .. |
---|
338 | 338 | |
---|
339 | 339 | int tm_unavailable_test(void) |
---|
340 | 340 | { |
---|
341 | | - int rc, exception; /* FP = 0, VEC = 1, VSX = 2 */ |
---|
| 341 | + int cpu, rc, exception; /* FP = 0, VEC = 1, VSX = 2 */ |
---|
342 | 342 | pthread_t t1; |
---|
343 | 343 | pthread_attr_t attr; |
---|
344 | 344 | cpu_set_t cpuset; |
---|
345 | 345 | |
---|
346 | 346 | SKIP_IF(!have_htm()); |
---|
347 | 347 | |
---|
348 | | - /* Set only CPU 0 in the mask. Both threads will be bound to CPU 0. */ |
---|
| 348 | + cpu = pick_online_cpu(); |
---|
| 349 | + FAIL_IF(cpu < 0); |
---|
| 350 | + |
---|
| 351 | + // Set only one CPU in the mask. Both threads will be bound to that CPU. |
---|
349 | 352 | CPU_ZERO(&cpuset); |
---|
350 | | - CPU_SET(0, &cpuset); |
---|
| 353 | + CPU_SET(cpu, &cpuset); |
---|
351 | 354 | |
---|
352 | 355 | /* Init pthread attribute. */ |
---|
353 | 356 | rc = pthread_attr_init(&attr); |
---|