linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cliff Wickman <cpw@sgi.com>
To: linux-numa@vger.kernel.org
Subject: [PATCH] libnuma: parsing cpu and node strings
Date: Thu, 13 Jan 2011 08:22:55 -0600	[thread overview]
Message-ID: <E1PdO4l-0007Rt-LX@eag09.americas.sgi.com> (raw)

From: Cliff Wickman <cpw@sgi.com>

Fix numa_parse_cpustring() and numa_parse_nodestring() to be cpuset aware.

numa_parse_cpustring() was coded with the assumption that cpu's are
numbered 0..N.  And therefore any cpu number in the parsed string should
be <= N.  Use the cpuset aware bit mask 'numa_all_cpus_ptr' instead.

And similarly numa_parse_nodestring() was coded with the assumption that
nodes are numbered 0..N.  Use the cpuset aware bit mask 'numa_all_nodes_ptr'
instead.

Signed-off-by: Cliff Wickman <cpw@sgi.com>
---
 libnuma.c |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

Index: numactl-dev/libnuma.c
===================================================================
--- numactl-dev.orig/libnuma.c
+++ numactl-dev/libnuma.c
@@ -1753,10 +1753,8 @@ static unsigned long get_nr(char *s, cha
 struct bitmask *
 numa_parse_nodestring(char *s)
 {
-	int maxnode = numa_max_node();
 	int invert = 0, relative = 0;
 	int conf_nodes = numa_num_configured_nodes();
-	int task_nodes = numa_num_task_nodes();
 	char *end;
 	struct bitmask *mask;
 
@@ -1775,12 +1773,10 @@ numa_parse_nodestring(char *s)
 		s++;
 	}
 	do {
-		unsigned long arg;
 		int i;
+		unsigned long arg;
 		if (!strcmp(s,"all")) {
-			int i;
-			for (i = 0; i < task_nodes; i++)
-				numa_bitmask_setbit(mask, i);
+			copy_bitmask_to_bitmask(numa_all_nodes_ptr, mask);
 			s+=4;
 			break;
 		}
@@ -1789,7 +1785,7 @@ numa_parse_nodestring(char *s)
 			numa_warn(W_nodeparse, "unparseable node description `%s'\n", s);
 			goto err;
 		}
-		if (arg > maxnode) {
+		if (!numa_bitmask_isbitset(numa_all_nodes_ptr, arg)) {
 			numa_warn(W_nodeparse, "node argument %d is out of range\n", arg);
 			goto err;
 		}
@@ -1804,7 +1800,7 @@ numa_parse_nodestring(char *s)
 				numa_warn(W_nodeparse, "missing node argument %s\n", s);
 				goto err;
 			}
-			if (arg2 >= task_nodes) {
+			if (!numa_bitmask_isbitset(numa_all_nodes_ptr, arg2)) {
 				numa_warn(W_nodeparse, "node argument %d out of range\n", arg2);
 				goto err;
 			}
@@ -1852,7 +1848,6 @@ numa_parse_cpustring(char *s)
 {
 	int invert = 0, relative=0;
 	int conf_cpus = numa_num_configured_cpus();
-	int task_cpus = numa_num_task_cpus();
 	char *end;
 	struct bitmask *mask;
 
@@ -1873,9 +1868,7 @@ numa_parse_cpustring(char *s)
 		int i;
 
 		if (!strcmp(s,"all")) {
-			int i;
-			for (i = 0; i < task_cpus; i++)
-				numa_bitmask_setbit(mask, i);
+			copy_bitmask_to_bitmask(numa_all_cpus_ptr, mask);
 			s+=4;
 			break;
 		}
@@ -1884,7 +1877,7 @@ numa_parse_cpustring(char *s)
 			numa_warn(W_cpuparse, "unparseable cpu description `%s'\n", s);
 			goto err;
 		}
-		if (arg >= task_cpus) {
+		if (!numa_bitmask_isbitset(numa_all_cpus_ptr, arg)) {
 			numa_warn(W_cpuparse, "cpu argument %s is out of range\n", s);
 			goto err;
 		}
@@ -1900,7 +1893,7 @@ numa_parse_cpustring(char *s)
 				numa_warn(W_cpuparse, "missing cpu argument %s\n", s);
 				goto err;
 			}
-			if (arg2 >= task_cpus) {
+			if (!numa_bitmask_isbitset(numa_all_cpus_ptr, arg2)) {
 				numa_warn(W_cpuparse, "cpu argument %s out of range\n", s);
 				goto err;
 			}

                 reply	other threads:[~2011-01-13 14:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1PdO4l-0007Rt-LX@eag09.americas.sgi.com \
    --to=cpw@sgi.com \
    --cc=linux-numa@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).