Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf timechart: Refactor svg_build_topology_map()

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.

Committer notes:

No need to include env.h from svghelper.h, all it needs is a forward
declaration for 'struct perf_env', so move the include directive to
svghelper.c, where it is really needed.

Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com>
Reviewed-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Russ Anderson <russ.anderson@hpe.com>
Link: http://lore.kernel.org/lkml/20190827214352.94272-2-meyerk@stormcage.eag.rdlabs.hpecorp.net
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Kyle Meyer and committed by
Arnaldo Carvalho de Melo
0ac1dd5b 67260e8c

+16 -13
+1 -4
tools/perf/builtin-timechart.c
··· 1518 1518 if (!tchart->topology) 1519 1519 break; 1520 1520 1521 - if (svg_build_topology_map(ph->env.sibling_cores, 1522 - ph->env.nr_sibling_cores, 1523 - ph->env.sibling_threads, 1524 - ph->env.nr_sibling_threads)) 1521 + if (svg_build_topology_map(&ph->env)) 1525 1522 fprintf(stderr, "problem building topology\n"); 1526 1523 break; 1527 1524
+12 -8
tools/perf/util/svghelper.c
··· 19 19 #include <linux/zalloc.h> 20 20 #include <perf/cpumap.h> 21 21 22 + #include "env.h" 22 23 #include "perf.h" 23 24 #include "svghelper.h" 24 25 #include "cpumap.h" ··· 753 752 return ret; 754 753 } 755 754 756 - int svg_build_topology_map(char *sib_core, int sib_core_nr, 757 - char *sib_thr, int sib_thr_nr) 755 + int svg_build_topology_map(struct perf_env *env) 758 756 { 759 757 int i; 760 758 struct topology t; 759 + char *sib_core, *sib_thr; 761 760 762 - t.sib_core_nr = sib_core_nr; 763 - t.sib_thr_nr = sib_thr_nr; 764 - t.sib_core = calloc(sib_core_nr, sizeof(cpumask_t)); 765 - t.sib_thr = calloc(sib_thr_nr, sizeof(cpumask_t)); 761 + t.sib_core_nr = env->nr_sibling_cores; 762 + t.sib_thr_nr = env->nr_sibling_threads; 763 + t.sib_core = calloc(env->nr_sibling_cores, sizeof(cpumask_t)); 764 + t.sib_thr = calloc(env->nr_sibling_threads, sizeof(cpumask_t)); 765 + 766 + sib_core = env->sibling_cores; 767 + sib_thr = env->sibling_threads; 766 768 767 769 if (!t.sib_core || !t.sib_thr) { 768 770 fprintf(stderr, "topology: no memory\n"); 769 771 goto exit; 770 772 } 771 773 772 - for (i = 0; i < sib_core_nr; i++) { 774 + for (i = 0; i < env->nr_sibling_cores; i++) { 773 775 if (str_to_bitmap(sib_core, &t.sib_core[i])) { 774 776 fprintf(stderr, "topology: can't parse siblings map\n"); 775 777 goto exit; ··· 781 777 sib_core += strlen(sib_core) + 1; 782 778 } 783 779 784 - for (i = 0; i < sib_thr_nr; i++) { 780 + for (i = 0; i < env->nr_sibling_threads; i++) { 785 781 if (str_to_bitmap(sib_thr, &t.sib_thr[i])) { 786 782 fprintf(stderr, "topology: can't parse siblings map\n"); 787 783 goto exit;
+3 -1
tools/perf/util/svghelper.h
··· 4 4 5 5 #include <linux/types.h> 6 6 7 + struct perf_env; 8 + 7 9 void open_svg(const char *filename, int cpus, int rows, u64 start, u64 end); 8 10 void svg_ubox(int Yslot, u64 start, u64 end, double height, const char *type, int fd, int err, int merges); 9 11 void svg_lbox(int Yslot, u64 start, u64 end, double height, const char *type, int fd, int err, int merges); ··· 30 28 void svg_interrupt(u64 start, int row, const char *backtrace); 31 29 void svg_text(int Yslot, u64 start, const char *text); 32 30 void svg_close(void); 33 - int svg_build_topology_map(char *sib_core, int sib_core_nr, char *sib_thr, int sib_thr_nr); 31 + int svg_build_topology_map(struct perf_env *env); 34 32 35 33 extern int svg_page_width; 36 34 extern u64 svg_highlight;