From b22da3d8526a935aa31e086e63f60ff3246cb61c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Sat, 09 Dec 2023 07:24:11 +0000 Subject: [PATCH] add stmac read mac form eeprom --- kernel/tools/perf/util/svghelper.c | 72 ++++++++++++++++++------------------ 1 files changed, 36 insertions(+), 36 deletions(-) diff --git a/kernel/tools/perf/util/svghelper.c b/kernel/tools/perf/util/svghelper.c index f735ee0..96f941e 100644 --- a/kernel/tools/perf/util/svghelper.c +++ b/kernel/tools/perf/util/svghelper.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * svghelper.c - helper functions for outputting svg * @@ -5,11 +6,6 @@ * * Authors: * Arjan van de Ven <arjan@linux.intel.com> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; version 2 - * of the License. */ #include <inttypes.h> @@ -18,12 +14,14 @@ #include <unistd.h> #include <string.h> #include <linux/bitmap.h> +#include <linux/string.h> #include <linux/time64.h> +#include <linux/zalloc.h> +#include <internal/cpumap.h> +#include <perf/cpumap.h> -#include "perf.h" +#include "env.h" #include "svghelper.h" -#include "util.h" -#include "cpumap.h" static u64 first_time, last_time; static u64 turbo_frequency, max_freq; @@ -698,7 +696,8 @@ int sib_thr_nr; }; -static void scan_thread_topology(int *map, struct topology *t, int cpu, int *pos) +static void scan_thread_topology(int *map, struct topology *t, int cpu, + int *pos, int nr_cpus) { int i; int thr; @@ -707,41 +706,37 @@ if (!test_bit(cpu, cpumask_bits(&t->sib_thr[i]))) continue; - for_each_set_bit(thr, - cpumask_bits(&t->sib_thr[i]), - MAX_NR_CPUS) + for_each_set_bit(thr, cpumask_bits(&t->sib_thr[i]), nr_cpus) if (map[thr] == -1) map[thr] = (*pos)++; } } -static void scan_core_topology(int *map, struct topology *t) +static void scan_core_topology(int *map, struct topology *t, int nr_cpus) { int pos = 0; int i; int cpu; for (i = 0; i < t->sib_core_nr; i++) - for_each_set_bit(cpu, - cpumask_bits(&t->sib_core[i]), - MAX_NR_CPUS) - scan_thread_topology(map, t, cpu, &pos); + for_each_set_bit(cpu, cpumask_bits(&t->sib_core[i]), nr_cpus) + scan_thread_topology(map, t, cpu, &pos, nr_cpus); } -static int str_to_bitmap(char *s, cpumask_t *b) +static int str_to_bitmap(char *s, cpumask_t *b, int nr_cpus) { int i; int ret = 0; - struct cpu_map *m; + struct perf_cpu_map *m; int c; - m = cpu_map__new(s); + m = perf_cpu_map__new(s); if (!m) return -1; for (i = 0; i < m->nr; i++) { c = m->map[i]; - if (c >= MAX_NR_CPUS) { + if (c >= nr_cpus) { ret = -1; break; } @@ -749,29 +744,34 @@ set_bit(c, cpumask_bits(b)); } - cpu_map__put(m); + perf_cpu_map__put(m); 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; + int i, nr_cpus; 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)); + nr_cpus = min(env->nr_cpus_online, MAX_NR_CPUS); + + 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++) { - if (str_to_bitmap(sib_core, &t.sib_core[i])) { + for (i = 0; i < env->nr_sibling_cores; i++) { + if (str_to_bitmap(sib_core, &t.sib_core[i], nr_cpus)) { fprintf(stderr, "topology: can't parse siblings map\n"); goto exit; } @@ -779,8 +779,8 @@ sib_core += strlen(sib_core) + 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(sib_thr, &t.sib_thr[i], nr_cpus)) { fprintf(stderr, "topology: can't parse siblings map\n"); goto exit; } @@ -788,16 +788,16 @@ sib_thr += strlen(sib_thr) + 1; } - topology_map = malloc(sizeof(int) * MAX_NR_CPUS); + topology_map = malloc(sizeof(int) * nr_cpus); if (!topology_map) { fprintf(stderr, "topology: no memory\n"); goto exit; } - for (i = 0; i < MAX_NR_CPUS; i++) + for (i = 0; i < nr_cpus; i++) topology_map[i] = -1; - scan_core_topology(topology_map, &t); + scan_core_topology(topology_map, &t, nr_cpus); return 0; -- Gitblit v1.6.2