Skip to contentSkip to conversation

make SMP option only use online cpus (cyclictest)

RFC PATCH In review Joakim Hernberg 2 participants 2 messages Aug 14, 2014 – Aug 15, 2014

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 make SMP option only use online cpus (cyclictest)

When I boot my 8 core i7 laptop with the maxcpus=4 kernel boot flag, cyclictest -S runs 8 threads. This patch makes it only use the online cpus instead.

(quoted diff) +0 -0

b/src/cyclictest/cyclictest.c index 4547831..92fc346 100644

src/cyclictest/cyclictest.c +1 -1
@@ -1740,7 +1740,7 @@ int main(int argc, char **argv)
        sigset_t sigset;
        int signum = SIGALRM;
        int mode;
-       int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+       int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
        int i, ret = -1;
        int status;
 
src/cyclictest/rt_numa.h +1 -1
index e64c446..c2b3e85 100644
@@ -128,7 +128,7 @@ static int rt_numa_numa_node_of_cpu(int cpu)
        int max_node, max_cpus;
 
        max_node = numa_max_node();
-       max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+       max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
        if (cpu > max_cpus) {
                errno = EINVAL;

--

Joakim

#1 lore raw
Quoted 22 lines · Joakim Hernberg

When I boot my 8 core i7 laptop with the maxcpus=4 kernel boot flag, cyclictest -S runs 8 threads. This patch makes it only use the online cpus instead.

(quoted diff) +0 -0

b/src/cyclictest/cyclictest.c index 4547831..92fc346 100644

src/cyclictest/cyclictest.c +1 -1
@@ -1740,7 +1740,7 @@ int main(int argc, char **argv)
        sigset_t sigset;
        int signum = SIGALRM;
        int mode;
-       int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+       int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
        int i, ret = -1;
        int status;
 
src/cyclictest/rt_numa.h +0 -0
index e64c446..c2b3e85 100644

src/cyclictest/rt_numa.h static int rt_numa_numa_node_of_cpu(int cpu)

Quoted 10 lines
src/cyclictest/rt_numa.h +1 -2
@@ -128,7 +128,7 @@ static int rt_numa_numa_node_of_cpu(int cpu)
        int max_node, max_cpus;
 
        max_node = numa_max_node();
-       max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+       max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
        if (cpu > max_cpus) {
                errno = EINVAL;
 
--

This is fine, in anycase, it's not less robust than what we are currently doing. (I suppose we really should be checking the result of sysconf)

I changed the description a little bit.

Clark, I pushed the following version to my repo, please pull

Quoted 1 line

From 863f1482220034de0a85f8150384931318325953 Mon Sep 17 00:00:00 2001

From: Joakim Hernberg <[email protected]>
Date: Thu, 14 Aug 2014 19:29:29 +0200
Subject: [PATCH] cyclictest: make affinity option only use number of online
cpus

When I boot my 8 core i7 laptop with the maxcpus=4 kernel boot flag, cyclictest -S runs 8 threads. This patch makes it only use the number of online cpus instead.

---
 src/cyclictest/cyclictest.c | 2 +-
 src/cyclictest/rt_numa.h    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.c +1 -1
index a3e7b1d6c377..c727d54364b1 100644
@@ -1763,7 +1763,7 @@ int main(int argc, char **argv)
 	sigset_t sigset;
 	int signum = SIGALRM;
 	int mode;
-	int max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+	int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	int i, ret = -1;
 	int status;
 
src/cyclictest/rt_numa.h +1 -1
index 60a143721da1..06c9420e53cc 100644
@@ -128,7 +128,7 @@ static int rt_numa_numa_node_of_cpu(int cpu)
 	int max_node, max_cpus;
 
 	max_node = numa_max_node();
-	max_cpus = sysconf(_SC_NPROCESSORS_CONF);
+	max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
 	if (cpu > max_cpus) {
 		errno = EINVAL;
Signature · 1 line
1.8.1.4