From: Marcelo Tosatti <mtosatti@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Nitesh Lal <nilal@redhat.com>,
Nicolas Saenz Julienne <nsaenzju@redhat.com>,
Frederic Weisbecker <frederic@kernel.org>,
Christoph Lameter <cl@linux.com>,
Juri Lelli <juri.lelli@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Alex Belits <abelits@belits.com>, Peter Xu <peterx@redhat.com>
Subject: [patch v4] rt-tests: add task isolation activation to cyclictest/oslat
Date: Fri, 8 Oct 2021 11:48:20 -0300 [thread overview]
Message-ID: <20211008144820.GA3986@fuller.cnet> (raw)
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 <mtosatti@redhat.com>
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 2187d98..2e13046 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -515,10 +515,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));
@@ -623,11 +626,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) {
@@ -775,6 +787,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 50ddc81..2105af0 100644
--- a/src/oslat/oslat.c
+++ b/src/oslat/oslat.c
@@ -31,6 +31,7 @@
#include <limits.h>
#include <stdbool.h>
+#include <linux/prctl.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/sysinfo.h>
@@ -383,9 +384,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);
@@ -393,6 +405,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)
reply other threads:[~2021-10-08 14:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211008144820.GA3986@fuller.cnet \
--to=mtosatti@redhat.com \
--cc=abelits@belits.com \
--cc=cl@linux.com \
--cc=frederic@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nilal@redhat.com \
--cc=nsaenzju@redhat.com \
--cc=peterx@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.