From: Jonathan Schwender <schwenderjonathan@gmail.com>
To: jkacur@redhat.com, williams@redhat.com
Cc: linux-rt-users@vger.kernel.org
Subject: [PATCH 2/2] cyclictest: Add --mainaffinity=[CPUSET] option.
Date: Mon, 22 Feb 2021 16:28:33 +0100 [thread overview]
Message-ID: <20210222152833.8758-4-schwenderjonathan@gmail.com> (raw)
In-Reply-To: <20210222152833.8758-1-schwenderjonathan@gmail.com>
This allows the user to specify a separate cpuset for the main pid,
e.g. on a housekeeping CPU.
If --mainaffinity is not specified, but --affinity is, then the
current behaviour is preserved and the main pid is bound
to the cpuset specified by --affinity
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
---
src/cyclictest/cyclictest.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 3cd592d..803d19a 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -836,6 +836,8 @@ static void display_help(int error)
" --laptop Save battery when running cyclictest\n"
" This will give you poorer realtime results\n"
" but will not drain your battery so quickly\n"
+ " --mainaffinity=[CPUSET] Run the main thread on CPU #N. This only affects\n"
+ " the main thread and not the measurement threads\n"
"-m --mlockall lock current and future memory allocations\n"
"-M --refresh_on_max delay updating the screen until a new max\n"
" latency is hit. Useful for low bandwidth.\n"
@@ -891,6 +893,7 @@ static int quiet;
static int interval = DEFAULT_INTERVAL;
static int distance = -1;
static struct bitmask *affinity_mask = NULL;
+static struct bitmask *main_affinity_mask = NULL;
static int smp = 0;
static int clocksources[] = {
@@ -943,7 +946,7 @@ enum option_values {
OPT_AFFINITY=1, OPT_BREAKTRACE, OPT_CLOCK,
OPT_DISTANCE, OPT_DURATION, OPT_LATENCY,
OPT_FIFO, OPT_HISTOGRAM, OPT_HISTOFALL, OPT_HISTFILE,
- OPT_INTERVAL, OPT_LOOPS, OPT_MLOCKALL, OPT_REFRESH,
+ OPT_INTERVAL, OPT_LOOPS, OPT_MAINAFFINITY, OPT_MLOCKALL, OPT_REFRESH,
OPT_NANOSLEEP, OPT_NSECS, OPT_OSCOPE, OPT_PRIORITY,
OPT_QUIET, OPT_PRIOSPREAD, OPT_RELATIVE, OPT_RESOLUTION,
OPT_SYSTEM, OPT_SMP, OPT_THREADS, OPT_TRIGGER,
@@ -980,6 +983,7 @@ static void process_options(int argc, char *argv[], int max_cpus)
{"interval", required_argument, NULL, OPT_INTERVAL },
{"laptop", no_argument, NULL, OPT_LAPTOP },
{"loops", required_argument, NULL, OPT_LOOPS },
+ {"mainaffinity", required_argument, NULL, OPT_MAINAFFINITY},
{"mlockall", no_argument, NULL, OPT_MLOCKALL },
{"refresh_on_max", no_argument, NULL, OPT_REFRESH },
{"nsecs", no_argument, NULL, OPT_NSECS },
@@ -1071,6 +1075,16 @@ static void process_options(int argc, char *argv[], int max_cpus)
case 'l':
case OPT_LOOPS:
max_cycles = atoi(optarg); break;
+ case OPT_MAINAFFINITY:
+ if (optarg) {
+ parse_cpumask(optarg, max_cpus, &main_affinity_mask);
+ } else if (optind < argc &&
+ (atoi(argv[optind]) ||
+ argv[optind][0] == '0' ||
+ argv[optind][0] == '!')) {
+ parse_cpumask(argv[optind], max_cpus, &main_affinity_mask);
+ }
+ break;
case 'm':
case OPT_MLOCKALL:
lockall = 1; break;
@@ -1787,7 +1801,10 @@ int main(int argc, char **argv)
}
/* Restrict the main pid to the affinity specified by the user */
- if (affinity_mask) {
+ if (main_affinity_mask){
+ set_main_thread_affinity(main_affinity_mask);
+ }
+ else if (affinity_mask) {
set_main_thread_affinity(affinity_mask);
if (verbose)
printf("Using %u cpus.\n",
--
2.29.2
next prev parent reply other threads:[~2021-02-22 15:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-22 15:28 rt-tests: cyclictest: Add option to specify main pid affinity Jonathan Schwender
2021-02-22 15:28 ` [PATCH 0/2] " Jonathan Schwender
2021-02-22 15:28 ` [PATCH 1/2] cyclictest: Move main pid setaffinity handling into a function Jonathan Schwender
2021-02-23 5:12 ` John Kacur
2021-02-22 15:28 ` Jonathan Schwender [this message]
2021-02-22 16:20 ` rt-tests: cyclictest: Add option to specify main pid affinity Ahmed S. Darwish
2021-02-22 17:05 ` Jonathan Schwender
2021-03-21 17:11 ` Jonathan Schwender
2021-03-23 16:51 ` John Kacur
2021-03-24 9:32 ` Ahmed S. Darwish
2021-03-29 14:37 ` Jonathan Schwender
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=20210222152833.8758-4-schwenderjonathan@gmail.com \
--to=schwenderjonathan@gmail.com \
--cc=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).