linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: RT <linux-rt-users@vger.kernel.org>, Christian Eggers <ceggers@arri.de>
Cc: Daniel Wagner <wagi@monom.org>,
	Kurt Kanzenbach <kurt.kanzenbach@linutronix.de>,
	Clark Williams <williams@redhat.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	John Kacur <jkacur@redhat.com>
Subject: [PATCH 1/2] rt-tests: Don't assume numa is available at runtime
Date: Mon, 22 Feb 2021 17:07:49 -0500	[thread overview]
Message-ID: <20210222220750.12911-2-jkacur@redhat.com> (raw)
In-Reply-To: <20210222220750.12911-1-jkacur@redhat.com>

- Rework numa_initialize a bit to return the status of numa
- Don't fail if numa is not available after the call to numa_initialize

Signed-off-by: John Kacur <jkacur@redhat.com>
---
 src/cyclictest/cyclictest.c |  8 ++------
 src/lib/rt-numa.c           | 17 +++++++++++------
 src/signaltest/signaltest.c |  8 ++------
 3 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 3e31937f7088..157047837259 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1018,9 +1018,7 @@ static void process_options(int argc, char *argv[], int max_cpus)
 			/* smp sets AFFINITY_USEALL in OPT_SMP */
 			if (smp)
 				break;
-			if (numa_initialize())
-				fatal("Couldn't initialize libnuma");
-			numa = 1;
+			numa = numa_initialize();
 			if (optarg) {
 				parse_cpumask(optarg, max_cpus, &affinity_mask);
 				setaffinity = AFFINITY_SPECIFIED;
@@ -1204,9 +1202,7 @@ static void process_options(int argc, char *argv[], int max_cpus)
 
 	/* if smp wasn't requested, test for numa automatically */
 	if (!smp) {
-		if (numa_initialize())
-			fatal("Couldn't initialize libnuma");
-		numa = 1;
+		numa = numa_initialize();
 		if (setaffinity == AFFINITY_UNSPECIFIED)
 			setaffinity = AFFINITY_USEALL;
 	}
diff --git a/src/lib/rt-numa.c b/src/lib/rt-numa.c
index dbeaef696876..babcc634d57e 100644
--- a/src/lib/rt-numa.c
+++ b/src/lib/rt-numa.c
@@ -13,19 +13,24 @@
 #include "rt-error.h"
 #include "rt-numa.h"
 
-/* numa_available() must be called before any other calls to the numa library */
+/*
+ * numa_available() must be called before any other calls to the numa library
+ * returns 0 if numa is available, or 1 if numa is not available
+ */
 int numa_initialize(void)
 {
-	static int is_initialized;
+	static int is_initialized;	// Only call numa_available once
+	static int numa;
 
 	if (is_initialized == 1)
-		return 0;
+		return numa;
 
-	if (numa_available() == -1)
-		return -1;
+	if (numa_available() != -1)
+		numa = 1;
 
 	is_initialized = 1;
-	return 0;
+
+	return numa;
 }
 
 int get_available_cpus(struct bitmask *cpumask)
diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index 4f8e7caea2c1..b1a7e1db8302 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -253,9 +253,7 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus)
 			/* smp sets AFFINITY_USEALL in OPT_SMP */
 			if (smp)
 				break;
-			if (numa_initialize())
-				fatal("Couldn't initialize libnuma");
-			numa = 1;
+			numa = numa_initialize();
 			if (optarg) {
 				parse_cpumask(optarg, max_cpus, &affinity_mask);
 				setaffinity = AFFINITY_SPECIFIED;
@@ -339,9 +337,7 @@ static void process_options(int argc, char *argv[], unsigned int max_cpus)
 
 	/* if smp wasn't requested, test for numa automatically */
 	if (!smp) {
-		if (numa_initialize())
-			fatal("Couldn't initialize libnuma");
-		numa = 1;
+		numa = numa_initialize();
 		if (setaffinity == AFFINITY_UNSPECIFIED)
 			setaffinity = AFFINITY_USEALL;
 	}
-- 
2.26.2


  reply	other threads:[~2021-02-22 22:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 22:07 [PATCH 0/2] Fix for machines without numa John Kacur
2021-02-22 22:07 ` John Kacur [this message]
2021-02-22 22:07 ` [PATCH 2/2] rt-tests: remove rt_numa_bitmask_count in rt_numa.h John Kacur
2021-02-24  9:25 ` [PATCH 0/2] Fix for machines without numa Kurt Kanzenbach
2021-02-25  3:36   ` 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=20210222220750.12911-2-jkacur@redhat.com \
    --to=jkacur@redhat.com \
    --cc=bigeasy@linutronix.de \
    --cc=ceggers@arri.de \
    --cc=kurt.kanzenbach@linutronix.de \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=wagi@monom.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).