From: sathnaga@linux.vnet.ibm.com
To: acme@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org
Cc: srikar@linux.vnet.ibm.com, bala24@linux.vnet.ibm.com,
Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Subject: [PATCH v2 1/2] perf/bench/numa: Add functions to detect sparse numa nodes
Date: Mon, 21 Aug 2017 14:57:48 +0530 [thread overview]
Message-ID: <2a54db2b5e75b15c6f214899bdc7b4a6a1568af0.1502971981.git.sathnaga@linux.vnet.ibm.com> (raw)
In-Reply-To: <cover.1502971981.git.sathnaga@linux.vnet.ibm.com>
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: Arnaldo Carvalho de Melo <acme@kernel.org>
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..300faba1 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -215,6 +215,41 @@ static const char * const numa_usage[] = {
NULL
};
+// To get number of numa nodes present.
+static int nr_numa_nodes(void)
+{
+ int i, nr_nodes = 0;
+
+ for (i = 0; i < g->p.nr_nodes; i++) {
+ if (numa_bitmask_isbitset(numa_nodes_ptr, i))
+ nr_nodes++;
+ }
+ return nr_nodes;
+}
+
+// To check if given numa node is present.
+static int is_node_present(int node)
+{
+ return numa_bitmask_isbitset(numa_nodes_ptr, node);
+}
+
+// To check given numa node has cpus.
+static bool node_has_cpus(int node)
+{
+ struct bitmask *cpu = numa_allocate_cpumask();
+ unsigned int i;
+
+ if (cpu == NULL)
+ return false; // lets fall back to nocpus safely
+ if (numa_node_to_cpus(node, cpu) == 0) {
+ for (i = 0; i < cpu->size; i++) {
+ if (numa_bitmask_isbitset(cpu, i))
+ return true;
+ }
+ }
+ return false;
+}
+
static cpu_set_t bind_to_cpu(int target_cpu)
{
cpu_set_t orig_mask, mask;
--
2.7.4
next prev parent reply other threads:[~2017-08-21 9:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-21 9:27 [PATCH v2 0/2] Fixup for discontiguous/sparse numa nodes sathnaga
2017-08-21 9:27 ` sathnaga [this message]
2017-08-21 9:28 ` [PATCH v2 2/2] perf/bench/numa: Handle " sathnaga
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=2a54db2b5e75b15c6f214899bdc7b4a6a1568af0.1502971981.git.sathnaga@linux.vnet.ibm.com \
--to=sathnaga@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=bala24@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=srikar@linux.vnet.ibm.com \
/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).