After setting CPU affinity, read it back to verify it was set correctly. Throw a warning on mismatch. This can happen if affinity is set to an offline core. Signed-off-by: Allen Martin <amartin@xxxxxxxxxx> --- src/cyclictest/cyclictest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 0912494426ca..568e52f4b328 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -982,7 +982,7 @@ static void *timerthread(void *param) struct itimerspec tspec; struct thread_stat *stat = par->stats; int stopped = 0; - cpu_set_t mask; + cpu_set_t mask, mask_verify; pthread_t thread; unsigned long smi_now, smi_old; @@ -997,6 +997,13 @@ static void *timerthread(void *param) if (pthread_setaffinity_np(thread, sizeof(mask), &mask) == -1) warn("Could not set CPU affinity to CPU #%d\n", par->cpu); + /* read back affinity to verify it was set correctly */ + if (pthread_getaffinity_np(thread, sizeof(mask), &mask_verify) == -1) + warn("Could not get CPU affinity for CPU #%d\n", + par->cpu); + if (!CPU_EQUAL(&mask, &mask_verify)) + warn("CPU affinity was set incorrectly for CPU #%d\n", + par->cpu); } interval.tv_sec = par->interval / USEC_PER_SEC; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html