linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>,
	Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Balamuruhan S <bala24@linux.vnet.ibm.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Sasha Levin <alexander.levin@microsoft.com>
Subject: [PATCH 3.18 39/58] perf bench numa: Fixup discontiguous/sparse numa nodes
Date: Fri, 23 Feb 2018 19:26:38 +0100	[thread overview]
Message-ID: <20180223170212.904805002@linuxfoundation.org> (raw)
In-Reply-To: <20180223170206.724655284@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

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


[ Upstream commit 321a7c35c90cc834851ceda18a8ee18f1d032b92 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 tools/perf/bench/numa.c |   56 +++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 51 insertions(+), 5 deletions(-)

--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -203,6 +203,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;
@@ -231,12 +272,12 @@ static cpu_set_t bind_to_cpu(int target_
 
 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);
@@ -636,7 +677,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;
 				}
@@ -943,6 +984,8 @@ static void calc_convergence(double runt
 	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);
@@ -963,8 +1006,11 @@ static void calc_convergence(double runt
 	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);
 
@@ -1262,7 +1308,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",

  parent reply	other threads:[~2018-02-23 18:31 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-23 18:25 [PATCH 3.18 00/58] 3.18.96-stable review Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 01/58] IB/mlx4: Fix incorrectly releasing steerable UD QPs when have only ETH ports Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 02/58] PM / devfreq: Propagate error from devfreq_add_device() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 03/58] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 04/58] arm: spear600: Add missing interrupt-parent of rtc Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 05/58] arm: spear13xx: Fix dmas cells Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 06/58] arm: spear13xx: Fix spics gpio controllers warning Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 07/58] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 08/58] drm/radeon: adjust tested variable Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 09/58] ext4: save error to disk in __ext4_grp_locked_error() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 10/58] ext4: correct documentation for grpid mount option Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 11/58] video: fbdev: atmel_lcdfb: fix display-timings lookup Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 12/58] console/dummy: leave .con_font_get set to NULL Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 13/58] Btrfs: fix deadlock in run_delalloc_nocow Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 14/58] Btrfs: fix crash due to not cleaning up tree log blocks dirty bits Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 15/58] ALSA: seq: Fix racy pool initializations Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 16/58] ARM: dts: s5pv210: add interrupt-parent for ohci Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 17/58] media: r820t: fix r820t_write_reg for KASAN Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 18/58] mm,vmscan: Make unregister_shrinker() no-op if register_shrinker() failed Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 19/58] xfrm: check id proto in validate_tmpl() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 20/58] selinux: skip bounded transition processing if the policy isnt loaded Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 21/58] crypto: x86/twofish-3way - Fix %rbp usage Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 22/58] staging: android: ion: Add __GFP_NOWARN for system contig heap Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 23/58] netfilter: x_tables: fix int overflow in xt_alloc_table_info() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 24/58] netfilter: x_tables: avoid out-of-bounds reads in xt_request_find_{match|target} Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 25/58] netfilter: ipt_CLUSTERIP: fix out-of-bounds accesses in clusterip_tg_check() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 26/58] netfilter: on sockopt() acquire sock lock only in the required scope Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 27/58] netfilter: xt_RATEEST: acquire xt_rateest_mutex for hash insert Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 28/58] net: avoid skb_warn_bad_offload on IS_ERR Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 29/58] Provide a function to create a NUL-terminated string from unterminated data Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 30/58] selinux: ensure the context is NUL terminated in security_context_to_sid_core() Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 31/58] ASoC: ux500: add MODULE_LICENSE tag Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 32/58] video: fbdev/mmp: add MODULE_LICENSE Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 33/58] dn_getsockoptdecnet: move nf_{get/set}sockopt outside sock lock Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 34/58] usbip: keep usbip_device sockfd state in sync with tcp_socket Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 35/58] usb: build drivers/usb/common/ when USB_SUPPORT is set Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 36/58] ARM: AM33xx: PRM: Remove am33xx_pwrdm_read_prev_pwrst function Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 37/58] ARM: dts: am4372: Correct the interrupts_properties of McASP Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 38/58] perf top: Fix window dimensions change handling Greg Kroah-Hartman
2018-02-23 18:26 ` Greg Kroah-Hartman [this message]
2018-02-23 18:26 ` [PATCH 3.18 40/58] media: s5k6aa: describe some function parameters Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 41/58] scripts/kernel-doc: Dont fail with status != 0 if error encountered with -none Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 42/58] m68k: add missing SOFTIRQENTRY_TEXT linker section Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 43/58] powerpc/perf: Fix oops when grouping different pmu events Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 44/58] s390/dasd: prevent prefix I/O error Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 45/58] gianfar: fix a flooded alignment reports because of padding issue Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 46/58] net_sched: red: Avoid devision by zero Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 47/58] net_sched: red: Avoid illegal values Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 48/58] btrfs: Fix possible off-by-one in btrfs_search_path_in_tree Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 49/58] 509: fix printing uninitialized stack memory when OID is empty Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 50/58] spi: sun4i: disable clocks in the remove function Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 51/58] xfrm: Fix stack-out-of-bounds with misconfigured transport mode policies Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 52/58] dmaengine: jz4740: disable/unprepare clk if probe fails Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 53/58] mm/early_ioremap: Fix boot hang with earlyprintk=efi,keep Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 54/58] x86/mm/kmmio: Fix mmiotrace for page unaligned addresses Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 55/58] xen: XEN_ACPI_PROCESSOR is Dom0-only Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 56/58] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 57/58] KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously Greg Kroah-Hartman
2018-02-23 18:26 ` [PATCH 3.18 58/58] crypto: s5p-sss - Fix kernel Oops in AES-ECB mode Greg Kroah-Hartman
2018-02-23 22:17 ` [PATCH 3.18 00/58] 3.18.96-stable review kernelci.org bot
2018-02-24  0:37 ` Shuah Khan
2018-02-24 11:41 ` Harsh Shandilya
2018-02-24 18:38   ` Greg Kroah-Hartman
2018-02-24 17:54 ` Guenter Roeck

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=20180223170212.904805002@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=acme@redhat.com \
    --cc=alexander.levin@microsoft.com \
    --cc=bala24@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=sathnaga@linux.vnet.ibm.com \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=stable@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).