@@ -49,10 +49,26 @@ again:
static void setup(void)
{
cpu_set_t mask;
+ int cpu = 0;
+ long ncpus = tst_ncpus_conf();
CPU_ZERO(&mask);
- CPU_SET(0, &mask);
+ /* Restrict test to a single cpu */
+ if (!sched_getaffinity(0, sizeof(mask), &mask))
+ tst_brk(TBROK | TERRNO, "sched_getaffinity() failed");
+
+ if (CPU_COUNT(&mask) == 0)
+ tst_brk(TBROK, "No cpus available");
+
+ while (CPU_ISSET(cpu, &mask) == 0 && cpu < ncpus)
+ cpu++;
+
+ CPU_ZERO(&mask);
+
+ CPU_SET(cpu, &mask);
+
+ tst_res(TINFO, "Setting affinity to CPU %d", cpu);
if (!sched_setaffinity(0, sizeof(mask), &mask))
tst_brk(TBROK | TERRNO, "sched_setaffinity() failed");