linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kyle Meyer <meyerk@hpe.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Kyle Meyer <meyerk@hpe.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org,
	Russ Anderson <russ.anderson@hpe.com>,
	Kyle Meyer <kyle.meyer@hpe.com>
Subject: [PATCH v4 1/7] perf: Refactor svg_build_topology_map
Date: Tue, 27 Aug 2019 16:43:46 -0500	[thread overview]
Message-ID: <20190827214352.94272-2-meyerk@stormcage.eag.rdlabs.hpecorp.net> (raw)
In-Reply-To: <20190827214352.94272-1-meyerk@stormcage.eag.rdlabs.hpecorp.net>

Exchange the parameters of svg_build_topology_map with struct perf_env
*env and adjust the function accordingly. This patch should not change any
behavior, it is merely refactoring for the following patch.

Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: Russ Anderson <russ.anderson@hpe.com>
Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
---
 tools/perf/builtin-timechart.c |  5 +----
 tools/perf/util/svghelper.c    | 19 +++++++++++--------
 tools/perf/util/svghelper.h    |  4 +++-
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 7d6a6ecf4e02..1ff81a790931 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1518,10 +1518,7 @@ static int process_header(struct perf_file_section *section __maybe_unused,
 		if (!tchart->topology)
 			break;
 
-		if (svg_build_topology_map(ph->env.sibling_cores,
-					   ph->env.nr_sibling_cores,
-					   ph->env.sibling_threads,
-					   ph->env.nr_sibling_threads))
+		if (svg_build_topology_map(&ph->env))
 			fprintf(stderr, "problem building topology\n");
 		break;
 
diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
index bbdd87163285..4d2ac55267fc 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -752,23 +752,26 @@ static int str_to_bitmap(char *s, cpumask_t *b)
 	return ret;
 }
 
-int svg_build_topology_map(char *sib_core, int sib_core_nr,
-			   char *sib_thr, int sib_thr_nr)
+int svg_build_topology_map(struct perf_env *env)
 {
 	int i;
 	struct topology t;
+	char *sib_core, *sib_thr;
 
-	t.sib_core_nr = sib_core_nr;
-	t.sib_thr_nr = sib_thr_nr;
-	t.sib_core = calloc(sib_core_nr, sizeof(cpumask_t));
-	t.sib_thr = calloc(sib_thr_nr, sizeof(cpumask_t));
+	t.sib_core_nr = env->nr_sibling_cores;
+	t.sib_thr_nr = env->nr_sibling_threads;
+	t.sib_core = calloc(env->nr_sibling_cores, sizeof(cpumask_t));
+	t.sib_thr = calloc(env->nr_sibling_threads, sizeof(cpumask_t));
+
+	sib_core = env->sibling_cores;
+	sib_thr = env->sibling_threads;
 
 	if (!t.sib_core || !t.sib_thr) {
 		fprintf(stderr, "topology: no memory\n");
 		goto exit;
 	}
 
-	for (i = 0; i < sib_core_nr; i++) {
+	for (i = 0; i < env->nr_sibling_cores; i++) {
 		if (str_to_bitmap(sib_core, &t.sib_core[i])) {
 			fprintf(stderr, "topology: can't parse siblings map\n");
 			goto exit;
@@ -777,7 +780,7 @@ int svg_build_topology_map(char *sib_core, int sib_core_nr,
 		sib_core += strlen(sib_core) + 1;
 	}
 
-	for (i = 0; i < sib_thr_nr; i++) {
+	for (i = 0; i < env->nr_sibling_threads; i++) {
 		if (str_to_bitmap(sib_thr, &t.sib_thr[i])) {
 			fprintf(stderr, "topology: can't parse siblings map\n");
 			goto exit;
diff --git a/tools/perf/util/svghelper.h b/tools/perf/util/svghelper.h
index e55338d5c3bd..2add34c75733 100644
--- a/tools/perf/util/svghelper.h
+++ b/tools/perf/util/svghelper.h
@@ -4,6 +4,8 @@
 
 #include <linux/types.h>
 
+#include "env.h"
+
 void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end);
 void svg_ubox(int Yslot, u64 start, u64 end, double height, const char *type, int fd, int err, int merges);
 void svg_lbox(int Yslot, u64 start, u64 end, double height, const char *type, int fd, int err, int merges);
@@ -28,7 +30,7 @@ void svg_partial_wakeline(u64 start, int row1, char *desc1, int row2, char *desc
 void svg_interrupt(u64 start, int row, const char *backtrace);
 void svg_text(int Yslot, u64 start, const char *text);
 void svg_close(void);
-int svg_build_topology_map(char *sib_core, int sib_core_nr, char *sib_thr, int sib_thr_nr);
+int svg_build_topology_map(struct perf_env *env);
 
 extern int svg_page_width;
 extern u64 svg_highlight;
-- 
2.12.3


       reply	other threads:[~2019-08-27 21:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190827214352.94272-1-meyerk@stormcage.eag.rdlabs.hpecorp.net>
2019-08-27 21:43 ` Kyle Meyer [this message]
2019-08-29  9:11   ` [PATCH v4 1/7] perf: Refactor svg_build_topology_map Jiri Olsa
2019-08-29 15:49     ` Arnaldo Carvalho de Melo
2019-09-02  8:16   ` [tip: perf/core] perf timechart: Refactor svg_build_topology_map() tip-bot2 for Kyle Meyer
2019-08-27 21:43 ` [PATCH v4 2/7] perf/util/svghelper: Replace MAX_NR_CPUS with env->nr_cpus_online Kyle Meyer
2019-09-02  8:16   ` [tip: perf/core] perf svghelper: Replace MAX_NR_CPUS with perf_env::nr_cpus_online tip-bot2 for Kyle Meyer
2019-08-27 21:43 ` [PATCH v4 3/7] perf/util/stat: Replace MAX_NR_CPUS with cpu__max_cpu Kyle Meyer
2019-09-02  8:16   ` [tip: perf/core] perf stat: Replace MAX_NR_CPUS with cpu__max_cpu() tip-bot2 for Kyle Meyer
2019-08-27 21:43 ` [PATCH v4 4/7] perf/util/session: Replace MAX_NR_CPUS with nr_cpus_online Kyle Meyer
2019-09-02  8:16   ` [tip: perf/core] perf session: Replace MAX_NR_CPUS with perf_env::nr_cpus_online tip-bot2 for Kyle Meyer
2019-08-27 21:43 ` [PATCH v4 5/7] perf/util/machine: Replace MAX_NR_CPUS with nr_cpus_online Kyle Meyer
2019-09-02  8:16   ` [tip: perf/core] perf machine: Replace MAX_NR_CPUS with perf_env::nr_cpus_online tip-bot2 for Kyle Meyer
2019-08-27 21:43 ` [PATCH v4 6/7] perf/util/header: Replace MAX_NR_CPUS with cpu__max_cpu Kyle Meyer
2019-09-02  8:16   ` [tip: perf/core] perf header: Replace MAX_NR_CPUS with cpu__max_cpu() tip-bot2 for Kyle Meyer
2019-08-27 21:43 ` [PATCH v4 7/7] perf/lib/cpumap: Warn when exceeding MAX_NR_CPUS Kyle Meyer
2019-09-02  8:16   ` [tip: perf/core] libperf: Warn when exceeding MAX_NR_CPUS in cpumap tip-bot2 for Kyle Meyer

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=20190827214352.94272-2-meyerk@stormcage.eag.rdlabs.hpecorp.net \
    --to=meyerk@hpe.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=kyle.meyer@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=russ.anderson@hpe.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).