linux-numa.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 2/2] libnuma: new function numa_run_on_node_mask_all was added to libnuma
Date: Fri,  6 Sep 2013 16:33:57 +0200	[thread overview]
Message-ID: <1378478037-14996-3-git-send-email-pholasek@redhat.com> (raw)
In-Reply-To: <1378478037-14996-1-git-send-email-pholasek@redhat.com>

---
 libnuma.c         | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 numa.h            |  2 ++
 versions.ldscript |  8 ++++++++
 3 files changed, 56 insertions(+)

diff --git a/libnuma.c b/libnuma.c
index a319bcc..091261c 100755
--- a/libnuma.c
+++ b/libnuma.c
@@ -1524,6 +1524,52 @@ __asm__(".symver numa_run_on_node_mask_v2,numa_run_on_node_mask@@libnuma_1.2");
 
 make_internal_alias(numa_run_on_node_mask_v2);
 
+/*
+ * Given a node mask (size of a kernel nodemask_t) (probably populated by
+ * a user argument list) set up a map of cpus (map "cpus") on those nodes
+ * without any cpuset awareness. Then set affinity to those cpus.
+ */
+int
+numa_run_on_node_mask_all(struct bitmask *bmp)
+{
+	int ncpus, i, k, err;
+	struct bitmask *cpus, *nodecpus;
+
+	cpus = numa_allocate_cpumask();
+	ncpus = cpus->size;
+	nodecpus = numa_allocate_cpumask();
+
+	for (i = 0; i < bmp->size; i++) {
+		if (bmp->maskp[i / BITS_PER_LONG] == 0)
+			continue;
+		if (numa_bitmask_isbitset(bmp, i)) {
+			if (!numa_bitmask_isbitset(numa_possible_nodes_ptr, i)) {
+				numa_warn(W_noderunmask,
+					"node %d not allowed", i);
+				continue;
+			}
+			if (numa_node_to_cpus_v2_int(i, nodecpus) < 0) {
+				numa_warn(W_noderunmask,
+					"Cannot read node cpumask from sysfs");
+				continue;
+			}
+			for (k = 0; k < CPU_LONGS(ncpus); k++)
+				cpus->maskp[k] |= nodecpus->maskp[k];
+		}
+	}
+	err = numa_sched_setaffinity_v2_int(0, cpus);
+
+	numa_bitmask_free(cpus);
+	numa_bitmask_free(nodecpus);
+
+	/* With possible nodes freedom it can happen easily now */
+	if (err < 0) {
+		numa_error("numa_sched_setaffinity_v2_int() failed; abort\n");
+	}
+
+	return err;
+}
+
 nodemask_t
 numa_get_run_node_mask_v1(void)
 {
diff --git a/numa.h b/numa.h
index 5982fdc..01b3165 100755
--- a/numa.h
+++ b/numa.h
@@ -238,6 +238,8 @@ void numa_police_memory(void *start, size_t size);
 
 /* Run current task only on nodes in mask */
 int numa_run_on_node_mask(struct bitmask *mask);
+/* Run current task on nodes in mask without any cpuset awareness */
+int numa_run_on_node_mask_all(struct bitmask *mask);
 /* Run current task only on node */
 int numa_run_on_node(int node);
 /* Return current mask of nodes the task can run on */
diff --git a/versions.ldscript b/versions.ldscript
index 2f2d254..eaddc7e 100755
--- a/versions.ldscript
+++ b/versions.ldscript
@@ -165,3 +165,11 @@ libnuma_1.3 {
     *;
 } libnuma_1.2;
 
+# New interface with customizable cpuset awareness
+# was added into version 1.4
+libnuma_1.4 {
+  global:
+    numa_run_on_node_mask_all;
+  local:
+    *;
+} libnuma_1.3;
-- 
1.8.1.4

  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 ` [PATCH 1/2] numactl: new option --all/-a was added for policy settings Petr Holasek
2013-09-06 14:33 ` Petr Holasek [this message]
2013-09-06 19:24   ` [PATCH 2/2] libnuma: new function numa_run_on_node_mask_all was added to libnuma 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-3-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).