From: Petr Holasek <pholasek@redhat.com>
To: Cliff Wickman <cpw@sgi.com>
Cc: Andi Kleen <andi@firstfloor.org>,
linux-numa@vger.kernel.org, Petr Holasek <pholasek@redhat.com>
Subject: [PATCH 1/2] numactl: new option --all/-a was added for policy settings
Date: Fri, 6 Sep 2013 16:33:56 +0200 [thread overview]
Message-ID: <1378478037-14996-2-git-send-email-pholasek@redhat.com> (raw)
In-Reply-To: <1378478037-14996-1-git-send-email-pholasek@redhat.com>
---
numactl.8 | 6 ++++++
numactl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/numactl.8 b/numactl.8
index 576cdb6..7a001c0 100644
--- a/numactl.8
+++ b/numactl.8
@@ -23,6 +23,8 @@ numactl \- Control NUMA policy for processes or shared memory
.SH SYNOPSIS
.B numactl
[
+.B \-\-all
+] [
.B \-\-interleave nodes
] [
.B \-\-preferred node
@@ -107,6 +109,10 @@ for udev names in /dev use
.TP
Policy settings are:
.TP
+.B \-\-all, \-a
+Unset default cpuset awareness, so user can use all possible CPUs/nodes
+for following policy settings.
+.TP
.B \-\-interleave=nodes, \-i nodes
Set a memory interleave policy. Memory will be allocated using round robin
on
diff --git a/numactl.c b/numactl.c
index e1d5487..97955a4 100755
--- a/numactl.c
+++ b/numactl.c
@@ -29,9 +29,13 @@
#include "util.h"
#include "shm.h"
+#define CPUSET 0
+#define ALL 1
+
int exitcode;
struct option opts[] = {
+ {"all", 0, 0, 'a'},
{"interleave", 1, 0, 'i' },
{"preferred", 1, 0, 'p' },
{"cpubind", 1, 0, 'c' },
@@ -60,7 +64,7 @@ struct option opts[] = {
void usage(void)
{
fprintf(stderr,
- "usage: numactl [--interleave= | -i <nodes>] [--preferred= | -p <node>]\n"
+ "usage: numactl [--all | -a] [--interleave= | -i <nodes>] [--preferred= | -p <node>]\n"
" [--physcpubind= | -C <cpus>] [--cpunodebind= | -N <nodes>]\n"
" [--membind= | -m <nodes>] [--localalloc | -l] command args ...\n"
" numactl [--show | -s]\n"
@@ -328,6 +332,8 @@ int did_strict = 0;
int do_shm = 0;
int do_dump = 0;
int shmattached = 0;
+int did_node_cpu_parse = 0;
+int parse_all = 0;
char *shmoption;
void check_cpubind(int flag)
@@ -355,6 +361,12 @@ void needshm(char *opt)
usage_msg("%s must be after shared memory specification", opt);
}
+void check_all_parse(int flag)
+{
+ if (did_node_cpu_parse)
+ usage_msg("--all/-a option must be before all cpu/node specifications");
+}
+
void get_short_opts(struct option *o, char *s)
{
*s++ = '+';
@@ -379,7 +391,7 @@ void check_shmbeyond(char *msg)
}
}
-static struct bitmask *numactl_parse_nodestring(char *s)
+static struct bitmask *numactl_parse_nodestring(char *s, int flag)
{
static char *last;
@@ -390,7 +402,11 @@ static struct bitmask *numactl_parse_nodestring(char *s)
} else {
last = s;
}
- return numa_parse_nodestring(s);
+
+ if (flag == ALL)
+ return numa_parse_nodestring_all(s);
+ else
+ return numa_parse_nodestring(s);
}
int main(int ac, char **av)
@@ -413,13 +429,17 @@ int main(int ac, char **av)
exit(0);
case 'i': /* --interleave */
checknuma();
- mask = numactl_parse_nodestring(optarg);
+ if (parse_all)
+ mask = numactl_parse_nodestring(optarg, ALL);
+ else
+ mask = numactl_parse_nodestring(optarg, CPUSET);
if (!mask) {
printf ("<%s> is invalid\n", optarg);
usage();
}
errno = 0;
+ did_node_cpu_parse = 1;
setpolicy(MPOL_INTERLEAVE);
if (shmfd >= 0)
numa_interleave_memory(shmptr, shmlen, mask);
@@ -431,7 +451,10 @@ int main(int ac, char **av)
case 'c': /* --cpubind */
dontshm("-c/--cpubind/--cpunodebind");
checknuma();
- mask = numactl_parse_nodestring(optarg);
+ if (parse_all)
+ mask = numactl_parse_nodestring(optarg, ALL);
+ else
+ mask = numactl_parse_nodestring(optarg, CPUSET);
if (!mask) {
printf ("<%s> is invalid\n", optarg);
usage();
@@ -439,14 +462,18 @@ int main(int ac, char **av)
errno = 0;
check_cpubind(do_shm);
did_cpubind = 1;
- numa_run_on_node_mask(mask);
+ did_node_cpu_parse = 1;
+ numa_run_on_node_mask_all(mask);
checkerror("sched_setaffinity");
break;
case 'C': /* --physcpubind */
{
struct bitmask *cpubuf;
dontshm("-C/--physcpubind");
- cpubuf = numa_parse_cpustring(optarg);
+ if (parse_all)
+ cpubuf = numa_parse_cpustring_all(optarg);
+ else
+ cpubuf = numa_parse_cpustring(optarg);
if (!cpubuf) {
printf ("<%s> is invalid\n", optarg);
usage();
@@ -454,6 +481,7 @@ int main(int ac, char **av)
errno = 0;
check_cpubind(do_shm);
did_cpubind = 1;
+ did_node_cpu_parse = 1;
numa_sched_setaffinity(0, cpubuf);
checkerror("sched_setaffinity");
free(cpubuf);
@@ -462,12 +490,16 @@ int main(int ac, char **av)
case 'm': /* --membind */
checknuma();
setpolicy(MPOL_BIND);
- mask = numactl_parse_nodestring(optarg);
+ if (parse_all)
+ mask = numactl_parse_nodestring(optarg, ALL);
+ else
+ mask = numactl_parse_nodestring(optarg, CPUSET);
if (!mask) {
printf ("<%s> is invalid\n", optarg);
usage();
}
errno = 0;
+ did_node_cpu_parse = 1;
numa_set_bind_policy(1);
if (shmfd >= 0) {
numa_tonodemask_memory(shmptr, shmlen, mask);
@@ -480,7 +512,10 @@ int main(int ac, char **av)
case 'p': /* --preferred */
checknuma();
setpolicy(MPOL_PREFERRED);
- mask = numactl_parse_nodestring(optarg);
+ if (parse_all)
+ mask = numactl_parse_nodestring(optarg, ALL);
+ else
+ mask = numactl_parse_nodestring(optarg, CPUSET);
if (!mask) {
printf ("<%s> is invalid\n", optarg);
usage();
@@ -495,6 +530,7 @@ int main(int ac, char **av)
usage();
numa_bitmask_free(mask);
errno = 0;
+ did_node_cpu_parse = 1;
numa_set_bind_policy(0);
if (shmfd >= 0)
numa_tonode_memory(shmptr, shmlen, node);
@@ -586,6 +622,10 @@ int main(int ac, char **av)
verify_shm(set_policy, mask);
break;
+ case 'a': /* --all */
+ check_all_parse(did_node_cpu_parse);
+ parse_all = 1;
+ break;
default:
usage();
}
--
1.8.1.4
next prev parent reply other threads:[~2013-09-06 14:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 14:33 [PATCH 0/2] New numactl option for overriding of policy settings cpuset awareness Petr Holasek
2013-09-06 14:33 ` Petr Holasek [this message]
2013-09-06 14:33 ` [PATCH 2/2] libnuma: new function numa_run_on_node_mask_all was added to libnuma Petr Holasek
2013-09-06 19:24 ` Andi Kleen
2013-09-06 19:50 ` [PATCH 0/2] New numactl option for overriding of policy settings cpuset awareness Cliff Wickman
2013-09-08 18:01 ` Petr Holasek
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=1378478037-14996-2-git-send-email-pholasek@redhat.com \
--to=pholasek@redhat.com \
--cc=andi@firstfloor.org \
--cc=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 NNTP newsgroup(s).