Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1708269

[PATCH 1/2] perf/bench/numa: Add functions to detect sparse numa nodes

From sathnaga@linux.vnet.ibm.com
Newsgroups linux.kernel
Subject [PATCH 1/2] perf/bench/numa: Add functions to detect sparse numa nodes
Date 2017-08-10 09:30 +0200
Message-ID <ucQ4N-2jh-1@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>

Added functions 1) to get a count of all nodes that are exposed to
userspace. These nodes could be memoryless cpu nodes or cpuless memory
nodes, 2) to check given node is present and 3) to check given
node has cpus

This information can be used to handle sparse/discontiguous nodes.

Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Signed-off-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Signed-off-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
---
 tools/perf/bench/numa.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 469d65b..efd7595 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -215,6 +215,41 @@ static const char * const numa_usage[] = {
 	NULL
 };
 
+static int nr_numa_nodes(void)
+{
+	int node = 0, i;
+
+        for (i = 0; i < g->p.nr_nodes; i++) {
+		if (numa_bitmask_isbitset(numa_nodes_ptr, i))
+			node++;
+	}
+	return node;
+}
+
+static bool is_node_present(int node)
+{
+	if (numa_bitmask_isbitset(numa_nodes_ptr, node))
+		return true;
+	else
+		return false;
+}
+
+static bool is_node_hascpu(int node)
+{
+	struct bitmask *cpu;
+	unsigned int i;
+
+	cpu = numa_allocate_cpumask();
+	if (numa_node_to_cpus(node, cpu) == 0) {
+		for (i = 0; i < cpu->size; i++) {
+			if (numa_bitmask_isbitset(cpu, i))
+				return true;
+			}
+	} else
+		return false; // lets fall back to nocpus safely
+	return false;
+}
+
 static cpu_set_t bind_to_cpu(int target_cpu)
 {
 	cpu_set_t orig_mask, mask;
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] perf/bench/numa: Add functions to detect sparse numa nodes sathnaga@linux.vnet.ibm.com - 2017-08-10 09:30 +0200
  Re: [PATCH 1/2] perf/bench/numa: Add functions to detect sparse numa  nodes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-08-10 21:30 +0200

csiph-web