From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>,
Balamuruhan S <bala24@linux.vnet.ibm.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 19/30] perf bench numa: Fixup discontiguous/sparse numa nodes
Date: Tue, 28 Nov 2017 12:02:09 -0300 [thread overview]
Message-ID: <20171128150220.5064-20-acme@kernel.org> (raw)
In-Reply-To: <20171128150220.5064-1-acme@kernel.org>
From: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Certain systems are designed to have sparse/discontiguous nodes. On
such systems, 'perf bench numa' hangs, shows wrong number of nodes and
shows values for non-existent nodes. Handle this by only taking nodes
that are exposed by kernel to userspace.
Signed-off-by: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/1edbcd353c009e109e93d78f2f46381930c340fe.1511368645.git.sathnaga@linux.vnet.ibm.com
Signed-off-by: Balamuruhan S <bala24@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/bench/numa.c | 56 ++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 51 insertions(+), 5 deletions(-)
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index d95fdcc26f4b..944070e98a2c 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -216,6 +216,47 @@ 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 && !numa_node_to_cpus(node, cpu)) {
+ for (i = 0; i < cpu->size; i++) {
+ if (numa_bitmask_isbitset(cpu, i))
+ return true;
+ }
+ }
+
+ return false; /* lets fall back to nocpus safely */
+}
+
static cpu_set_t bind_to_cpu(int target_cpu)
{
cpu_set_t orig_mask, mask;
@@ -244,12 +285,12 @@ static cpu_set_t bind_to_cpu(int target_cpu)
static cpu_set_t bind_to_node(int target_node)
{
- int cpus_per_node = g->p.nr_cpus/g->p.nr_nodes;
+ int cpus_per_node = g->p.nr_cpus / nr_numa_nodes();
cpu_set_t orig_mask, mask;
int cpu;
int ret;
- BUG_ON(cpus_per_node*g->p.nr_nodes != g->p.nr_cpus);
+ BUG_ON(cpus_per_node * nr_numa_nodes() != g->p.nr_cpus);
BUG_ON(!cpus_per_node);
ret = sched_getaffinity(0, sizeof(orig_mask), &orig_mask);
@@ -649,7 +690,7 @@ static int parse_setup_node_list(void)
int i;
for (i = 0; i < mul; i++) {
- if (t >= g->p.nr_tasks) {
+ if (t >= g->p.nr_tasks || !node_has_cpus(bind_node)) {
printf("\n# NOTE: ignoring bind NODEs starting at NODE#%d\n", bind_node);
goto out;
}
@@ -964,6 +1005,8 @@ static void calc_convergence(double runtime_ns_max, double *convergence)
sum = 0;
for (node = 0; node < g->p.nr_nodes; node++) {
+ if (!is_node_present(node))
+ continue;
nr = nodes[node];
nr_min = min(nr, nr_min);
nr_max = max(nr, nr_max);
@@ -984,8 +1027,11 @@ static void calc_convergence(double runtime_ns_max, double *convergence)
process_groups = 0;
for (node = 0; node < g->p.nr_nodes; node++) {
- int processes = count_node_processes(node);
+ int processes;
+ if (!is_node_present(node))
+ continue;
+ processes = count_node_processes(node);
nr = nodes[node];
tprintf(" %2d/%-2d", nr, processes);
@@ -1291,7 +1337,7 @@ static void print_summary(void)
printf("\n ###\n");
printf(" # %d %s will execute (on %d nodes, %d CPUs):\n",
- g->p.nr_tasks, g->p.nr_tasks == 1 ? "task" : "tasks", g->p.nr_nodes, g->p.nr_cpus);
+ g->p.nr_tasks, g->p.nr_tasks == 1 ? "task" : "tasks", nr_numa_nodes(), g->p.nr_cpus);
printf(" # %5dx %5ldMB global shared mem operations\n",
g->p.nr_loops, g->p.bytes_global/1024/1024);
printf(" # %5dx %5ldMB process shared mem operations\n",
--
2.13.6
next prev parent reply other threads:[~2017-11-28 15:02 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 15:01 [GIT PULL 00/30] perf/urgent fixes Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 01/30] perf evlist: Set the correct idx when adding dummy events Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 02/30] perf record: Generate PERF_RECORD_{MMAP,COMM,EXEC} with --delay Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 03/30] perf record: Fix -c/-F options for cpu event aliases Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 04/30] perf trace: Fix an exit code of trace__symbols_init Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 05/30] perf evsel: Fix up leftover perf_evsel_stat usage via evsel->priv Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 06/30] perf script: Fix --per-event-dump for auxtrace synth evsels Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 07/30] perf machine: Guard against NULL in machine__exit() Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 08/30] perf help: Fix a bug during strstart() conversion Arnaldo Carvalho de Melo
2017-11-28 15:01 ` [PATCH 09/30] perf annotate: Do not truncate instruction names at 6 chars Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 10/30] perf test shell: Fix check open filename arg using 'perf trace' on s390x Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 11/30] perf test shell: Fix test case probe libc's inet_pton " Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 12/30] perf evlist: Add helper to check if attr.exclude_kernel is set in all evsels Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 13/30] perf report: Ignore kptr_restrict when not sampling the kernel Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 14/30] perf record: " Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 15/30] perf top: " Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 16/30] perf: Fix header.size for namespace events Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 17/30] perf top: Fix window dimensions change handling Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 18/30] perf top: Use signal interface for SIGWINCH handler Arnaldo Carvalho de Melo
2017-11-28 15:02 ` Arnaldo Carvalho de Melo [this message]
2017-11-28 15:02 ` [PATCH 20/30] perf test: Fix test 21 for s390x Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 21/30] perf intel-pt: Bring instruction decoder files into line with the kernel Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 22/30] tools/headers: Synchronize kernel x86 UAPI headers Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 23/30] tools headers: Synchronize kernel ABI headers wrt SPDX tags Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 24/30] tools headers: Synchronize perf_event.h header Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 25/30] tools headers uapi: Synchronize drm/drm.h Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 26/30] tools headers: Synchronize drm/i915_drm.h Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 27/30] tools headers: Synchronize KVM arch ABI headers Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 28/30] tools headers: Synchronize prctl.h ABI header Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 29/30] tools headers: Syncronize mman.h " Arnaldo Carvalho de Melo
2017-11-28 15:02 ` [PATCH 30/30] perf tools s390: Do not include header files from the kernel sources Arnaldo Carvalho de Melo
2017-11-28 16:20 ` [GIT PULL 00/30] perf/urgent fixes Ingo Molnar
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=20171128150220.5064-20-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=bala24@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=sathnaga@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).