rt-tests: add task isolation activation to cyclictest/oslat Check whether task isolation is configured, right before the latency sensitive loop, and if so, activate it. Use chisol util-linux tool to configure task isolation externally. Signed-off-by: Marcelo Tosatti diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index a08c91d..eaafe65 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -509,10 +509,13 @@ static void *timerthread(void *param) struct itimerval itimer; struct itimerspec tspec; struct thread_stat *stat = par->stats; - int stopped = 0; + int stopped = 0, ret = 0; cpu_set_t mask; pthread_t thread; unsigned long smi_now, smi_old = 0; +#ifdef PR_ISOL_CFG_GET + unsigned long long isol_mask = 0; +#endif memset(&stop, 0, sizeof(stop)); @@ -617,11 +620,20 @@ static void *timerthread(void *param) stat->threadstarted++; +#ifdef PR_ISOL_CFG_GET + ret = prctl(PR_ISOL_CFG_GET, I_CFG_FEAT, 0, &isol_mask, 0); + if (ret != -1 && isol_mask != 0) { + ret = prctl(PR_ISOL_ACTIVATE_SET, &isol_mask, 0, 0); + if (ret == -1) + fatal("prctl PR_ISOL_ACTIVATE_SET"); + } +#endif + while (!shutdown) { uint64_t diff; unsigned long diff_smi = 0; - int sigs, ret; + int sigs; /* Wait for next period */ switch (par->mode) { @@ -769,6 +781,14 @@ static void *timerthread(void *param) } out: +#ifdef PR_ISOL_ACTIVATE_SET + if (isol_mask != 0) { + ret = prctl(PR_ISOL_ACTIVATE_SET, &isol_mask, 0, 0); + if (ret == -1) + fatal("prctl PR_ISOL_ACTIVATE_SET"); + } +#endif + if (refresh_on_max) { pthread_mutex_lock(&refresh_on_max_lock); /* We could reach here with both shutdown and allstopped unset (0). diff --git a/src/oslat/oslat.c b/src/oslat/oslat.c index 6108fed..658a419 100644 --- a/src/oslat/oslat.c +++ b/src/oslat/oslat.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -350,9 +351,20 @@ static void insert_bucket(struct thread *t, stamp_t value) static void doit(struct thread *t) { +#ifdef PR_ISOL_CFG_GET + int ret; + unsigned long long isol_mask; +#endif + stamp_t ts1, ts2; workload_fn workload_fn = g.workload->w_fn; +#ifdef PR_ISOL_CFG_GET + ret = prctl(PR_ISOL_CFG_GET, I_CFG_FEAT, 0, &isol_mask, 0); + if (ret != -1 && isol_mask != 0) + TEST0(prctl(PR_ISOL_ACTIVATE_SET, &isol_mask, 0, 0, 0)); +#endif + frc(&ts2); do { workload_fn(t->dst_buf, t->src_buf, g.workload_mem_size); @@ -360,6 +372,13 @@ static void doit(struct thread *t) insert_bucket(t, ts1 - ts2); ts2 = ts1; } while (g.cmd == GO); + +#ifdef PR_ISOL_CFG_GET + if (isol_mask != 0) { + isol_mask = 0; + TEST0(prctl(PR_ISOL_ACTIVATE_SET, &isol_mask, 0, 0, 0)); + } +#endif } static int set_fifo_prio(int prio)