From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 1/1] cyclictest: Allow passing a list of cpus to affine threads to
Date: Thu, 13 Nov 2014 12:12:48 -0300 [thread overview]
Message-ID: <20141113151248.GB3612@kernel.org> (raw)
From: Arnaldo Carvalho de Melo <acme@redhat.com>
For testing, for instance, running one thread per cpu in a CPU socket,
testing isolation of groups of cores that share memory cache.
[root@emilia ~]# ~acme/bin/cyclictest -nmu -p95 -a 1,3,5,7
policy: fifo: loadavg: 0.00 0.17 2.48 2/409 25640
T: 0 (25636) P:95 I:1000 C: 15503 Min: 4 Act: 4 Avg: 4 Max: 8
T: 1 (25637) P:95 I:1500 C: 10331 Min: 4 Act: 4 Avg: 4 Max: 7
T: 2 (25638) P:95 I:2000 C: 7745 Min: 4 Act: 4 Avg: 4 Max: 8
T: 3 (25639) P:95 I:2500 C: 6193 Min: 3 Act: 4 Avg: 4 Max: 8
[root@emilia ~]# tuna -t cyclictest -CP
thread ctxt_switches
pid SCHED_ rtpri affinity voluntary nonvoluntary cmd
25635 FIFO 2 0,2,4,6 449 16 cyclictest
25636 FIFO 95 1 4471 1 cyclictest
25637 FIFO 95 3 2977 1 cyclictest
25638 FIFO 95 5 2230 1 cyclictest
25639 FIFO 95 7 1782 1 cyclictest
[root@emilia ~]#
And generally to allow starting multiple threads spread over non
contiguous CPUs.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
src/cyclictest/cyclictest.8 | 3 ++-
src/cyclictest/cyclictest.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletions(-)
diff --git a/src/cyclictest/cyclictest.8 b/src/cyclictest/cyclictest.8
index fbb6174..fc76e31 100644
--- a/src/cyclictest/cyclictest.8
+++ b/src/cyclictest/cyclictest.8
@@ -34,7 +34,8 @@ A summary of options is included below.
.\" For a complete description, see the Info files.
.TP
.B \-a, \-\-affinity[=PROC]
-Run all threads on procesor number PROC. If PROC is not specified, run thread #N on processor #N.
+Run all threads on procesor number PROC. If PROC is not specified, run thread #N on processor #N. If a CSV PROC list is specified, start a thread on each,
+for starting multiple threads on non-contiguous (enumeration) CPUs.
.TP
.B \-b, \-\-breaktrace=USEC
Send break trace command when latency > USEC. This is a debugging option to control the latency tracer in the realtime preemption patch.
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 11b6cea..26ba18f 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -980,11 +980,13 @@ static int quiet;
static int interval = DEFAULT_INTERVAL;
static int distance = -1;
static int affinity = 0;
+static int *affinities;
static int smp = 0;
enum {
AFFINITY_UNSPECIFIED,
AFFINITY_SPECIFIED,
+ AFFINITY_SPECIFIED_LIST,
AFFINITY_USEALL
};
static int setaffinity = AFFINITY_UNSPECIFIED;
@@ -1034,6 +1036,33 @@ static char *policyname(int policy)
return policystr;
}
+static int read_affinities(char *list, int max_cpus)
+{
+ char *token = list;
+
+ affinities = malloc(sizeof(int) * max_cpus);
+
+ if (affinities == NULL)
+ return -1;
+
+ num_threads = 0;
+
+ do {
+ affinities[num_threads] = atoi(token);
+ if (affinities[num_threads] >= max_cpus)
+ return -1;
+ token = strchr(token, ',');
+ if (++num_threads > max_cpus)
+ goto out_free;
+ } while (token++ != NULL);
+
+ return 0;
+out_free:
+ free(affinities);
+ affinities = NULL;
+ return -1;
+}
+
/* Process commandline options */
static void process_options (int argc, char *argv[])
@@ -1097,6 +1126,10 @@ static void process_options (int argc, char *argv[])
if (optarg != NULL) {
affinity = atoi(optarg);
setaffinity = AFFINITY_SPECIFIED;
+ } else if (optind<argc && strstr(argv[optind], ",")) {
+ if (read_affinities(argv[optind], max_cpus))
+ fatal("invalid affinity list\n");
+ setaffinity = AFFINITY_SPECIFIED_LIST;
} else if (optind<argc && atoi(argv[optind])) {
affinity = atoi(argv[optind]);
setaffinity = AFFINITY_SPECIFIED;
@@ -1588,6 +1621,7 @@ int main(int argc, char **argv)
switch (setaffinity) {
case AFFINITY_UNSPECIFIED: par->cpu = -1; break;
case AFFINITY_SPECIFIED: par->cpu = affinity; break;
+ case AFFINITY_SPECIFIED_LIST: par->cpu = affinities[i]; break;
case AFFINITY_USEALL: par->cpu = i % max_cpus; break;
}
stat->min = 1000000;
--
1.7.1
reply other threads:[~2014-11-13 15:55 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=20141113151248.GB3612@kernel.org \
--to=acme@kernel.org \
--cc=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/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.