linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface
@ 2012-08-23 16:01 Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 1/7] libnuma: Fix calculation of maxconfiguredcpu Petr Holasek
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman; +Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek

This patchset fixes a few bugs in numactl and introduce new interface
for parsing of cpustrings.

v2:

* _all versions of parsing interfaces and numa_numa_possible_cpus
  are exported via version 1.3 API and don't broke the fixed 1.2

Petr Holasek (7):
  libnuma: Fix calculation of maxconfiguredcpu
  libnuma: do not recalculate maxconfiguredcpu
  libnuma: numa_num_possible_cpus symbol is exported from the library
  libnuma: introduced _all versions of numa_parse_{cpu,node}string()
  libnuma: numa_parse_cpustring and similar should take a const char*
    parameter
  libnuma: removed unused bufferlen variable
  libnuma: no warnings when there are holes in numbering of nodes

 affinity.c        |  17 +++----
 affinity.h        |   2 +-
 distance.c        |   2 +-
 libnuma.c         | 131 +++++++++++++++++++++++++++++++++---------------------
 numa.3            |  18 +++++++-
 numa.h            |  12 ++++-
 versions.ldscript |  13 ++++++
 7 files changed, 130 insertions(+), 65 deletions(-)

-- 
1.7.11.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/7] libnuma: Fix calculation of maxconfiguredcpu
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 2/7] libnuma: do not recalculate maxconfiguredcpu Petr Holasek
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman
  Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek,
	Mark A. Grondona

The value for maxconfiguredcpu was calculated in set_configured_cpus()
by walking the directory in /sys/devices/system/cpu and counting the
entries that begin with "cpu". However, in RHEL6 this ends up making
the cpu count off by two, because there are two directories "cpufreq"
and "cpuidle" that also get counted.

Instead of this overly complex and brittle method, just use sysconf(3)
with _SC_NPROCESSORS_CONF to get the maxconfiguredcpu value. This
was already the fallback method, and seems much less prone to future
failures than other possible methods.

Signed-off-by: Mark A. Grondona <mgrondona@llnl.gov>
Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 libnuma.c | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)

diff --git a/libnuma.c b/libnuma.c
index cc4db0a..302843e 100755
--- a/libnuma.c
+++ b/libnuma.c
@@ -557,30 +557,9 @@ set_numa_max_cpu(void)
 static void
 set_configured_cpus(void)
 {
-	char		*dirnamep = "/sys/devices/system/cpu";
-	struct dirent	*dirent;
-	DIR		*dir;
-	dir = opendir(dirnamep);
-
-	if (dir == NULL) {
-		/* fall back to using the online cpu count */
-		maxconfiguredcpu = sysconf(_SC_NPROCESSORS_CONF) - 1;
-		return;
-	}
-	while ((dirent = readdir(dir)) != 0) {
-		if (dirent->d_type == DT_DIR
-		    && !strncmp("cpu", dirent->d_name, 3)) {
-			long cpu = strtol(dirent->d_name + 3, NULL, 10);
-
-			if (cpu < INT_MAX && cpu > maxconfiguredcpu)
-				maxconfiguredcpu = cpu;
-		}
-	}
-	closedir(dir);
-	if (maxconfiguredcpu < 0) {
-		/* fall back to using the online cpu count */
-		maxconfiguredcpu = sysconf(_SC_NPROCESSORS_CONF) - 1;
-	}
+	maxconfiguredcpu = sysconf(_SC_NPROCESSORS_CONF) - 1;
+	if (maxconfiguredcpu == -1)
+		numa_error("sysconf(NPROCESSORS_CONF) failed.\n");
 }
 
 /*
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/7] libnuma: do not recalculate maxconfiguredcpu
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 1/7] libnuma: Fix calculation of maxconfiguredcpu Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 3/7] libnuma: numa_num_possible_cpus symbol is exported from the library Petr Holasek
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman
  Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek,
	Mark A. Grondona

The value for maxtconfiguredcpu is already calculated before
set_thread_constraints() is called, so there is no reason to
call sysconf(_SC_NPROCESSORS_CONF) a second time. Instead just
use the global maxconfiguredcpu.

Signed-off-by: Mark A. Grondona <mgrondona@llnl.gov>
Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 libnuma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libnuma.c b/libnuma.c
index 302843e..2fd1ad1 100755
--- a/libnuma.c
+++ b/libnuma.c
@@ -464,7 +464,7 @@ read_mask(char *s, struct bitmask *bmp)
 static void
 set_task_constraints(void)
 {
-	int hicpu = sysconf(_SC_NPROCESSORS_CONF)-1;
+	int hicpu = maxconfiguredcpu;
 	int i;
 	char *buffer = NULL;
 	size_t buflen = 0;
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/7] libnuma: numa_num_possible_cpus symbol is exported from the library
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 1/7] libnuma: Fix calculation of maxconfiguredcpu Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 2/7] libnuma: do not recalculate maxconfiguredcpu Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  2012-08-23 16:01 ` [RFC PATCH v2 4/7] libnuma: introduced _all versions of numa_parse_{cpu,node}string() Petr Holasek
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman; +Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek

Function numa_num_possible_cpus is declared in numa.h but not exported.
Seems like mistakenly forgotten because all similar function are exported.

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 versions.ldscript | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/versions.ldscript b/versions.ldscript
index f2071cc..2f2d254 100755
--- a/versions.ldscript
+++ b/versions.ldscript
@@ -152,3 +152,16 @@ libnuma_1.2 {
   local:
     *;
 } libnuma_1.1;
+
+# New parsing interface for cpu/numastrings
+# was added into version 1.3
+
+libnuma_1.3 {
+  global:
+    numa_parse_cpustring_all;
+    numa_parse_nodestring_all;
+    numa_num_possible_cpus;
+  local:
+    *;
+} libnuma_1.2;
+
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC PATCH v2 4/7] libnuma: introduced _all versions of numa_parse_{cpu,node}string()
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
                   ` (2 preceding siblings ...)
  2012-08-23 16:01 ` [PATCH v2 3/7] libnuma: numa_num_possible_cpus symbol is exported from the library Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 5/7] libnuma: numa_parse_cpustring and similar should take a const char* parameter Petr Holasek
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman; +Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek

This patch adds new interfaces numa_parse_cpustring_all() and
numa_parse_nodestring_all(). The functions are able to parse
input string to bitmask regardless current task's cpuset or
available nodes.

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 libnuma.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++---------------
 numa.3    | 14 +++++++++
 numa.h    |  8 ++++++
 3 files changed, 96 insertions(+), 23 deletions(-)

diff --git a/libnuma.c b/libnuma.c
index 2fd1ad1..0fb3b11 100755
--- a/libnuma.c
+++ b/libnuma.c
@@ -47,7 +47,9 @@ nodemask_t numa_all_nodes;
 /* these are now the default bitmask (pointers to) (version 2) */
 struct bitmask *numa_no_nodes_ptr = NULL;
 struct bitmask *numa_all_nodes_ptr = NULL;
+struct bitmask *numa_possible_nodes_ptr = NULL;
 struct bitmask *numa_all_cpus_ptr = NULL;
+struct bitmask *numa_possible_cpus_ptr = NULL;
 /* I would prefer to use symbol versioning to create v1 and v2 versions
    of numa_no_nodes and numa_all_nodes, but the loader does not correctly
    handle versioning of BSS versus small data items */
@@ -108,7 +110,9 @@ void __attribute__((destructor))
 numa_fini(void)
 {
 	FREE_AND_ZERO(numa_all_cpus_ptr);
+	FREE_AND_ZERO(numa_possible_cpus_ptr);
 	FREE_AND_ZERO(numa_all_nodes_ptr);
+	FREE_AND_ZERO(numa_possible_nodes_ptr);
 	FREE_AND_ZERO(numa_no_nodes_ptr);
 	FREE_AND_ZERO(numa_memnode_ptr);
 	FREE_AND_ZERO(numa_nodes_ptr);
@@ -471,7 +475,9 @@ set_task_constraints(void)
 	FILE *f;
 
 	numa_all_cpus_ptr = numa_allocate_cpumask();
+	numa_possible_cpus_ptr = numa_allocate_cpumask();
 	numa_all_nodes_ptr = numa_allocate_nodemask();
+	numa_possible_nodes_ptr = numa_allocate_cpumask();
 	numa_no_nodes_ptr = numa_allocate_nodemask();
 
 	f = fopen(mask_size_file, "r");
@@ -494,6 +500,11 @@ set_task_constraints(void)
 	fclose(f);
 	free(buffer);
 
+	for (i = 0; i <= hicpu; i++)
+		numa_bitmask_setbit(numa_possible_cpus_ptr, i);
+	for (i = 0; i <= maxconfigurednode; i++)
+		numa_bitmask_setbit(numa_possible_nodes_ptr, i);
+
 	/*
 	 * Cpus_allowed in the kernel can be defined to all f's
 	 * i.e. it may be a superset of the actual available processors.
@@ -1725,18 +1736,18 @@ static unsigned long get_nr(char *s, char **end, struct bitmask *bmp, int relati
 }
 
 /*
- * numa_parse_nodestring() is called to create a node mask, given
+ * __numa_parse_nodestring() is called to create a node mask, given
  * an ascii string such as 25 or 12-15 or 1,3,5-7 or +6-10.
- * (the + indicates that the numbers are cpuset-relative)
+ * (the + indicates that the numbers are nodeset-relative)
  *
- * The nodes may be specified as absolute, or relative to the current cpuset.
- * The list of available nodes is in a map pointed to by "numa_all_nodes_ptr",
- * which may represent all nodes or the nodes in the current cpuset.
+ * The nodes may be specified as absolute, or relative to the current nodeset.
+ * The list of available nodes is in a map pointed to by "allowed_nodes_ptr",
+ * which may represent all nodes or the nodes in the current nodeset.
  *
  * The caller must free the returned bitmask.
  */
-struct bitmask *
-numa_parse_nodestring(char *s)
+static struct bitmask *
+__numa_parse_nodestring(char *s, struct bitmask *allowed_nodes_ptr)
 {
 	int invert = 0, relative = 0;
 	int conf_nodes = numa_num_configured_nodes();
@@ -1763,7 +1774,7 @@ numa_parse_nodestring(char *s)
 		if (isalpha(*s)) {
 			int n;
 			if (!strcmp(s,"all")) {
-				copy_bitmask_to_bitmask(numa_all_nodes_ptr,
+				copy_bitmask_to_bitmask(allowed_nodes_ptr,
 							mask);
 				s+=4;
 				break;
@@ -1776,12 +1787,12 @@ numa_parse_nodestring(char *s)
 				break;
 			}
 		}
-		arg = get_nr(s, &end, numa_all_nodes_ptr, relative);
+		arg = get_nr(s, &end, allowed_nodes_ptr, relative);
 		if (end == s) {
 			numa_warn(W_nodeparse, "unparseable node description `%s'\n", s);
 			goto err;
 		}
-		if (!numa_bitmask_isbitset(numa_all_nodes_ptr, arg)) {
+		if (!numa_bitmask_isbitset(allowed_nodes_ptr, arg)) {
 			numa_warn(W_nodeparse, "node argument %d is out of range\n", arg);
 			goto err;
 		}
@@ -1791,18 +1802,18 @@ numa_parse_nodestring(char *s)
 		if (*s == '-') {
 			char *end2;
 			unsigned long arg2;
-			arg2 = get_nr(++s, &end2, numa_all_nodes_ptr, relative);
+			arg2 = get_nr(++s, &end2, allowed_nodes_ptr, relative);
 			if (end2 == s) {
 				numa_warn(W_nodeparse, "missing node argument %s\n", s);
 				goto err;
 			}
-			if (!numa_bitmask_isbitset(numa_all_nodes_ptr, arg2)) {
+			if (!numa_bitmask_isbitset(allowed_nodes_ptr, arg2)) {
 				numa_warn(W_nodeparse, "node argument %d out of range\n", arg2);
 				goto err;
 			}
 			while (arg <= arg2) {
 				i = arg;
-				if (numa_bitmask_isbitset(numa_all_nodes_ptr,i))
+				if (numa_bitmask_isbitset(allowed_nodes_ptr,i))
 					numa_bitmask_setbit(mask, i);
 				arg++;
 			}
@@ -1828,19 +1839,39 @@ err:
 }
 
 /*
- * numa_parse_cpustring() is called to create a bitmask, given
+ * numa_parse_nodestring() is called to create a bitmask from nodes available
+ * for this task.
+ */
+
+struct bitmask * numa_parse_nodestring(char *s)
+{
+	return __numa_parse_nodestring(s, numa_all_nodes_ptr);
+}
+
+/*
+ * numa_parse_nodestring_all() is called to create a bitmask from all nodes
+ * available.
+ */
+
+struct bitmask * numa_parse_nodestring_all(char *s)
+{
+	return __numa_parse_nodestring(s, numa_possible_nodes_ptr);
+}
+
+/*
+ * __numa_parse_cpustring() is called to create a bitmask, given
  * an ascii string such as 25 or 12-15 or 1,3,5-7 or +6-10.
  * (the + indicates that the numbers are cpuset-relative)
  *
  * The cpus may be specified as absolute, or relative to the current cpuset.
  * The list of available cpus for this task is in the map pointed to by
- * "numa_all_cpus_ptr", which may represent all cpus or the cpus in the
+ * "allowed_cpus_ptr", which may represent all cpus or the cpus in the
  * current cpuset.
  *
  * The caller must free the returned bitmask.
  */
-struct bitmask *
-numa_parse_cpustring(char *s)
+static struct bitmask *
+__numa_parse_cpustring(char *s, struct bitmask *allowed_cpus_ptr)
 {
 	int invert = 0, relative=0;
 	int conf_cpus = numa_num_configured_cpus();
@@ -1864,16 +1895,16 @@ numa_parse_cpustring(char *s)
 		int i;
 
 		if (!strcmp(s,"all")) {
-			copy_bitmask_to_bitmask(numa_all_cpus_ptr, mask);
+			copy_bitmask_to_bitmask(allowed_cpus_ptr, mask);
 			s+=4;
 			break;
 		}
-		arg = get_nr(s, &end, numa_all_cpus_ptr, relative);
+		arg = get_nr(s, &end, allowed_cpus_ptr, relative);
 		if (end == s) {
 			numa_warn(W_cpuparse, "unparseable cpu description `%s'\n", s);
 			goto err;
 		}
-		if (!numa_bitmask_isbitset(numa_all_cpus_ptr, arg)) {
+		if (!numa_bitmask_isbitset(allowed_cpus_ptr, arg)) {
 			numa_warn(W_cpuparse, "cpu argument %s is out of range\n", s);
 			goto err;
 		}
@@ -1884,18 +1915,18 @@ numa_parse_cpustring(char *s)
 			char *end2;
 			unsigned long arg2;
 			int i;
-			arg2 = get_nr(++s, &end2, numa_all_cpus_ptr, relative);
+			arg2 = get_nr(++s, &end2, allowed_cpus_ptr, relative);
 			if (end2 == s) {
 				numa_warn(W_cpuparse, "missing cpu argument %s\n", s);
 				goto err;
 			}
-			if (!numa_bitmask_isbitset(numa_all_cpus_ptr, arg2)) {
+			if (!numa_bitmask_isbitset(allowed_cpus_ptr, arg2)) {
 				numa_warn(W_cpuparse, "cpu argument %s out of range\n", s);
 				goto err;
 			}
 			while (arg <= arg2) {
 				i = arg;
-				if (numa_bitmask_isbitset(numa_all_cpus_ptr, i))
+				if (numa_bitmask_isbitset(allowed_cpus_ptr, i))
 					numa_bitmask_setbit(mask, i);
 				arg++;
 			}
@@ -1919,3 +1950,23 @@ err:
 	numa_bitmask_free(mask);
 	return NULL;
 }
+
+/*
+ * numa_parse_cpustring() is called to create a bitmask from cpus available
+ * for this task.
+ */
+
+struct bitmask * numa_parse_cpustring(char *s)
+{
+	return __numa_parse_cpustring(s, numa_all_cpus_ptr);
+}
+
+/*
+ * numa_parse_cpustring_all() is called to create a bitmask from all cpus
+ * available.
+ */
+
+struct bitmask * numa_parse_cpustring_all(char *s)
+{
+	return __numa_parse_cpustring(s, numa_possible_cpus_ptr);
+}
diff --git a/numa.3 b/numa.3
index 5ee2d5b..b302b8f 100755
--- a/numa.3
+++ b/numa.3
@@ -52,7 +52,11 @@ numa \- NUMA policy library
 .br
 .BI "struct bitmask *numa_parse_nodestring(char *" string );
 .br
+.BI "struct bitmask *numa_parse_nodestring_all(char *" string );
+.br
 .BI "struct bitmask *numa_parse_cpustring(char *" string );
+.br
+.BI "struct bitmask *numa_parse_cpustring_all(char *" string );
 .sp
 .BI "long numa_node_size(int " node ", long *" freep );
 .br
@@ -364,6 +368,11 @@ If the string is of 0 length, bitmask
 .BR numa_no_nodes_ptr
 is returned.  Returns 0 if the string is invalid.
 
+.BR numa_parse_nodestring_all()
+is similar to
+.BR numa_parse_nodestring
+, but can parse all possible nodes, not only current nodeset.
+
 .BR numa_parse_cpustring()
 parses a character string list of cpus into a bit mask.
 The bit mask is allocated by
@@ -384,6 +393,11 @@ Examples:  1-5,7,10   !4-5   +0-3
 .br
 Returns 0 if the string is invalid.
 
+.BR numa_parse_cpustring_all()
+is similar to
+.BR numa_parse_cpustring
+, but can parse all possible cpus, not only current cpuset.
+
 .BR numa_node_size ()
 returns the memory size of a node. If the argument
 .I freep
diff --git a/numa.h b/numa.h
index 1dbc137..ea28774 100755
--- a/numa.h
+++ b/numa.h
@@ -312,9 +312,17 @@ int numa_sched_setaffinity(pid_t, struct bitmask *);
 /* Convert an ascii list of nodes to a bitmask */
 struct bitmask *numa_parse_nodestring(char *);
 
+/* Convert an ascii list of nodes to a bitmask without current nodeset
+ * dependency */
+struct bitmask *numa_parse_nodestring_all(char *);
+
 /* Convert an ascii list of cpu to a bitmask */
 struct bitmask *numa_parse_cpustring(char *);
 
+/* Convert an ascii list of cpu to a bitmask without current taskset
+ * dependency */
+struct bitmask *numa_parse_cpustring_all(char *);
+
 /*
  * The following functions are for source code compatibility
  * with releases prior to version 2.
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 5/7] libnuma: numa_parse_cpustring and similar should take a const char* parameter
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
                   ` (3 preceding siblings ...)
  2012-08-23 16:01 ` [RFC PATCH v2 4/7] libnuma: introduced _all versions of numa_parse_{cpu,node}string() Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 6/7] libnuma: removed unused bufferlen variable Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 7/7] libnuma: no warnings when there are holes in numbering of nodes Petr Holasek
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman; +Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek

Input string is handled like it was a const and it doesn't actually modify the
string that it is parsing. It raises warning with following C++ reproducer:

using namespace std;

int main (int argc, char **argv)
{
  bitmask *pbm = numa_allocate_cpumask();
  pbm = numa_bitmask_clearall(pbm);

  if ((pbm = numa_parse_cpustring("2-5,8,10")) != NULL) {
    cout << " cpumask bitmask 2-5,8,10            = ";
    for (int n=0;n<numa_num_configured_cpus();++n) {
      cout << numa_bitmask_isbitset(pbm, n);
    }
    cout << endl;
  }
}

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 affinity.c | 17 +++++++++--------
 affinity.h |  2 +-
 libnuma.c  | 14 +++++++-------
 numa.3     |  8 ++++----
 numa.h     |  8 ++++----
 5 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/affinity.c b/affinity.c
index 2c0cabc..a226b59 100644
--- a/affinity.c
+++ b/affinity.c
@@ -49,14 +49,14 @@
 #include "affinity.h"
 #include "rtnetlink.h"
 
-static int badchar(char *s)
+static int badchar(const char *s)
 {
 	if (strpbrk(s, "/."))
 		return 1;
 	return 0;
 }
 
-static int node_parse_failure(int ret, char *cls, char *dev)
+static int node_parse_failure(int ret, char *cls, const char *dev)
 {
 	if (!cls)
 		cls = "";
@@ -72,7 +72,8 @@ static int node_parse_failure(int ret, char *cls, char *dev)
 }
 
 /* Generic sysfs class lookup */
-static int affinity_class(struct bitmask *mask, char *cls, char *dev)
+static int
+affinity_class(struct bitmask *mask, char *cls, const const char *dev)
 {
 	int ret;
 	while (isspace(*dev))
@@ -121,7 +122,7 @@ static int affinity_class(struct bitmask *mask, char *cls, char *dev)
 
 
 /* Turn file (or device node) into class name */
-static int affinity_file(struct bitmask *mask, char *cls, char *file)
+static int affinity_file(struct bitmask *mask, char *cls, const char *file)
 {
 	struct stat st;
 	DIR *dir;
@@ -249,7 +250,7 @@ static int iif_to_name(int iif, struct ifreq *ifr)
    This generally only attempts to handle simple cases:
    no multi-path, no bounding etc. In these cases only
    the first interface or none is chosen. */
-static int affinity_ip(struct bitmask *mask, char *cls, char *id)
+static int affinity_ip(struct bitmask *mask, char *cls, const char *id)
 {
 	struct addrinfo *ai;
 	int n;
@@ -279,7 +280,7 @@ out_ai:
 }
 
 /* Look up affinity for a PCI device */
-static int affinity_pci(struct bitmask *mask, char *cls, char *id)
+static int affinity_pci(struct bitmask *mask, char *cls, const char *id)
 {
 	unsigned seg, bus, dev, func;
 	int n, ret;
@@ -310,7 +311,7 @@ static struct handler {
 	char first;
 	char *name;
 	char *cls;
-	int (*handler)(struct bitmask *mask, char *cls, char *desc);
+	int (*handler)(struct bitmask *mask, char *cls, const char *desc);
 } handlers[] = {
 	{ 'n', "netdev:", "net",   affinity_class },
 	{ 'i', "ip:",     NULL,    affinity_ip    },
@@ -320,7 +321,7 @@ static struct handler {
 	{}
 };
 
-hidden int resolve_affinity(char *id, struct bitmask *mask)
+hidden int resolve_affinity(const char *id, struct bitmask *mask)
 {
 	struct handler *h;
 
diff --git a/affinity.h b/affinity.h
index 4863d8f..a513749 100644
--- a/affinity.h
+++ b/affinity.h
@@ -2,5 +2,5 @@ enum {
 	NO_IO_AFFINITY = -2
 };
 
-int resolve_affinity(char *id, struct bitmask *mask);
+int resolve_affinity(const char *id, struct bitmask *mask);
 
diff --git a/libnuma.c b/libnuma.c
index 0fb3b11..9c9a1de 100755
--- a/libnuma.c
+++ b/libnuma.c
@@ -1718,7 +1718,7 @@ void numa_set_strict(int flag)
  * Allow a relative node / processor specification within the allowed
  * set if "relative" is nonzero
  */
-static unsigned long get_nr(char *s, char **end, struct bitmask *bmp, int relative)
+static unsigned long get_nr(const char *s, char **end, struct bitmask *bmp, int relative)
 {
 	long i, nr;
 
@@ -1747,7 +1747,7 @@ static unsigned long get_nr(char *s, char **end, struct bitmask *bmp, int relati
  * The caller must free the returned bitmask.
  */
 static struct bitmask *
-__numa_parse_nodestring(char *s, struct bitmask *allowed_nodes_ptr)
+__numa_parse_nodestring(const char *s, struct bitmask *allowed_nodes_ptr)
 {
 	int invert = 0, relative = 0;
 	int conf_nodes = numa_num_configured_nodes();
@@ -1843,7 +1843,7 @@ err:
  * for this task.
  */
 
-struct bitmask * numa_parse_nodestring(char *s)
+struct bitmask * numa_parse_nodestring(const char *s)
 {
 	return __numa_parse_nodestring(s, numa_all_nodes_ptr);
 }
@@ -1853,7 +1853,7 @@ struct bitmask * numa_parse_nodestring(char *s)
  * available.
  */
 
-struct bitmask * numa_parse_nodestring_all(char *s)
+struct bitmask * numa_parse_nodestring_all(const char *s)
 {
 	return __numa_parse_nodestring(s, numa_possible_nodes_ptr);
 }
@@ -1871,7 +1871,7 @@ struct bitmask * numa_parse_nodestring_all(char *s)
  * The caller must free the returned bitmask.
  */
 static struct bitmask *
-__numa_parse_cpustring(char *s, struct bitmask *allowed_cpus_ptr)
+__numa_parse_cpustring(const char *s, struct bitmask *allowed_cpus_ptr)
 {
 	int invert = 0, relative=0;
 	int conf_cpus = numa_num_configured_cpus();
@@ -1956,7 +1956,7 @@ err:
  * for this task.
  */
 
-struct bitmask * numa_parse_cpustring(char *s)
+struct bitmask * numa_parse_cpustring(const char *s)
 {
 	return __numa_parse_cpustring(s, numa_all_cpus_ptr);
 }
@@ -1966,7 +1966,7 @@ struct bitmask * numa_parse_cpustring(char *s)
  * available.
  */
 
-struct bitmask * numa_parse_cpustring_all(char *s)
+struct bitmask * numa_parse_cpustring_all(const char *s)
 {
 	return __numa_parse_cpustring(s, numa_possible_cpus_ptr);
 }
diff --git a/numa.3 b/numa.3
index b302b8f..e0da131 100755
--- a/numa.3
+++ b/numa.3
@@ -50,13 +50,13 @@ numa \- NUMA policy library
 .sp
 .BI "int numa_parse_bitmap(char *" line " , struct bitmask *" mask ");
 .br
-.BI "struct bitmask *numa_parse_nodestring(char *" string );
+.BI "struct bitmask *numa_parse_nodestring(const char *" string );
 .br
-.BI "struct bitmask *numa_parse_nodestring_all(char *" string );
+.BI "struct bitmask *numa_parse_nodestring_all(const char *" string );
 .br
-.BI "struct bitmask *numa_parse_cpustring(char *" string );
+.BI "struct bitmask *numa_parse_cpustring(const char *" string );
 .br
-.BI "struct bitmask *numa_parse_cpustring_all(char *" string );
+.BI "struct bitmask *numa_parse_cpustring_all(const char *" string );
 .sp
 .BI "long numa_node_size(int " node ", long *" freep );
 .br
diff --git a/numa.h b/numa.h
index ea28774..86d3b2e 100755
--- a/numa.h
+++ b/numa.h
@@ -310,18 +310,18 @@ int numa_sched_getaffinity(pid_t, struct bitmask *);
 int numa_sched_setaffinity(pid_t, struct bitmask *);
 
 /* Convert an ascii list of nodes to a bitmask */
-struct bitmask *numa_parse_nodestring(char *);
+struct bitmask *numa_parse_nodestring(const char *);
 
 /* Convert an ascii list of nodes to a bitmask without current nodeset
  * dependency */
-struct bitmask *numa_parse_nodestring_all(char *);
+struct bitmask *numa_parse_nodestring_all(const char *);
 
 /* Convert an ascii list of cpu to a bitmask */
-struct bitmask *numa_parse_cpustring(char *);
+struct bitmask *numa_parse_cpustring(const char *);
 
 /* Convert an ascii list of cpu to a bitmask without current taskset
  * dependency */
-struct bitmask *numa_parse_cpustring_all(char *);
+struct bitmask *numa_parse_cpustring_all(const char *);
 
 /*
  * The following functions are for source code compatibility
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 6/7] libnuma: removed unused bufferlen variable
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
                   ` (4 preceding siblings ...)
  2012-08-23 16:01 ` [PATCH v2 5/7] libnuma: numa_parse_cpustring and similar should take a const char* parameter Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  2012-08-23 16:01 ` [PATCH v2 7/7] libnuma: no warnings when there are holes in numbering of nodes Petr Holasek
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman; +Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 libnuma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libnuma.c b/libnuma.c
index 9c9a1de..a319bcc 100755
--- a/libnuma.c
+++ b/libnuma.c
@@ -1320,7 +1320,7 @@ __asm__(".symver numa_node_to_cpus_v1,numa_node_to_cpus@libnuma_1.1");
 int
 numa_node_to_cpus_v2(int node, struct bitmask *buffer)
 {
-	int err = 0, bufferlen;
+	int err = 0;
 	int nnodes = numa_max_node();
 	char fn[64], *line = NULL;
 	FILE *f; 
@@ -1330,7 +1330,6 @@ numa_node_to_cpus_v2(int node, struct bitmask *buffer)
 	if (!node_cpu_mask_v2)
 		init_node_cpu_mask_v2();
 
-	bufferlen = numa_bitmask_nbytes(buffer);
 	if (node > nnodes) {
 		errno = ERANGE;
 		return -1;
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 7/7] libnuma: no warnings when there are holes in numbering of nodes
  2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
                   ` (5 preceding siblings ...)
  2012-08-23 16:01 ` [PATCH v2 6/7] libnuma: removed unused bufferlen variable Petr Holasek
@ 2012-08-23 16:01 ` Petr Holasek
  6 siblings, 0 replies; 8+ messages in thread
From: Petr Holasek @ 2012-08-23 16:01 UTC (permalink / raw
  To: Cliff Wickman; +Cc: linux-numa, Andi Kleen, Anton Arapov, Petr Holasek

Some machines don't even export their 0th node to acpi tables when there
is no memory installed. This patch removes warning in such cases.

Signed-off-by: Petr Holasek <pholasek@redhat.com>
---
 distance.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/distance.c b/distance.c
index 2b48f97..4a26972 100755
--- a/distance.c
+++ b/distance.c
@@ -64,7 +64,7 @@ static int read_distance_table(void)
 		sprintf(fn, "/sys/devices/system/node/node%d/distance", nd);
 		dfh = fopen(fn, "r");
 		if (!dfh) {
-			if (errno == ENOENT && nd > 0)
+			if (errno == ENOENT)
 				err = 0;
 			if (!err && nd<maxnode)
 				continue;
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-08-23 16:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-23 16:01 [PATCH v2 0/7] couple of numactl-2.0.8-rc4 bugfixes and new interface Petr Holasek
2012-08-23 16:01 ` [PATCH v2 1/7] libnuma: Fix calculation of maxconfiguredcpu Petr Holasek
2012-08-23 16:01 ` [PATCH v2 2/7] libnuma: do not recalculate maxconfiguredcpu Petr Holasek
2012-08-23 16:01 ` [PATCH v2 3/7] libnuma: numa_num_possible_cpus symbol is exported from the library Petr Holasek
2012-08-23 16:01 ` [RFC PATCH v2 4/7] libnuma: introduced _all versions of numa_parse_{cpu,node}string() Petr Holasek
2012-08-23 16:01 ` [PATCH v2 5/7] libnuma: numa_parse_cpustring and similar should take a const char* parameter Petr Holasek
2012-08-23 16:01 ` [PATCH v2 6/7] libnuma: removed unused bufferlen variable Petr Holasek
2012-08-23 16:01 ` [PATCH v2 7/7] libnuma: no warnings when there are holes in numbering of nodes Petr Holasek

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 read-only IMAP folder(s) and NNTP newsgroup(s).