[PATCH 1/8] Add support for a "same" numamask to numactl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

With more complicated node masks it gets a bit annoying
to type them multiple times, e.g. for -c and -m. Add
a "same" alias that just refers to the previous nodemask.

Since this is only well defined on the command line implement
it in numactl only.
---
 CHANGES         |    3 +++
 numactl.8       |    4 +++-
 numactl.c       |   22 ++++++++++++++++++----
 4 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/CHANGES b/CHANGES
index f8cb229..d63aa12 100644
--- a/CHANGES
+++ b/CHANGES
@@ -356,3 +356,6 @@ newer:
 - 110818 Checking of sucessful allocations in numademo (Petr Holasek)
 2.0.8-rc2
 - 110823 Fix of numactl (--touch) warnings and man page (Cliff W.)
+
+
+- Add "same" nodemask alias to numactl (Andi Kleen)
diff --git a/numactl.8 b/numactl.8
index e5c7ef6..684e80a 100644
--- a/numactl.8
+++ b/numactl.8
@@ -95,7 +95,9 @@ may be specifed as +N,N,N or  +N-N or +N,N-N and so forth. The + indicates that
 the node numbers are relative to the process' set of allowed nodes in its
 current cpuset.
 A !N-N notation indicates the inverse of N-N, in other words all nodes
-except N-N.  If used with + notation, specify !+N-N.
+except N-N.  If used with + notation, specify !+N-N. When 
+.I same 
+is specified the previous nodemask specified on the command line is used.
 .TP
 .B \-\-membind=nodes, \-m nodes
 Only allocate memory from nodes.  Allocation will fail when there
diff --git a/numactl.c b/numactl.c
index a47a2cf..d1be03c 100755
--- a/numactl.c
+++ b/numactl.c
@@ -366,6 +366,20 @@ void check_shmbeyond(char *msg)
 	}
 }
 
+static struct bitmask *numactl_parse_nodestring(char *s)
+{
+	static char *last;
+
+	if (s[0] == 's' && !strcmp(s, "same")) {
+		if (!last)
+			usage_msg("same needs previous node specification");
+		s = last;
+	} else {
+		last = s;
+	}
+	return numa_parse_nodestring(s);
+}
+
 int main(int ac, char **av)
 {
 	int c, i, nnodes=0;
@@ -386,7 +400,7 @@ int main(int ac, char **av)
 			exit(0);
 		case 'i': /* --interleave */
 			checknuma();
-			mask = numa_parse_nodestring(optarg);
+			mask = numactl_parse_nodestring(optarg);
 			if (!mask) {
 				printf ("<%s> is invalid\n", optarg);
 				usage();
@@ -404,7 +418,7 @@ int main(int ac, char **av)
 		case 'c': /* --cpubind */
 			dontshm("-c/--cpubind/--cpunodebind");
 			checknuma();
-			mask = numa_parse_nodestring(optarg);
+			mask = numactl_parse_nodestring(optarg);
 			if (!mask) {
 				printf ("<%s> is invalid\n", optarg);
 				usage();
@@ -435,7 +449,7 @@ int main(int ac, char **av)
 		case 'm': /* --membind */
 			checknuma();
 			setpolicy(MPOL_BIND);
-			mask = numa_parse_nodestring(optarg);
+			mask = numactl_parse_nodestring(optarg);
 			if (!mask) {
 				printf ("<%s> is invalid\n", optarg);
 				usage();
@@ -453,7 +467,7 @@ int main(int ac, char **av)
 		case 'p': /* --preferred */
 			checknuma();
 			setpolicy(MPOL_PREFERRED);
-			mask = numa_parse_nodestring(optarg);
+			mask = numactl_parse_nodestring(optarg);
 			if (!mask) {
 				printf ("<%s> is invalid\n", optarg);
 				usage();
--
To unsubscribe from this list: send the line "unsubscribe linux-numa" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]     [Devices]

  Powered by Linux