* [PATCH v2 1/6] perf: Refactor svg_build_topology_map
@ 2019-08-14 20:38 Kyle Meyer
2019-08-16 9:05 ` Jiri Olsa
0 siblings, 1 reply; 2+ messages in thread
From: Kyle Meyer @ 2019-08-14 20:38 UTC (permalink / raw)
Cc: Kyle Meyer, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Alexander Shishkin, Jiri Olsa,
Namhyung Kim, linux-kernel, Russ Anderson, Kyle Meyer
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 | 23 +++++++++++------------
tools/perf/util/svghelper.h | 4 +++-
3 files changed, 15 insertions(+), 17 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 ae6a534a7a80..1beeb7291361 100644
--- a/tools/perf/util/svghelper.c
+++ b/tools/perf/util/svghelper.c
@@ -751,38 +751,37 @@ 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;
- 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));
if (!t.sib_core || !t.sib_thr) {
fprintf(stderr, "topology: no memory\n");
goto exit;
}
- for (i = 0; i < sib_core_nr; i++) {
- if (str_to_bitmap(sib_core, &t.sib_core[i])) {
+ for (i = 0; i < env->nr_sibling_cores; i++) {
+ if (str_to_bitmap(env->sibling_cores, &t.sib_core[i])) {
fprintf(stderr, "topology: can't parse siblings map\n");
goto exit;
}
- sib_core += strlen(sib_core) + 1;
+ env->sibling_cores += strlen(env->sibling_cores) + 1;
}
- for (i = 0; i < sib_thr_nr; i++) {
- if (str_to_bitmap(sib_thr, &t.sib_thr[i])) {
+ for (i = 0; i < env->nr_sibling_threads; i++) {
+ if (str_to_bitmap(env->sibling_threads, &t.sib_thr[i])) {
fprintf(stderr, "topology: can't parse siblings map\n");
goto exit;
}
- sib_thr += strlen(sib_thr) + 1;
+ env->sibling_threads += strlen(env->sibling_threads) + 1;
}
topology_map = malloc(sizeof(int) * MAX_NR_CPUS);
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/6] perf: Refactor svg_build_topology_map
2019-08-14 20:38 [PATCH v2 1/6] perf: Refactor svg_build_topology_map Kyle Meyer
@ 2019-08-16 9:05 ` Jiri Olsa
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Olsa @ 2019-08-16 9:05 UTC (permalink / raw)
To: Kyle Meyer
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Alexander Shishkin, Namhyung Kim, linux-kernel, Russ Anderson,
Kyle Meyer
On Wed, Aug 14, 2019 at 03:38:24PM -0500, Kyle Meyer wrote:
SNIP
> diff --git a/tools/perf/util/svghelper.c b/tools/perf/util/svghelper.c
> index ae6a534a7a80..1beeb7291361 100644
> --- a/tools/perf/util/svghelper.c
> +++ b/tools/perf/util/svghelper.c
> @@ -751,38 +751,37 @@ 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;
>
> - 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));
>
> if (!t.sib_core || !t.sib_thr) {
> fprintf(stderr, "topology: no memory\n");
> goto exit;
> }
>
> - for (i = 0; i < sib_core_nr; i++) {
> - if (str_to_bitmap(sib_core, &t.sib_core[i])) {
> + for (i = 0; i < env->nr_sibling_cores; i++) {
> + if (str_to_bitmap(env->sibling_cores, &t.sib_core[i])) {
> fprintf(stderr, "topology: can't parse siblings map\n");
> goto exit;
> }
>
> - sib_core += strlen(sib_core) + 1;
> + env->sibling_cores += strlen(env->sibling_cores) + 1;
so this will actualy change env->sibling_cores in the header,
I guess thats not a problem for timechart, but might cause some
confusion in future.. could you just use local pointer for that?
other than that the patchset looks good
thanks,
jirka
> }
>
> - for (i = 0; i < sib_thr_nr; i++) {
> - if (str_to_bitmap(sib_thr, &t.sib_thr[i])) {
> + for (i = 0; i < env->nr_sibling_threads; i++) {
> + if (str_to_bitmap(env->sibling_threads, &t.sib_thr[i])) {
> fprintf(stderr, "topology: can't parse siblings map\n");
> goto exit;
> }
>
> - sib_thr += strlen(sib_thr) + 1;
> + env->sibling_threads += strlen(env->sibling_threads) + 1;
> }
>
SNIP
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-16 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 20:38 [PATCH v2 1/6] perf: Refactor svg_build_topology_map Kyle Meyer
2019-08-16 9:05 ` Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.