linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: rt-users <linux-rt-users@vger.kernel.org>
Cc: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Subject: [PATCH 3/4] rt-tests: cyclictest: Make the affinity mask apply to the main thread too
Date: Wed,  4 Mar 2020 16:55:47 -0500	[thread overview]
Message-ID: <20200304215548.13079-3-jkacur@redhat.com> (raw)
In-Reply-To: <20200304215548.13079-1-jkacur@redhat.com>

There is no reason that the main thread should be treated differently,
so apply the affinity setting there too.

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/cyclictest/cyclictest.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 13d2b1722890..f8df4c6954ad 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1992,6 +1992,17 @@ int main(int argc, char **argv)
 	if (verbose)
 		printf("Max CPUs = %d\n", max_cpus);
 
+	/* Restrict the main pid to the affinity specified by the user */
+	if (affinity_mask != NULL) {
+		int res;
+
+		errno = 0;
+		res = numa_sched_setaffinity(getpid(), affinity_mask);
+		if (res != 0) {
+			warn("Couldn't setaffinity in main thread: %s\n", strerror(errno));
+		}
+	}
+
 	if (trigger) {
 		int retval;
 		retval = trigger_init();
-- 
2.20.1


  parent reply	other threads:[~2020-03-04 21:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-04 21:55 [PATCH 1/4] rt-tests: cyclictest: Remove HAVE_PARSE_CPUSTRING_ALL John Kacur
2020-03-04 21:55 ` [PATCH 2/4] rt-tests: cyclictest: Remove support for compiling without NUMA John Kacur
2020-03-04 21:55 ` John Kacur [this message]
2020-03-04 21:55 ` [PATCH 4/4] rt-tests: cyclictest: Fix -t without a user specified [NUM] John Kacur

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=20200304215548.13079-3-jkacur@redhat.com \
    --to=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).