perf tools: fix perf stat with large socket IDs
v6 cover perf tools: fix perf stat with large socket IDs
Changes since v5:
* Fix test for cpu_map__get_die() by shifting id before testing.
* Fix test for cpu_map__get_socket() by not using cpu_map__id_to_socket() which is only valid in CPU aggregation mode.
James Clark (12):
perf tools: Improve topology test
perf tools: Use allocator for perf_cpu_map perf tools: Add new struct for cpu aggregation perf tools: Replace aggregation ID with a struct perf tools: add new map type for aggregation perf tools: drop in cpu_aggr_map struct perf tools: Start using cpu_aggr_id in map perf tools: Add separate node member perf tools: Add separate socket member perf tools: Add separate die member
perf tools: Add separate core member perf tools: Add separate thread member
tools/perf/builtin-stat.c | 128 ++++++++++++------------ tools/perf/tests/topology.c | 64 ++++++++++-- tools/perf/util/cpumap.c | 171 ++++++++++++++++++++++----------- tools/perf/util/cpumap.h | 55 ++++++----- tools/perf/util/stat-display.c | 102 ++++++++++++-------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 9 +- 7 files changed, 337 insertions(+), 194 deletions(-)
Signature · 1 line
2.28.0
PATCH v6 1/12 perf tools: Improve topology test
Improve the topology test to check all aggregation types. This is to lock down the behaviour before 'id' is changed into a struct in later commits.
--- tools/perf/tests/topology.c | 53 ++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 7 deletions(-)
tools/perf/tests/topology.c +46 -7
@@ -64,10 +64,11 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) .path = path, .mode = PERF_DATA_MODE_READ, }; -int i; +int i, id; session =perf_session__new (&data, false,NULL );TEST_ASSERT_VAL ("can't get session" , !IS_ERR (session)); +cpu__setup_cpunode_map ();/* On platforms with large numbers of CPUs process_cpu_topology() * might issue an error while reading the perf.data file section
@@ -85,11 +86,18 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)* "socket_id number is too big. You may need to upgrade the * perf tool." * -* This is the reason why this test might be skipped. +* This is the reason why this test might be skipped. aarch64 and +* s390 always write this part of the header, even when the above +* condition is true (see do_core_id_test in header.c). So always +* run this test on those platforms. */ -if (!session->header.env.cpu) +if (!session->header.env.cpu + &&strncmp (session->header.env.arch,"s390" ,4 ) + &&strncmp (session->header.env.arch,"aarch64" ,7 ))return TEST_SKIP ; +TEST_ASSERT_VAL ("Session header CPU map not set" , session->header.env.cpu); +for (i =0 ; i < session->header.env.nr_cpus_avail; i++) {if (!cpu_map__has (map, i))continue ;
@@ -98,14 +106,45 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) session->header.env.cpu[i].socket_id); } +// Test that core ID contains socket, die and core +for (i =0 ; i < map->nr; i++) { + id =cpu_map__get_core (map, i,NULL ); +TEST_ASSERT_VAL ("Core map - Core ID doesn't match" , + session->header.env.cpu[map->map[i]].core_id ==cpu_map__id_to_cpu (id)); + +TEST_ASSERT_VAL ("Core map - Socket ID doesn't match" , + session->header.env.cpu[map->map[i]].socket_id == +cpu_map__id_to_socket (id)); + +TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , + session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id)); + } + +// Test that die ID contains socket and die for (i =0 ; i < map->nr; i++) { -TEST_ASSERT_VAL ("Core ID doesn't match" , - (session->header.env.cpu[map->map[i]].core_id == (cpu_map__get_core (map, i,NULL ) &0xffff ))); + id =cpu_map__get_die (map, i,NULL ); +TEST_ASSERT_VAL ("Die map - Socket ID doesn't match" , + session->header.env.cpu[map->map[i]].socket_id == +cpu_map__id_to_socket (id <<16 )); + +TEST_ASSERT_VAL ("Die map - Die ID doesn't match" , + session->header.env.cpu[map->map[i]].die_id == +cpu_map__id_to_die (id <<16 )); + } -TEST_ASSERT_VAL ("Socket ID doesn't match" , - (session->header.env.cpu[map->map[i]].socket_id ==cpu_map__get_socket (map, i,NULL ))); +// Test that socket ID contains only socket +for (i =0 ; i < map->nr; i++) { + id =cpu_map__get_socket (map, i,NULL ); +TEST_ASSERT_VAL ("Socket map - Socket ID doesn't match" , + session->header.env.cpu[map->map[i]].socket_id == id); } +// Test that node ID contains only node +for (i =0 ; i < map->nr; i++) { + id =cpu_map__get_node (map, i,NULL ); +TEST_ASSERT_VAL ("Node map - Node ID doesn't match" , +cpu__get_node (map->map[i]) == id); + }perf_session__delete (session);return 0 ;
Signature · 1 line
2.28.0
PATCH v6 2/12 perf tools: Use allocator for perf_cpu_map
In reply to James ClarkUse the existing allocator for perf_cpu_map to avoid use of raw malloc. This could cause an issue in later commits where the size of perf_cpu_map is changed.
No functional changes.
--- tools/perf/util/cpumap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/perf/util/cpumap.c +4 -4
@@ -132,15 +132,16 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res,int (*f)(struct perf_cpu_map *map,int cpu,void *data), void *data) { - struct perf_cpu_map *c; int nr = cpus->nr; +struct perf_cpu_map *c =perf_cpu_map__empty_new (nr);int cpu, s1, s2; -/* allocate as much as possible */ - c =calloc (1 ,sizeof (*c) + nr *sizeof (int ));if (!c)return -1 ; +/* Reset size as it may only be partially filled */ + c->nr =0 ; +for (cpu =0 ; cpu < nr; cpu++) { s1 =f (cpus, cpu, data);for (s2 =0 ; s2 < c->nr; s2++) {
@@ -155,7 +156,6 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res,/* ensure we process id in increasing order */ qsort (c->map, c->nr,sizeof (int ), cmp_ids); -refcount_set (&c->refcnt,1 ); *res = c;return 0 ; }
Signature · 1 line
2.28.0
PATCH v6 3/12 perf tools: Add new struct for cpu aggregation
In reply to James ClarkThis struct currently has only a single int member so that it can be used as a drop in replacement for the existing behaviour.
Comparison and constructor functions have also been added that will replace usages of '==' and '= -1'.
No functional changes.
--- tools/perf/util/cpumap.c | 18 ++++++++++++++++++ tools/perf/util/cpumap.h | 8 ++++++++ 2 files changed, 26 insertions(+)
tools/perf/util/cpumap.c +18 -0
@@ -586,3 +586,21 @@ const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */return online; } + +bool cpu_map__compare_aggr_cpu_id (struct aggr_cpu_id a,struct aggr_cpu_id b) +{ +return a.id == b.id; +} + +bool cpu_map__aggr_cpu_id_is_empty (struct aggr_cpu_id a) +{ +return a.id ==-1 ; +} + +struct aggr_cpu_id cpu_map__empty_aggr_cpu_id (void ) +{ +struct aggr_cpu_id ret = { + .id =-1 + }; +return ret; +}
tools/perf/util/cpumap.h +8 -0
@@ -7,6 +7,10 @@#include <internal/cpumap.h> #include <perf/cpumap.h> +struct aggr_cpu_id { +int id; +}; +struct perf_record_cpu_map_data ;struct perf_cpu_map *perf_cpu_map__empty_new (int nr);
@@ -64,4 +68,8 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct perf_cpu_map **res,int cpu_map__cpu (struct perf_cpu_map *cpus,int idx);bool cpu_map__has (struct perf_cpu_map *cpus,int cpu); +bool cpu_map__compare_aggr_cpu_id (struct aggr_cpu_id a,struct aggr_cpu_id b); +bool cpu_map__aggr_cpu_id_is_empty (struct aggr_cpu_id a); +struct aggr_cpu_id cpu_map__empty_aggr_cpu_id (void ); +#endif /* __PERF_CPUMAP_H */
Signature · 1 line
2.28.0
PATCH v6 4/12 perf tools: Replace aggregation ID with a struct
In reply to James ClarkReplace all occurences of the usage of int with the new struct cpu_aggr_id.
No functional changes.
--- tools/perf/builtin-stat.c | 76 +++++++++++++---------- tools/perf/tests/topology.c | 17 +++--- tools/perf/util/cpumap.c | 82 ++++++++++++++----------- tools/perf/util/cpumap.h | 10 +-- tools/perf/util/stat-display.c | 108 +++++++++++++++++++-------------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 5 +- 7 files changed, 173 insertions(+), 127 deletions(-)
tools/perf/builtin-stat.c +43 -33
@@ -1188,65 +1188,67 @@ static struct option stat_options[] = {OPT_END () }; -static int perf_stat__get_socket (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_socket (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int cpu) {return cpu_map__get_socket (map, cpu,NULL ); } -static int perf_stat__get_die (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_die (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int cpu) {return cpu_map__get_die (map, cpu,NULL ); } -static int perf_stat__get_core (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_core (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int cpu) {return cpu_map__get_core (map, cpu,NULL ); } -static int perf_stat__get_node (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_node (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int cpu) {return cpu_map__get_node (map, cpu,NULL ); } -static int perf_stat__get_aggr (struct perf_stat_config *config, +static struct aggr_cpu_id perf_stat__get_aggr (struct perf_stat_config *config,aggr_get_id_t get_id,struct perf_cpu_map *map,int idx) {int cpu; +struct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id ();if (idx >= map->nr) -return -1 ; +return id; cpu = map->map[idx];if (config->cpus_aggr_map->map[cpu] ==-1 ) - config->cpus_aggr_map->map[cpu] =get_id (config, map, idx); + config->cpus_aggr_map->map[cpu] =get_id (config, map, idx).id; -return config->cpus_aggr_map->map[cpu]; + id.id = config->cpus_aggr_map->map[cpu]; +return id; } -static int perf_stat__get_socket_cached (struct perf_stat_config *config, +static struct aggr_cpu_id perf_stat__get_socket_cached (struct perf_stat_config *config,struct perf_cpu_map *map,int idx) {return perf_stat__get_aggr (config, perf_stat__get_socket, map, idx); } -static int perf_stat__get_die_cached (struct perf_stat_config *config, +static struct aggr_cpu_id perf_stat__get_die_cached (struct perf_stat_config *config,struct perf_cpu_map *map,int idx) {return perf_stat__get_aggr (config, perf_stat__get_die, map, idx); } -static int perf_stat__get_core_cached (struct perf_stat_config *config, +static struct aggr_cpu_id perf_stat__get_core_cached (struct perf_stat_config *config,struct perf_cpu_map *map,int idx) {return perf_stat__get_aggr (config, perf_stat__get_core, map, idx); } -static int perf_stat__get_node_cached (struct perf_stat_config *config, +static struct aggr_cpu_id perf_stat__get_node_cached (struct perf_stat_config *config,struct perf_cpu_map *map,int idx) {return perf_stat__get_aggr (config, perf_stat__get_node, map, idx);
@@ -1347,18 +1349,23 @@ static inline int perf_env__get_cpu(struct perf_env *env, struct perf_cpu_map *mreturn cpu; } -static int perf_env__get_socket (struct perf_cpu_map *map,int idx,void *data) +static struct aggr_cpu_id perf_env__get_socket (struct perf_cpu_map *map,int idx,void *data) {struct perf_env *env = data;int cpu =perf_env__get_cpu (env, map, idx); +struct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id (); + +if (cpu !=-1 ) + id.id = env->cpu[cpu].socket_id; -return cpu ==-1 ?-1 : env->cpu[cpu].socket_id; +return id; } -static int perf_env__get_die (struct perf_cpu_map *map,int idx,void *data) +static struct aggr_cpu_id perf_env__get_die (struct perf_cpu_map *map,int idx,void *data) {struct perf_env *env = data; -int die_id =-1 , cpu =perf_env__get_cpu (env, map, idx); +struct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id (); +int cpu =perf_env__get_cpu (env, map, idx);if (cpu !=-1 ) {/*
@@ -1368,21 +1375,22 @@ static int perf_env__get_die(struct perf_cpu_map *map, int idx, void *data)* socket + die id */ if (WARN_ONCE (env->cpu[cpu].socket_id >>8 ,"The socket id number is too big.\n" )) -return -1 ; +return cpu_map__empty_aggr_cpu_id ();if (WARN_ONCE (env->cpu[cpu].die_id >>8 ,"The die id number is too big.\n" )) -return -1 ; +return cpu_map__empty_aggr_cpu_id (); - die_id = (env->cpu[cpu].socket_id <<8 ) | (env->cpu[cpu].die_id &0xff ); + id.id = (env->cpu[cpu].socket_id <<8 ) | (env->cpu[cpu].die_id &0xff ); } -return die_id; +return id; } -static int perf_env__get_core (struct perf_cpu_map *map,int idx,void *data) +static struct aggr_cpu_id perf_env__get_core (struct perf_cpu_map *map,int idx,void *data) {struct perf_env *env = data; -int core =-1 , cpu =perf_env__get_cpu (env, map, idx); +struct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id (); +int cpu =perf_env__get_cpu (env, map, idx);if (cpu !=-1 ) {/*
@@ -1393,27 +1401,29 @@ static int perf_env__get_core(struct perf_cpu_map *map, int idx, void *data)* socket + die id + core id */ if (WARN_ONCE (env->cpu[cpu].socket_id >>8 ,"The socket id number is too big.\n" )) -return -1 ; +return cpu_map__empty_aggr_cpu_id ();if (WARN_ONCE (env->cpu[cpu].die_id >>8 ,"The die id number is too big.\n" )) -return -1 ; +return cpu_map__empty_aggr_cpu_id ();if (WARN_ONCE (env->cpu[cpu].core_id >>16 ,"The core id number is too big.\n" )) -return -1 ; +return cpu_map__empty_aggr_cpu_id (); - core = (env->cpu[cpu].socket_id <<24 ) | + id.id = (env->cpu[cpu].socket_id <<24 ) | (env->cpu[cpu].die_id <<16 ) | (env->cpu[cpu].core_id &0xffff ); } -return core; +return id; } -static int perf_env__get_node (struct perf_cpu_map *map,int idx,void *data) +static struct aggr_cpu_id perf_env__get_node (struct perf_cpu_map *map,int idx,void *data) {int cpu =perf_env__get_cpu (data, map, idx); +struct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id (); -return perf_env__numa_node (data, cpu); + id.id =perf_env__numa_node (data, cpu); +return id; } static int perf_env__build_socket_map(struct perf_env *env, struct perf_cpu_map *cpus,
@@ -1440,24 +1450,24 @@ static int perf_env__build_node_map(struct perf_env *env, struct perf_cpu_map *creturn cpu_map__build_map (cpus, nodep, perf_env__get_node, env); } -static int perf_stat__get_socket_file (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_socket_file (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int idx) {return perf_env__get_socket (map, idx, &perf_stat.session->header.env); } -static int perf_stat__get_die_file (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_die_file (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int idx) {return perf_env__get_die (map, idx, &perf_stat.session->header.env); } -static int perf_stat__get_core_file (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_core_file (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int idx) {return perf_env__get_core (map, idx, &perf_stat.session->header.env); } -static int perf_stat__get_node_file (struct perf_stat_config *config__maybe_unused , +static struct aggr_cpu_id perf_stat__get_node_file (struct perf_stat_config *config__maybe_unused ,struct perf_cpu_map *map,int idx) {return perf_env__get_node (map, idx, &perf_stat.session->header.env);
tools/perf/tests/topology.c +9 -8
@@ -64,7 +64,8 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) .path = path, .mode = PERF_DATA_MODE_READ, }; -int i, id; +int i; +struct aggr_cpu_id id; session =perf_session__new (&data, false,NULL );TEST_ASSERT_VAL ("can't get session" , !IS_ERR (session));
@@ -110,14 +111,14 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)for (i =0 ; i < map->nr; i++) { id =cpu_map__get_core (map, i,NULL );TEST_ASSERT_VAL ("Core map - Core ID doesn't match" , - session->header.env.cpu[map->map[i]].core_id ==cpu_map__id_to_cpu (id)); + session->header.env.cpu[map->map[i]].core_id ==cpu_map__id_to_cpu (id.id));TEST_ASSERT_VAL ("Core map - Socket ID doesn't match" , session->header.env.cpu[map->map[i]].socket_id == -cpu_map__id_to_socket (id)); +cpu_map__id_to_socket (id.id));TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , - session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id)); + session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id.id)); }// Test that die ID contains socket and die
@@ -125,25 +126,25 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) id =cpu_map__get_die (map, i,NULL );TEST_ASSERT_VAL ("Die map - Socket ID doesn't match" , session->header.env.cpu[map->map[i]].socket_id == -cpu_map__id_to_socket (id <<16 )); +cpu_map__id_to_socket (id.id <<16 ));TEST_ASSERT_VAL ("Die map - Die ID doesn't match" , session->header.env.cpu[map->map[i]].die_id == -cpu_map__id_to_die (id <<16 )); +cpu_map__id_to_die (id.id <<16 )); }// Test that socket ID contains only socket for (i =0 ; i < map->nr; i++) { id =cpu_map__get_socket (map, i,NULL );TEST_ASSERT_VAL ("Socket map - Socket ID doesn't match" , - session->header.env.cpu[map->map[i]].socket_id == id); + session->header.env.cpu[map->map[i]].socket_id == id.id); }// Test that node ID contains only node for (i =0 ; i < map->nr; i++) { id =cpu_map__get_node (map, i,NULL );TEST_ASSERT_VAL ("Node map - Node ID doesn't match" , -cpu__get_node (map->map[i]) == id); +cpu__get_node (map->map[i]) == id.id); }perf_session__delete (session);
tools/perf/util/cpumap.c +48 -34
168 lines not on this page · raw message
tools/perf/util/cpumap.h +5 -5
@@ -19,13 +19,13 @@ size_t cpu_map__snprint(struct perf_cpu_map *map, char *buf, size_t size);size_t cpu_map__snprint_mask (struct perf_cpu_map *map,char *buf,size_t size);size_t cpu_map__fprintf (struct perf_cpu_map *map,FILE *fp);int cpu_map__get_socket_id (int cpu); -int cpu_map__get_socket (struct perf_cpu_map *map,int idx,void *data); +struct aggr_cpu_id cpu_map__get_socket (struct perf_cpu_map *map,int idx,void *data);int cpu_map__get_die_id (int cpu); -int cpu_map__get_die (struct perf_cpu_map *map,int idx,void *data); +struct aggr_cpu_id cpu_map__get_die (struct perf_cpu_map *map,int idx,void *data);int cpu_map__get_core_id (int cpu); -int cpu_map__get_core (struct perf_cpu_map *map,int idx,void *data); +struct aggr_cpu_id cpu_map__get_core (struct perf_cpu_map *map,int idx,void *data);int cpu_map__get_node_id (int cpu); -int cpu_map__get_node (struct perf_cpu_map *map,int idx,void *data); +struct aggr_cpu_id cpu_map__get_node (struct perf_cpu_map *map,int idx,void *data);int cpu_map__build_socket_map (struct perf_cpu_map *cpus,struct perf_cpu_map **sockp);int cpu_map__build_die_map (struct perf_cpu_map *cpus,struct perf_cpu_map **diep);int cpu_map__build_core_map (struct perf_cpu_map *cpus,struct perf_cpu_map **corep);
@@ -62,7 +62,7 @@ int cpu__max_present_cpu(void);int cpu__get_node (int cpu);int cpu_map__build_map (struct perf_cpu_map *cpus,struct perf_cpu_map **res, -int (*f)(struct perf_cpu_map *map,int cpu,void *data), +struct aggr_cpu_id (*f)(struct perf_cpu_map *map,int cpu,void *data),void *data);int cpu_map__cpu (struct perf_cpu_map *cpus,int idx);
tools/perf/util/stat-display.c +64 -44
301 lines not on this page · raw message
tools/perf/util/stat.c +1 -1
@@ -313,7 +313,7 @@ static int check_per_pkg(struct evsel *counter,if (!(vals->run && vals->ena))return 0 ; - s =cpu_map__get_socket (cpus, cpu,NULL ); + s =cpu_map__get_socket (cpus, cpu,NULL ).id;if (s <0 )return -1 ;
tools/perf/util/stat.h +3 -2
@@ -6,6 +6,7 @@#include <stdio.h> #include <sys/types.h> #include <sys/resource.h> +#include "cpumap.h" #include "rblist.h" struct perf_cpu_map ;
@@ -99,7 +100,7 @@ struct runtime_stat {struct rblist value_list; }; -typedef int (*aggr_get_id_t )(struct perf_stat_config *config, +typedef struct aggr_cpu_id (*aggr_get_id_t )(struct perf_stat_config *config,struct perf_cpu_map *m,int cpu);struct perf_stat_config {
@@ -170,7 +171,7 @@ struct evlist;struct perf_aggr_thread_value {struct evsel *counter; -int id; +struct aggr_cpu_id id;double uval;u64 val;u64 run;
Signature · 1 line
2.28.0
PATCH v6 5/12 perf tools: add new map type for aggregation
In reply to James ClarkCurrently this is a duplicate of perf_cpu_map so that it can be used as a drop in replacement.
In a later commit it will be changed from a map of ints to use the new cpu_aggr_id struct.
No functional changes.
--- tools/perf/util/cpumap.c | 17 +++++++++++++++++ tools/perf/util/cpumap.h | 8 ++++++++ 2 files changed, 25 insertions(+)
tools/perf/util/cpumap.c +17 -0
@@ -95,6 +95,23 @@ struct perf_cpu_map *perf_cpu_map__empty_new(int nr)return cpus; } +struct cpu_aggr_map *cpu_aggr_map__empty_new (int nr) +{ +struct cpu_aggr_map *cpus =malloc (sizeof (*cpus) +sizeof (int ) * nr); + +if (cpus !=NULL ) { +int i; + + cpus->nr = nr; +for (i =0 ; i < nr; i++) + cpus->map[i] =-1 ; + +refcount_set (&cpus->refcnt,1 ); + } + +return cpus; +} +static int cpu__get_topology_int (int cpu,const char *name,int *value) {char path[PATH_MAX ];
tools/perf/util/cpumap.h +8 -0
@@ -11,9 +11,17 @@ struct aggr_cpu_id {int id; }; +struct cpu_aggr_map { +refcount_t refcnt; +int nr; +int map[]; +}; +struct perf_record_cpu_map_data ;struct perf_cpu_map *perf_cpu_map__empty_new (int nr); +struct cpu_aggr_map *cpu_aggr_map__empty_new (int nr); +struct perf_cpu_map *cpu_map__new_data (struct perf_record_cpu_map_data *data);size_t cpu_map__snprint (struct perf_cpu_map *map,char *buf,size_t size);size_t cpu_map__snprint_mask (struct perf_cpu_map *map,char *buf,size_t size);
Signature · 1 line
2.28.0
PATCH v6 6/12 perf tools: drop in cpu_aggr_map struct
In reply to James ClarkReplace usages of perf_cpu_map with cpu_aggr map in places that are involved with perf stat aggregation.
This will then later be changed to be a map of cpu_aggr_id rather than an int so that more data can be stored.
No functional changes.
--- tools/perf/builtin-stat.c | 29 ++++++++++++++++++++++------- tools/perf/util/cpumap.c | 12 ++++++------ tools/perf/util/cpumap.h | 10 +++++----- tools/perf/util/stat.h | 4 ++-- 4 files changed, 35 insertions(+), 20 deletions(-)
tools/perf/builtin-stat.c +22 -7
@@ -1322,14 +1322,29 @@ static int perf_stat_init_aggr_mode(void)* the aggregation translate cpumap. */ nr =perf_cpu_map__max (evsel_list->core.cpus); - stat_config.cpus_aggr_map =perf_cpu_map__empty_new (nr +1 ); + stat_config.cpus_aggr_map =cpu_aggr_map__empty_new (nr +1 );return stat_config.cpus_aggr_map ?0 : -ENOMEM ; } +static void cpu_aggr_map__delete (struct cpu_aggr_map *map) +{ +if (map) { +WARN_ONCE (refcount_read (&map->refcnt) !=0 , +"cpu_aggr_map refcnt unbalanced\n" ); +free (map); + } +} + +static void cpu_aggr_map__put (struct cpu_aggr_map *map) +{ +if (map &&refcount_dec_and_test (&map->refcnt)) +cpu_aggr_map__delete (map); +} +static void perf_stat__exit_aggr_mode (void ) { -perf_cpu_map__put (stat_config.aggr_map); -perf_cpu_map__put (stat_config.cpus_aggr_map); +cpu_aggr_map__put (stat_config.aggr_map); +cpu_aggr_map__put (stat_config.cpus_aggr_map); stat_config.aggr_map =NULL ; stat_config.cpus_aggr_map =NULL ; }
@@ -1427,25 +1442,25 @@ static struct aggr_cpu_id perf_env__get_node(struct perf_cpu_map *map, int idx, }static int perf_env__build_socket_map (struct perf_env *env,struct perf_cpu_map *cpus, -struct perf_cpu_map **sockp) +struct cpu_aggr_map **sockp) {return cpu_map__build_map (cpus, sockp, perf_env__get_socket, env); }static int perf_env__build_die_map (struct perf_env *env,struct perf_cpu_map *cpus, -struct perf_cpu_map **diep) +struct cpu_aggr_map **diep) {return cpu_map__build_map (cpus, diep, perf_env__get_die, env); }static int perf_env__build_core_map (struct perf_env *env,struct perf_cpu_map *cpus, -struct perf_cpu_map **corep) +struct cpu_aggr_map **corep) {return cpu_map__build_map (cpus, corep, perf_env__get_core, env); }static int perf_env__build_node_map (struct perf_env *env,struct perf_cpu_map *cpus, -struct perf_cpu_map **nodep) +struct cpu_aggr_map **nodep) {return cpu_map__build_map (cpus, nodep, perf_env__get_node, env); }
tools/perf/util/cpumap.c +6 -6
@@ -151,12 +151,12 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer)return a->id - b->id; } -int cpu_map__build_map (struct perf_cpu_map *cpus,struct perf_cpu_map **res, +int cpu_map__build_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **res,struct aggr_cpu_id (*f)(struct perf_cpu_map *map,int cpu,void *data),void *data) {int nr = cpus->nr; -struct perf_cpu_map *c =perf_cpu_map__empty_new (nr); +struct cpu_aggr_map *c =cpu_aggr_map__empty_new (nr);int cpu, s2;struct aggr_cpu_id s1;
@@ -279,22 +279,22 @@ struct aggr_cpu_id cpu_map__get_node(struct perf_cpu_map *map, int idx, void *dareturn id; } -int cpu_map__build_socket_map (struct perf_cpu_map *cpus,struct perf_cpu_map **sockp) +int cpu_map__build_socket_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **sockp) {return cpu_map__build_map (cpus, sockp, cpu_map__get_socket,NULL ); } -int cpu_map__build_die_map (struct perf_cpu_map *cpus,struct perf_cpu_map **diep) +int cpu_map__build_die_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **diep) {return cpu_map__build_map (cpus, diep, cpu_map__get_die,NULL ); } -int cpu_map__build_core_map (struct perf_cpu_map *cpus,struct perf_cpu_map **corep) +int cpu_map__build_core_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **corep) {return cpu_map__build_map (cpus, corep, cpu_map__get_core,NULL ); } -int cpu_map__build_node_map (struct perf_cpu_map *cpus,struct perf_cpu_map **numap) +int cpu_map__build_node_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **numap) {return cpu_map__build_map (cpus, numap, cpu_map__get_node,NULL ); }
tools/perf/util/cpumap.h +5 -5
@@ -34,10 +34,10 @@ int cpu_map__get_core_id(int cpu);struct aggr_cpu_id cpu_map__get_core (struct perf_cpu_map *map,int idx,void *data);int cpu_map__get_node_id (int cpu);struct aggr_cpu_id cpu_map__get_node (struct perf_cpu_map *map,int idx,void *data); -int cpu_map__build_socket_map (struct perf_cpu_map *cpus,struct perf_cpu_map **sockp); -int cpu_map__build_die_map (struct perf_cpu_map *cpus,struct perf_cpu_map **diep); -int cpu_map__build_core_map (struct perf_cpu_map *cpus,struct perf_cpu_map **corep); -int cpu_map__build_node_map (struct perf_cpu_map *cpus,struct perf_cpu_map **nodep); +int cpu_map__build_socket_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **sockp); +int cpu_map__build_die_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **diep); +int cpu_map__build_core_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **corep); +int cpu_map__build_node_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **nodep);const struct perf_cpu_map *cpu_map__online (void );/* thread unsafe */ static inline int cpu_map__socket (struct perf_cpu_map *sock,int s)
@@ -69,7 +69,7 @@ int cpu__max_cpu(void);int cpu__max_present_cpu (void );int cpu__get_node (int cpu); -int cpu_map__build_map (struct perf_cpu_map *cpus,struct perf_cpu_map **res, +int cpu_map__build_map (struct perf_cpu_map *cpus,struct cpu_aggr_map **res,struct aggr_cpu_id (*f)(struct perf_cpu_map *map,int cpu,void *data),void *data);
tools/perf/util/stat.h +2 -2
@@ -139,9 +139,9 @@ struct perf_stat_config {const char *csv_sep;struct stats *walltime_nsecs_stats;struct rusage ru_data; -struct perf_cpu_map *aggr_map; +struct cpu_aggr_map *aggr_map;aggr_get_id_t aggr_get_id; -struct perf_cpu_map *cpus_aggr_map; +struct cpu_aggr_map *cpus_aggr_map;u64 *walltime_run;struct rblist metric_events;int ctl_fd;
Signature · 1 line
2.28.0
PATCH v6 7/12 perf tools: Start using cpu_aggr_id in map
In reply to James ClarkUse the new cpu_aggr_id struct in the cpu map instead of int so that it can store more data.
No functional changes.
--- tools/perf/builtin-stat.c | 6 +++--- tools/perf/util/cpumap.c | 8 ++++---- tools/perf/util/cpumap.h | 2 +- tools/perf/util/stat-display.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-)
tools/perf/builtin-stat.c +3 -3
@@ -1223,10 +1223,10 @@ static struct aggr_cpu_id perf_stat__get_aggr(struct perf_stat_config *config, cpu = map->map[idx]; -if (config->cpus_aggr_map->map[cpu] ==-1 ) - config->cpus_aggr_map->map[cpu] =get_id (config, map, idx).id; +if (cpu_map__aggr_cpu_id_is_empty (config->cpus_aggr_map->map[cpu])) + config->cpus_aggr_map->map[cpu] =get_id (config, map, idx); - id.id = config->cpus_aggr_map->map[cpu]; + id = config->cpus_aggr_map->map[cpu];return id; }
tools/perf/util/cpumap.c +4 -4
@@ -97,14 +97,14 @@ struct perf_cpu_map *perf_cpu_map__empty_new(int nr)struct cpu_aggr_map *cpu_aggr_map__empty_new (int nr) { -struct cpu_aggr_map *cpus =malloc (sizeof (*cpus) +sizeof (int ) * nr); +struct cpu_aggr_map *cpus =malloc (sizeof (*cpus) +sizeof (struct aggr_cpu_id ) * nr);if (cpus !=NULL ) {int i; cpus->nr = nr;for (i =0 ; i < nr; i++) - cpus->map[i] =-1 ; + cpus->map[i] =cpu_map__empty_aggr_cpu_id ();refcount_set (&cpus->refcnt,1 ); }
@@ -169,11 +169,11 @@ int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,for (cpu =0 ; cpu < nr; cpu++) { s1 =f (cpus, cpu, data);for (s2 =0 ; s2 < c->nr; s2++) { -if (s1.id == c->map[s2]) +if (cpu_map__compare_aggr_cpu_id (s1, c->map[s2]))break ; }if (s2 == c->nr) { - c->map[c->nr] = s1.id; + c->map[c->nr] = s1; c->nr++; } }
tools/perf/util/cpumap.h +1 -1
@@ -14,7 +14,7 @@ struct aggr_cpu_id {struct cpu_aggr_map {refcount_t refcnt;int nr; -int map[]; +struct aggr_cpu_id map[]; };struct perf_record_cpu_map_data ;
tools/perf/util/stat-display.c +3 -3
@@ -509,7 +509,7 @@ static void aggr_update_shadow(struct perf_stat_config *config,struct evsel *counter;for (s =0 ; s < config->aggr_map->nr; s++) { - id.id = config->aggr_map->map[s]; + id = config->aggr_map->map[s];evlist__for_each_entry (evlist, counter) { val =0 ;for (cpu =0 ; cpu <evsel__nr_cpus (counter); cpu++) {
@@ -641,7 +641,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config,struct aggr_cpu_id id;double uval; - ad.id.id = id.id = config->aggr_map->map[s]; + ad.id = id = config->aggr_map->map[s]; ad.val = ad.ena = ad.run =0 ; ad.nr =0 ;if (!collect_data (config, counter, aggr_cb, &ad))
@@ -1169,7 +1169,7 @@ static void print_percore_thread(struct perf_stat_config *config,for (int i =0 ; i <evsel__nr_cpus (counter); i++) { s2 = config->aggr_get_id (config,evsel__cpus (counter), i);for (s =0 ; s < config->aggr_map->nr; s++) { - id.id = config->aggr_map->map[s]; + id = config->aggr_map->map[s];if (cpu_map__compare_aggr_cpu_id (s2, id))break ; }
Signature · 1 line
2.28.0
PATCH v6 8/12 perf tools: Add separate node member
In reply to James ClarkAdd node as a separate member so that it doesn't have to be packed into the int value.
--- tools/perf/builtin-stat.c | 2 +- tools/perf/tests/topology.c | 8 +++++++- tools/perf/util/cpumap.c | 16 +++++++++++----- tools/perf/util/cpumap.h | 1 + tools/perf/util/stat-display.c | 2 +- 5 files changed, 21 insertions(+), 8 deletions(-)
tools/perf/builtin-stat.c +1 -1
@@ -1437,7 +1437,7 @@ static struct aggr_cpu_id perf_env__get_node(struct perf_cpu_map *map, int idx,int cpu =perf_env__get_cpu (data, map, idx);struct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id (); - id.id =perf_env__numa_node (data, cpu); + id.node =perf_env__numa_node (data, cpu);return id; }
tools/perf/tests/topology.c +7 -1
@@ -119,6 +119,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id.id)); +TEST_ASSERT_VAL ("Core map - Node ID is set" , id.node ==-1 ); }// Test that die ID contains socket and die
@@ -131,6 +132,8 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Die map - Die ID doesn't match" , session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id.id <<16 )); + +TEST_ASSERT_VAL ("Die map - Node ID is set" , id.node ==-1 ); }// Test that socket ID contains only socket
@@ -138,13 +141,16 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) id =cpu_map__get_socket (map, i,NULL );TEST_ASSERT_VAL ("Socket map - Socket ID doesn't match" , session->header.env.cpu[map->map[i]].socket_id == id.id); + +TEST_ASSERT_VAL ("Socket map - Node ID is set" , id.node ==-1 ); }// Test that node ID contains only node for (i =0 ; i < map->nr; i++) { id =cpu_map__get_node (map, i,NULL );TEST_ASSERT_VAL ("Node map - Node ID doesn't match" , -cpu__get_node (map->map[i]) == id.id); +cpu__get_node (map->map[i]) == id.node); +TEST_ASSERT_VAL ("Node map - ID is set" , id.id ==-1 ); }perf_session__delete (session);
tools/perf/util/cpumap.c +11 -5
@@ -148,7 +148,10 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer)struct aggr_cpu_id *a = (struct aggr_cpu_id *)a_pointer;struct aggr_cpu_id *b = (struct aggr_cpu_id *)b_pointer; -return a->id - b->id; +if (a->id != b->id) +return a->id - b->id; +else +return a->node - b->node; } int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
@@ -275,7 +278,7 @@ struct aggr_cpu_id cpu_map__get_node(struct perf_cpu_map *map, int idx, void *daif (idx <0 || idx >= map->nr)return id; - id.id =cpu_map__get_node_id (map->map[idx]); + id.node =cpu_map__get_node_id (map->map[idx]);return id; }
@@ -620,18 +623,21 @@ const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */bool cpu_map__compare_aggr_cpu_id (struct aggr_cpu_id a,struct aggr_cpu_id b) { -return a.id == b.id; +return a.id == b.id && + a.node == b.node; }bool cpu_map__aggr_cpu_id_is_empty (struct aggr_cpu_id a) { -return a.id ==-1 ; +return a.id ==-1 && + a.node ==-1 ; }struct aggr_cpu_id cpu_map__empty_aggr_cpu_id (void ) {struct aggr_cpu_id ret = { - .id =-1 + .id =-1 , + .node =-1 };return ret; }
tools/perf/util/cpumap.h +1 -0
@@ -9,6 +9,7 @@struct aggr_cpu_id {int id; +int node; };struct cpu_aggr_map {
tools/perf/util/stat-display.c +1 -1
@@ -104,7 +104,7 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_NODE : fprintf(config->output, "N%*d%s%*d%s", config->csv_output ? 0 : -5, - id.id, + id.node, config->csv_sep, config->csv_output ? 0 : 4, nr,
Signature · 1 line
2.28.0
PATCH v6 9/12 perf tools: Add separate socket member
In reply to James ClarkAdd socket as a separate member so that it doesn't have to be packed into the int value. When the socket ID was larger than 8 bits the output appeared corrupted or incomplete.
For example, here on ThunderX2 perf stat reports a socket of -1 and an invalid die number:
./perf stat -a --per-die
The socket id number is too big.
Performance counter stats for 'system wide':
S-1-D255 128 687.99 msec cpu-clock # 57.240 CPUs utilized
...
S36-D0 128 842.34 msec cpu-clock # 70.081 CPUs utilized
...
And with --per-core there is an entry with an invalid core ID:
./perf stat record -a --per-core
The socket id number is too big.
Performance counter stats for 'system wide':
S-1-D255-C65535 128 671.04 msec cpu-clock # 54.112 CPUs utilized
...
S36-D0-C0 4 28.27 msec cpu-clock # 2.279 CPUs utilized
...
This fixes the "Session topology" self test on ThunderX2.
After this fix the output contains the correct socket and die IDs and no longer prints a warning about the size of the socket ID:
./perf stat --per-die -a
Performance counter stats for 'system wide':
S36-D0 128 169,869.39 msec cpu-clock # 127.501 CPUs utilized
...
S3612-D0 128 169,733.05 msec cpu-clock # 127.398 CPUs utilized
--- tools/perf/builtin-stat.c | 22 +++++++---------- tools/perf/tests/topology.c | 10 ++++---- tools/perf/util/cpumap.c | 44 +++++++++++++++++----------------- tools/perf/util/cpumap.h | 6 +---- tools/perf/util/stat-display.c | 8 +++---- tools/perf/util/stat.c | 2 +- 6 files changed, 41 insertions(+), 51 deletions(-)
tools/perf/builtin-stat.c +8 -14
@@ -1371,7 +1371,7 @@ static struct aggr_cpu_id perf_env__get_socket(struct perf_cpu_map *map, int idxstruct aggr_cpu_id id =cpu_map__empty_aggr_cpu_id ();if (cpu !=-1 ) - id.id = env->cpu[cpu].socket_id; + id.socket = env->cpu[cpu].socket_id;return id; }
@@ -1384,18 +1384,16 @@ static struct aggr_cpu_id perf_env__get_die(struct perf_cpu_map *map, int idx, vif (cpu !=-1 ) {/* -* Encode socket in bit range 15:8 -* die_id is relative to socket, -* we need a global id. So we combine -* socket + die id +* die_id is relative to socket, so start +* with the socket ID and then add die to +* make a unique ID. */ -if (WARN_ONCE (env->cpu[cpu].socket_id >>8 ,"The socket id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); + id.socket = env->cpu[cpu].socket_id;if (WARN_ONCE (env->cpu[cpu].die_id >>8 ,"The die id number is too big.\n" ))return cpu_map__empty_aggr_cpu_id (); - id.id = (env->cpu[cpu].socket_id <<8 ) | (env->cpu[cpu].die_id &0xff ); + id.id = env->cpu[cpu].die_id &0xff ; }return id;
@@ -1409,23 +1407,19 @@ static struct aggr_cpu_id perf_env__get_core(struct perf_cpu_map *map, int idx,if (cpu !=-1 ) {/* -* Encode socket in bit range 31:24 * encode die id in bit range 23:16 * core_id is relative to socket and die, * we need a global id. So we combine * socket + die id + core id */ -if (WARN_ONCE (env->cpu[cpu].socket_id >>8 ,"The socket id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); -if (WARN_ONCE (env->cpu[cpu].die_id >>8 ,"The die id number is too big.\n" ))return cpu_map__empty_aggr_cpu_id ();if (WARN_ONCE (env->cpu[cpu].core_id >>16 ,"The core id number is too big.\n" ))return cpu_map__empty_aggr_cpu_id (); - id.id = (env->cpu[cpu].socket_id <<24 ) | - (env->cpu[cpu].die_id <<16 ) | + id.socket = env->cpu[cpu].socket_id; + id.id = (env->cpu[cpu].die_id <<16 ) | (env->cpu[cpu].core_id &0xffff ); }
tools/perf/tests/topology.c +5 -5
@@ -114,8 +114,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) session->header.env.cpu[map->map[i]].core_id == cpu_map__id_to_cpu(id.id));TEST_ASSERT_VAL ("Core map - Socket ID doesn't match" , - session->header.env.cpu[map->map[i]].socket_id == -cpu_map__id_to_socket (id.id)); + session->header.env.cpu[map->map[i]].socket_id == id.socket);TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id.id));
@@ -126,8 +125,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)for (i =0 ; i < map->nr; i++) { id =cpu_map__get_die (map, i,NULL );TEST_ASSERT_VAL ("Die map - Socket ID doesn't match" , - session->header.env.cpu[map->map[i]].socket_id == -cpu_map__id_to_socket (id.id <<16 )); + session->header.env.cpu[map->map[i]].socket_id == id.socket); TEST_ASSERT_VAL("Die map - Die ID doesn't match", session->header.env.cpu[map->map[i]].die_id ==
@@ -140,9 +138,10 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)for (i =0 ; i < map->nr; i++) { id =cpu_map__get_socket (map, i,NULL );TEST_ASSERT_VAL ("Socket map - Socket ID doesn't match" , - session->header.env.cpu[map->map[i]].socket_id == id.id); + session->header.env.cpu[map->map[i]].socket_id == id.socket);TEST_ASSERT_VAL ("Socket map - Node ID is set" , id.node ==-1 ); +TEST_ASSERT_VAL ("Socket map - ID is set" , id.id ==-1 ); }// Test that node ID contains only node
@@ -151,6 +150,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Node map - Node ID doesn't match" ,cpu__get_node (map->map[i]) == id.node);TEST_ASSERT_VAL ("Node map - ID is set" , id.id ==-1 ); +TEST_ASSERT_VAL ("Node map - Socket is set" , id.socket ==-1 ); }perf_session__delete (session);
tools/perf/util/cpumap.c +22 -22
99 lines not on this page · raw message
tools/perf/util/cpumap.h +1 -5
@@ -10,6 +10,7 @@struct aggr_cpu_id {int id;int node; +int socket; };struct cpu_aggr_map {
@@ -48,11 +49,6 @@ static inline int cpu_map__socket(struct perf_cpu_map *sock, int s)return sock->map[s]; } -static inline int cpu_map__id_to_socket (int id) -{ -return id >>24 ; -} -static inline int cpu_map__id_to_die (int id) {return (id >>16 ) &0xff ;
tools/perf/util/stat-display.c +4 -4
@@ -73,7 +73,7 @@ static void aggr_printout(struct perf_stat_config *config,switch (config->aggr_mode) {case AGGR_CORE : fprintf(config->output, "S%d-D%d-C%*d%s%*d%s", - cpu_map__id_to_socket(id.id), + id.socket, cpu_map__id_to_die(id.id), config->csv_output ? 0 : -8, cpu_map__id_to_cpu(id.id),
@@ -84,7 +84,7 @@ static void aggr_printout(struct perf_stat_config *config,break ;case AGGR_DIE : fprintf(config->output, "S%d-D%*d%s%*d%s", - cpu_map__id_to_socket(id.id << 16), + id.socket, config->csv_output ? 0 : -8, cpu_map__id_to_die(id.id << 16), config->csv_sep,
@@ -95,7 +95,7 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_SOCKET : fprintf(config->output, "S%*d%s%*d%s", config->csv_output ? 0 : -5, - id.id, + id.socket, config->csv_sep, config->csv_output ? 0 : 4, nr,
@@ -113,7 +113,7 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_NONE :if (evsel->percore && !config->percore_show_thread) {fprintf (config->output,"S%d-D%d-C%*d%s" , -cpu_map__id_to_socket (id.id), + id.socket,cpu_map__id_to_die (id.id), config->csv_output ?0 :-3 ,cpu_map__id_to_cpu (id.id), config->csv_sep);
tools/perf/util/stat.c +1 -1
@@ -313,7 +313,7 @@ static int check_per_pkg(struct evsel *counter,if (!(vals->run && vals->ena))return 0 ; - s =cpu_map__get_socket (cpus, cpu,NULL ).id; + s =cpu_map__get_socket (cpus, cpu,NULL ).socket;if (s <0 )return -1 ;
Signature · 1 line
2.28.0
PATCH v6 10/12 perf tools: Add separate die member
In reply to James ClarkAdd die as a separate member so that it doesn't have to be packed into the int value.
--- tools/perf/builtin-stat.c | 14 +++----------- tools/perf/tests/topology.c | 8 +++++--- tools/perf/util/cpumap.c | 28 ++++++++++++++-------------- tools/perf/util/cpumap.h | 6 +----- tools/perf/util/stat-display.c | 6 +++--- 5 files changed, 26 insertions(+), 36 deletions(-)
tools/perf/builtin-stat.c +3 -11
@@ -1389,11 +1389,7 @@ static struct aggr_cpu_id perf_env__get_die(struct perf_cpu_map *map, int idx, v* make a unique ID. */ id.socket = env->cpu[cpu].socket_id; - -if (WARN_ONCE (env->cpu[cpu].die_id >>8 ,"The die id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); - - id.id = env->cpu[cpu].die_id &0xff ; + id.die = env->cpu[cpu].die_id; }return id;
@@ -1407,20 +1403,16 @@ static struct aggr_cpu_id perf_env__get_core(struct perf_cpu_map *map, int idx,if (cpu !=-1 ) {/* -* encode die id in bit range 23:16 * core_id is relative to socket and die, * we need a global id. So we combine * socket + die id + core id */ -if (WARN_ONCE (env->cpu[cpu].die_id >>8 ,"The die id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); -if (WARN_ONCE (env->cpu[cpu].core_id >>16 ,"The core id number is too big.\n" ))return cpu_map__empty_aggr_cpu_id (); id.socket = env->cpu[cpu].socket_id; - id.id = (env->cpu[cpu].die_id <<16 ) | - (env->cpu[cpu].core_id &0xffff ); + id.die = env->cpu[cpu].die_id; + id.id = env->cpu[cpu].core_id &0xffff ; }return id;
tools/perf/tests/topology.c +5 -3
@@ -117,7 +117,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) session->header.env.cpu[map->map[i]].socket_id == id.socket);TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , - session->header.env.cpu[map->map[i]].die_id ==cpu_map__id_to_die (id.id)); + session->header.env.cpu[map->map[i]].die_id == id.die);TEST_ASSERT_VAL ("Core map - Node ID is set" , id.node ==-1 ); }
@@ -128,10 +128,10 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) session->header.env.cpu[map->map[i]].socket_id == id.socket);TEST_ASSERT_VAL ("Die map - Die ID doesn't match" , - session->header.env.cpu[map->map[i]].die_id == -cpu_map__id_to_die (id.id <<16 )); + session->header.env.cpu[map->map[i]].die_id == id.die);TEST_ASSERT_VAL ("Die map - Node ID is set" , id.node ==-1 ); +TEST_ASSERT_VAL ("Die map - ID is set" , id.id ==-1 ); }// Test that socket ID contains only socket
@@ -141,6 +141,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) session->header.env.cpu[map->map[i]].socket_id == id.socket);TEST_ASSERT_VAL ("Socket map - Node ID is set" , id.node ==-1 ); +TEST_ASSERT_VAL ("Socket map - Die ID is set" , id.die ==-1 );TEST_ASSERT_VAL ("Socket map - ID is set" , id.id ==-1 ); }
@@ -151,6 +152,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) cpu__get_node(map->map[i]) == id.node);TEST_ASSERT_VAL ("Node map - ID is set" , id.id ==-1 );TEST_ASSERT_VAL ("Node map - Socket is set" , id.socket ==-1 ); +TEST_ASSERT_VAL ("Node map - Die ID is set" , id.die ==-1 ); }perf_session__delete (session);
tools/perf/util/cpumap.c +14 -14
@@ -152,8 +152,10 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer)return a->id - b->id; else if (a->node != b->node) return a->node - b->node; - else + else if (a->socket != b->socket) return a->socket - b->socket; + else + return a->die - b->die; } int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
@@ -220,10 +222,7 @@ struct aggr_cpu_id cpu_map__get_die(struct perf_cpu_map *map, int idx, void *datif (cpu_map__aggr_cpu_id_is_empty (id))return id; -if (WARN_ONCE (die >>8 ,"The die id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); - - id.id = (die &0xff ); + id.die = die;return id; }
@@ -250,21 +249,19 @@ struct aggr_cpu_id cpu_map__get_core(struct perf_cpu_map *map, int idx, void *da cpu =cpu_map__get_core_id (cpu); -/* cpu_map__get_die returns the combination of socket + die id */ +/* cpu_map__get_die returns a struct with socket and die set*/ id =cpu_map__get_die (map, idx, data);if (cpu_map__aggr_cpu_id_is_empty (id))return id;/* -* encode die id in bit range 23:16 -* core_id is relative to socket and die, -* we need a global id. So we combine -* socket + die id + core id +* core_id is relative to socket and die, we need a global id. +* So we combine the result from cpu_map__get_die with the core id */ if (WARN_ONCE (cpu >>16 ,"The core id number is too big.\n" ))return cpu_map__empty_aggr_cpu_id (); - id.id = (id.id <<16 ) | (cpu &0xffff ); + id.id = (cpu &0xffff );return id; }
@@ -622,14 +619,16 @@ bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b) {return a.id == b.id && a.node == b.node && - a.socket == b.socket; + a.socket == b.socket && + a.die == b.die; }bool cpu_map__aggr_cpu_id_is_empty (struct aggr_cpu_id a) {return a.id ==-1 && a.node ==-1 && - a.socket ==-1 ; + a.socket ==-1 && + a.die ==-1 ; }struct aggr_cpu_id cpu_map__empty_aggr_cpu_id (void )
@@ -637,7 +636,8 @@ struct aggr_cpu_id cpu_map__empty_aggr_cpu_id(void)struct aggr_cpu_id ret = { .id =-1 , .node =-1 , - .socket =-1 + .socket =-1 , + .die =-1 };return ret; }
tools/perf/util/cpumap.h +1 -5
@@ -11,6 +11,7 @@ struct aggr_cpu_id {int id;int node;int socket; +int die; };struct cpu_aggr_map {
@@ -49,11 +50,6 @@ static inline int cpu_map__socket(struct perf_cpu_map *sock, int s)return sock->map[s]; } -static inline int cpu_map__id_to_die (int id) -{ -return (id >>16 ) &0xff ; -} -static inline int cpu_map__id_to_cpu (int id) {return id &0xffff ;
tools/perf/util/stat-display.c +3 -3
@@ -74,7 +74,7 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_CORE : fprintf(config->output, "S%d-D%d-C%*d%s%*d%s", id.socket, - cpu_map__id_to_die(id.id), + id.die, config->csv_output ? 0 : -8, cpu_map__id_to_cpu(id.id), config->csv_sep,
@@ -86,7 +86,7 @@ static void aggr_printout(struct perf_stat_config *config, fprintf(config->output, "S%d-D%*d%s%*d%s", id.socket, config->csv_output ? 0 : -8, - cpu_map__id_to_die(id.id << 16), + id.die, config->csv_sep, config->csv_output ? 0 : 4, nr,
@@ -114,7 +114,7 @@ static void aggr_printout(struct perf_stat_config *config,if (evsel->percore && !config->percore_show_thread) {fprintf (config->output,"S%d-D%d-C%*d%s" , id.socket, -cpu_map__id_to_die (id.id), + id.die, config->csv_output ?0 :-3 ,cpu_map__id_to_cpu (id.id), config->csv_sep); }else if (id.id >-1 ) {
Signature · 1 line
2.28.0
PATCH v6 11/12 perf tools: Add separate core member
In reply to James ClarkAdd core as a separate member so that it doesn't have to be packed into the int value.
--- tools/perf/builtin-stat.c | 9 +++------ tools/perf/tests/topology.c | 6 +++++- tools/perf/util/cpumap.c | 18 ++++++++++-------- tools/perf/util/cpumap.h | 6 +----- tools/perf/util/stat-display.c | 16 ++++++++-------- 5 files changed, 27 insertions(+), 28 deletions(-)
tools/perf/builtin-stat.c +3 -6
@@ -1404,15 +1404,12 @@ static struct aggr_cpu_id perf_env__get_core(struct perf_cpu_map *map, int idx,if (cpu !=-1 ) {/* * core_id is relative to socket and die, -* we need a global id. So we combine -* socket + die id + core id +* we need a global id. So we set +* socket, die id and core id */ -if (WARN_ONCE (env->cpu[cpu].core_id >>16 ,"The core id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); - id.socket = env->cpu[cpu].socket_id; id.die = env->cpu[cpu].die_id; - id.id = env->cpu[cpu].core_id &0xffff ; + id.core = env->cpu[cpu].core_id; }return id;
tools/perf/tests/topology.c +5 -1
@@ -111,7 +111,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)for (i =0 ; i < map->nr; i++) { id =cpu_map__get_core (map, i,NULL );TEST_ASSERT_VAL ("Core map - Core ID doesn't match" , - session->header.env.cpu[map->map[i]].core_id ==cpu_map__id_to_cpu (id.id)); + session->header.env.cpu[map->map[i]].core_id == id.core);TEST_ASSERT_VAL ("Core map - Socket ID doesn't match" , session->header.env.cpu[map->map[i]].socket_id == id.socket);
@@ -119,6 +119,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , session->header.env.cpu[map->map[i]].die_id == id.die);TEST_ASSERT_VAL ("Core map - Node ID is set" , id.node ==-1 ); +TEST_ASSERT_VAL ("Core map - ID is set" , id.id ==-1 ); }// Test that die ID contains socket and die
@@ -132,6 +133,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Die map - Node ID is set" , id.node ==-1 );TEST_ASSERT_VAL ("Die map - ID is set" , id.id ==-1 ); +TEST_ASSERT_VAL ("Die map - Core is set" , id.core ==-1 ); }// Test that socket ID contains only socket
@@ -143,6 +145,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Socket map - Node ID is set" , id.node ==-1 );TEST_ASSERT_VAL ("Socket map - Die ID is set" , id.die ==-1 );TEST_ASSERT_VAL ("Socket map - ID is set" , id.id ==-1 ); +TEST_ASSERT_VAL ("Socket map - Core is set" , id.core ==-1 ); }// Test that node ID contains only node
@@ -153,6 +156,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Node map - ID is set" , id.id ==-1 );TEST_ASSERT_VAL ("Node map - Socket is set" , id.socket ==-1 );TEST_ASSERT_VAL ("Node map - Die ID is set" , id.die ==-1 ); +TEST_ASSERT_VAL ("Node map - Core is set" , id.core ==-1 ); }perf_session__delete (session);
tools/perf/util/cpumap.c +10 -8
@@ -154,8 +154,10 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer)return a->node - b->node; else if (a->socket != b->socket) return a->socket - b->socket; - else + else if (a->die != b->die) return a->die - b->die; + else + return a->core - b->core; } int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
@@ -258,10 +260,7 @@ struct aggr_cpu_id cpu_map__get_core(struct perf_cpu_map *map, int idx, void *da* core_id is relative to socket and die, we need a global id. * So we combine the result from cpu_map__get_die with the core id */ -if (WARN_ONCE (cpu >>16 ,"The core id number is too big.\n" )) -return cpu_map__empty_aggr_cpu_id (); - - id.id = (cpu &0xffff ); + id.core = cpu;return id; }
@@ -620,7 +619,8 @@ bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b)return a.id == b.id && a.node == b.node && a.socket == b.socket && - a.die == b.die; + a.die == b.die && + a.core == b.core; }bool cpu_map__aggr_cpu_id_is_empty (struct aggr_cpu_id a)
@@ -628,7 +628,8 @@ bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a)return a.id ==-1 && a.node ==-1 && a.socket ==-1 && - a.die ==-1 ; + a.die ==-1 && + a.core ==-1 ; }struct aggr_cpu_id cpu_map__empty_aggr_cpu_id (void )
@@ -637,7 +638,8 @@ struct aggr_cpu_id cpu_map__empty_aggr_cpu_id(void) .id = -1, .node = -1, .socket = -1, - .die = -1 + .die = -1, + .core = -1 };return ret; }
tools/perf/util/cpumap.h +1 -5
@@ -12,6 +12,7 @@ struct aggr_cpu_id {int node;int socket;int die; +int core; };struct cpu_aggr_map {
@@ -50,11 +51,6 @@ static inline int cpu_map__socket(struct perf_cpu_map *sock, int s)return sock->map[s]; } -static inline int cpu_map__id_to_cpu (int id) -{ -return id &0xffff ; -} -int cpu__setup_cpunode_map (void );int cpu__max_node (void );
tools/perf/util/stat-display.c +8 -8
@@ -76,7 +76,7 @@ static void aggr_printout(struct perf_stat_config *config, id.socket, id.die, config->csv_output ?0 :-8 , -cpu_map__id_to_cpu (id.id), + id.core, config->csv_sep, config->csv_output ?0 :4 , nr,
@@ -116,11 +116,11 @@ static void aggr_printout(struct perf_stat_config *config, id.socket, id.die, config->csv_output ?0 :-3 , - cpu_map__id_to_cpu(id.id), config->csv_sep); - }else if (id.id >-1 ) { + id.core, config->csv_sep); + }else if (id.core >-1 ) {fprintf (config->output,"CPU%*d%s" , config->csv_output ?0 :-7 , -evsel__cpus (evsel)->map[id.id], +evsel__cpus (evsel)->map[id.core], config->csv_sep); }break ;
@@ -329,7 +329,7 @@ static int first_shadow_cpu(struct perf_stat_config *config,return 0 ;if (config->aggr_mode ==AGGR_NONE ) -return id.id; +return id.core;if (config->aggr_mode ==AGGR_GLOBAL )return 0 ;
@@ -661,7 +661,7 @@ static void print_counter_aggrdata(struct perf_stat_config *config, uval = val * counter->scale;if (cpu !=-1 ) { id =cpu_map__empty_aggr_cpu_id (); - id.id = cpu; + id.core = cpu; }printout (config, id, nr, counter, uval, prefix, run, ena,1.0 , &rt_stat);
@@ -874,7 +874,7 @@ static void print_counter(struct perf_stat_config *config, uval = val * counter->scale; id =cpu_map__empty_aggr_cpu_id (); - id.id = cpu; + id.core = cpu;printout (config, id,0 , counter, uval, prefix, run, ena,1.0 , &rt_stat);
@@ -901,7 +901,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config,fputs (prefix, config->output);evlist__for_each_entry (evlist, counter) { id =cpu_map__empty_aggr_cpu_id (); - id.id = cpu; + id.core = cpu;if (first) {aggr_printout (config, counter, id,0 ); first = false;
Signature · 1 line
2.28.0
PATCH v6 12/12 perf tools: Add separate thread member
In reply to James ClarkA separate field isn't strictly required. The core field could be re-used for thread IDs as a single field was used previously.
But separating them will avoid confusion and catch potential errors where core IDs are read as thread IDs and vice versa.
Also remove the placeholder id field which is now no longer used.
--- tools/perf/tests/topology.c | 8 ++++---- tools/perf/util/cpumap.c | 14 +++++++------- tools/perf/util/cpumap.h | 2 +- tools/perf/util/stat-display.c | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-)
tools/perf/tests/topology.c +4 -4
@@ -119,7 +119,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Core map - Die ID doesn't match" , session->header.env.cpu[map->map[i]].die_id == id.die);TEST_ASSERT_VAL ("Core map - Node ID is set" , id.node ==-1 ); -TEST_ASSERT_VAL ("Core map - ID is set" , id.id ==-1 ); +TEST_ASSERT_VAL ("Core map - Thread is set" , id.thread ==-1 ); }// Test that die ID contains socket and die
@@ -132,8 +132,8 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) session->header.env.cpu[map->map[i]].die_id == id.die);TEST_ASSERT_VAL ("Die map - Node ID is set" , id.node ==-1 ); -TEST_ASSERT_VAL ("Die map - ID is set" , id.id ==-1 );TEST_ASSERT_VAL ("Die map - Core is set" , id.core ==-1 ); +TEST_ASSERT_VAL ("Die map - Thread is set" , id.thread ==-1 ); }// Test that socket ID contains only socket
@@ -144,8 +144,8 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)TEST_ASSERT_VAL ("Socket map - Node ID is set" , id.node ==-1 );TEST_ASSERT_VAL ("Socket map - Die ID is set" , id.die ==-1 ); -TEST_ASSERT_VAL ("Socket map - ID is set" , id.id ==-1 );TEST_ASSERT_VAL ("Socket map - Core is set" , id.core ==-1 ); +TEST_ASSERT_VAL ("Socket map - Thread is set" , id.thread ==-1 ); }// Test that node ID contains only node
@@ -153,10 +153,10 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) id =cpu_map__get_node (map, i,NULL );TEST_ASSERT_VAL ("Node map - Node ID doesn't match" ,cpu__get_node (map->map[i]) == id.node); -TEST_ASSERT_VAL ("Node map - ID is set" , id.id ==-1 );TEST_ASSERT_VAL ("Node map - Socket is set" , id.socket ==-1 );TEST_ASSERT_VAL ("Node map - Die ID is set" , id.die ==-1 );TEST_ASSERT_VAL ("Node map - Core is set" , id.core ==-1 ); +TEST_ASSERT_VAL ("Node map - Thread is set" , id.thread ==-1 ); }perf_session__delete (session);
tools/perf/util/cpumap.c +7 -7
@@ -148,16 +148,16 @@ static int cmp_aggr_cpu_id(const void *a_pointer, const void *b_pointer)struct aggr_cpu_id *a = (struct aggr_cpu_id *)a_pointer;struct aggr_cpu_id *b = (struct aggr_cpu_id *)b_pointer; -if (a->id != b->id) -return a->id - b->id; -else if (a->node != b->node) +if (a->node != b->node)return a->node - b->node;else if (a->socket != b->socket)return a->socket - b->socket;else if (a->die != b->die)return a->die - b->die; -else +else if (a->core != b->core)return a->core - b->core; +else +return a->thread - b->thread; } int cpu_map__build_map(struct perf_cpu_map *cpus, struct cpu_aggr_map **res,
@@ -616,7 +616,7 @@ const struct perf_cpu_map *cpu_map__online(void) /* thread unsafe */bool cpu_map__compare_aggr_cpu_id (struct aggr_cpu_id a,struct aggr_cpu_id b) { -return a.id == b.id && +return a.thread == b.thread && a.node == b.node && a.socket == b.socket && a.die == b.die &&
@@ -625,7 +625,7 @@ bool cpu_map__compare_aggr_cpu_id(struct aggr_cpu_id a, struct aggr_cpu_id b)bool cpu_map__aggr_cpu_id_is_empty (struct aggr_cpu_id a) { -return a.id ==-1 && +return a.thread ==-1 && a.node ==-1 && a.socket ==-1 && a.die == -1 &&
@@ -635,7 +635,7 @@ bool cpu_map__aggr_cpu_id_is_empty(struct aggr_cpu_id a)struct aggr_cpu_id cpu_map__empty_aggr_cpu_id (void ) {struct aggr_cpu_id ret = { - .id =-1 , + .thread =-1 , .node =-1 , .socket =-1 , .die =-1 ,
tools/perf/util/cpumap.h +1 -1
@@ -8,7 +8,7 @@#include <perf/cpumap.h> struct aggr_cpu_id { -int id; +int thread;int node;int socket;int die;
tools/perf/util/stat-display.c +4 -4
@@ -127,9 +127,9 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_THREAD :fprintf (config->output,"%*s-%*d%s" , config->csv_output ?0 :16 , -perf_thread_map__comm (evsel->core.threads, id.id), +perf_thread_map__comm (evsel->core.threads, id.thread), config->csv_output ?0 :-8 , -perf_thread_map__pid (evsel->core.threads, id.id), +perf_thread_map__pid (evsel->core.threads, id.thread), config->csv_sep);break ;case AGGR_GLOBAL :
@@ -743,7 +743,7 @@ static struct perf_aggr_thread_value *sort_aggr_thread( buf[i].counter = counter; buf[i].id =cpu_map__empty_aggr_cpu_id (); - buf[i].id.id = thread; + buf[i].id.thread = thread; buf[i].uval = uval; buf[i].val = val; buf[i].run = run;
@@ -784,7 +784,7 @@ static void print_aggr_thread(struct perf_stat_config *config,if (config->stats)printout (config, id,0 , buf[thread].counter, buf[thread].uval, prefix, buf[thread].run, buf[thread].ena,1.0 , - &config->stats[id.id]); + &config->stats[id.thread]);else printout(config, id, 0, buf[thread].counter, buf[thread].uval, prefix, buf[thread].run, buf[thread].ena, 1.0,
Signature · 1 line
2.28.0
Hello,
Quoted 6 lines · James Clark
Changes since v5:
* Fix test forcpu_map__get_die()by shifting id before testing.
* Fix test forcpu_map__get_socket()by not usingcpu_map__id_to_socket()which is only valid in CPU aggregation mode.
Quoted 13 lines
James Clark (12):
perf tools: Improve topology test
perf tools: Use allocator forperf_cpu_mapperf tools: Add new struct for cpu aggregation perf tools: Replace aggregation ID with a struct perf tools: add new map type for aggregation perf tools: drop incpu_aggr_mapstruct perf tools: Start usingcpu_aggr_idin map perf tools: Add separate node member perf tools: Add separate socket member perf tools: Add separate die member
perf tools: Add separate core member perf tools: Add separate thread member
Thanks,
Namhyung
Quoted 13 lines
tools/perf/builtin-stat.c | 128 ++++++++++++------------ tools/perf/tests/topology.c | 64 ++++++++++-- tools/perf/util/cpumap.c | 171 ++++++++++++++++++++++----------- tools/perf/util/cpumap.h | 55 ++++++----- tools/perf/util/stat-display.c | 102 ++++++++++++-------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 9 +- 7 files changed, 337 insertions(+), 194 deletions(-)--
2.28.0
Quoted 5 lines · James Clark
Changes since v5:
* Fix test forcpu_map__get_die()by shifting id before testing.
* Fix test forcpu_map__get_socket()by not usingcpu_map__id_to_socket()which is only valid in CPU aggregation mode.
Quoted 13 lines
James Clark (12):
perf tools: Improve topology test
perf tools: Use allocator forperf_cpu_mapperf tools: Add new struct for cpu aggregation perf tools: Replace aggregation ID with a struct perf tools: add new map type for aggregation perf tools: drop incpu_aggr_mapstruct perf tools: Start usingcpu_aggr_idin map perf tools: Add separate node member perf tools: Add separate socket member perf tools: Add separate die member
perf tools: Add separate core member perf tools: Add separate thread member
thanks,
jirka
Quoted 13 lines
tools/perf/builtin-stat.c | 128 ++++++++++++------------ tools/perf/tests/topology.c | 64 ++++++++++-- tools/perf/util/cpumap.c | 171 ++++++++++++++++++++++----------- tools/perf/util/cpumap.h | 55 ++++++----- tools/perf/util/stat-display.c | 102 ++++++++++++-------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 9 +- 7 files changed, 337 insertions(+), 194 deletions(-)Signature · 1 line
2.28.0
John Garry
Tested-byOn 03/12/2020 15:39, Jiri Olsa wrote:
+
Quoted 20 lines · James Clark
Quoted 5 lines
Changes since v5:
* Fix test forcpu_map__get_die()by shifting id before testing.
* Fix test forcpu_map__get_socket()by not usingcpu_map__id_to_socket()which is only valid in CPU aggregation mode.Quoted 13 lines
James Clark (12):
perf tools: Improve topology test
perf tools: Use allocator forperf_cpu_mapperf tools: Add new struct for cpu aggregation perf tools: Replace aggregation ID with a struct perf tools: add new map type for aggregation perf tools: drop incpu_aggr_mapstruct perf tools: Start usingcpu_aggr_idin map perf tools: Add separate node member perf tools: Add separate socket member perf tools: Add separate die member
perf tools: Add separate core member perf tools: Add separate thread member
Quoted 2 lines
Acked-by Jiri Olsa <[email protected]>
I still think that vendors (like us) need to fix/improve their firmware tables so that we don't get silly big numbers for socket/package IDs, like S5418-D0, below:
$./perf stat -a --per-die
Performance counter stats for 'system wide':
S36-D0 48 72,216.31 msec cpu-clock # 47.933 CPUs utilized S36-D0 48 174 context-switches # 0.002 K/sec S36-D0 48 48 cpu-migrations # 0.001 K/sec S36-D0 48 0 page-faults # 0.000 K/sec S36-D0 48 7,991,698 cycles # 0.000 GHz S36-D0 48 4,750,040 instructions # 0.59 insn per cycle S36-D0 1 <not supported> branches S36-D0 48 32,928 branch-misses # 0.00% of all branches S5418-D0 48 72,189.54 msec cpu-clock # 47.915 CPUs utilized S5418-D0 48 176 context-switches # 0.002 K/sec S5418-D0 48 48 cpu-migrations # 0.001 K/sec S5418-D0 48 0 page-faults # 0.000 K/sec S5418-D0 48 5,677,218 cycles # 0.000 GHz S5418-D0 48 3,872,285 instructions # 0.68 insn per cycle
S5418-D0 1 <not supported> branches
S5418-D0 48 29,208 branch-misses # 0.00% of all branches
1.506615297 seconds time elapsed
but at least it works now. Thanks.
Quoted 17 lines
Quoted 14 lines
tools/perf/builtin-stat.c | 128 ++++++++++++------------ tools/perf/tests/topology.c | 64 ++++++++++-- tools/perf/util/cpumap.c | 171 ++++++++++++++++++++++----------- tools/perf/util/cpumap.h | 55 ++++++----- tools/perf/util/stat-display.c | 102 ++++++++++++-------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 9 +- 7 files changed, 337 insertions(+), 194 deletions(-)Signature · 1 line
2.28.0.
Quoted 24 lines · John Garry
On 03/12/2020 15:39, Jiri Olsa wrote:
+
Quoted 20 lines · James Clark
Quoted 18 lines
Changes since v5:
* Fix test forcpu_map__get_die()by shifting id before testing.
* Fix test forcpu_map__get_socket()by not usingcpu_map__id_to_socket()which is only valid in CPU aggregation mode.James Clark (12):
perf tools: Improve topology test
perf tools: Use allocator forperf_cpu_mapperf tools: Add new struct for cpu aggregation perf tools: Replace aggregation ID with a struct perf tools: add new map type for aggregation perf tools: drop incpu_aggr_mapstruct perf tools: Start usingcpu_aggr_idin map perf tools: Add separate node member perf tools: Add separate socket member perf tools: Add separate die member
perf tools: Add separate core member perf tools: Add separate thread member
Quoted 4 lines
Quoted 2 lines
Acked-by Jiri Olsa <[email protected]>Tested-by John Garry <[email protected]>
hi,
I was wondering where this went, and noticed that
Arnaldo was not CC-ed on the cover letter ;-)
jirka
Quoted 48 lines
I still think that vendors (like us) need to fix/improve their firmware tables so that we don't get silly big numbers for socket/package IDs, like S5418-D0, below:
$./perf stat -a --per-die
Performance counter stats for 'system wide':
S36-D0 48 72,216.31 msec cpu-clock # 47.933 CPUs utilized S36-D0 48 174 context-switches # 0.002 K/sec S36-D0 48 48 cpu-migrations # 0.001 K/sec S36-D0 48 0 page-faults # 0.000 K/sec S36-D0 48 7,991,698 cycles # 0.000 GHz S36-D0 48 4,750,040 instructions # 0.59 insn per cycle S36-D0 1 <not supported> branches S36-D0 48 32,928 branch-misses # 0.00% of all branches S5418-D0 48 72,189.54 msec cpu-clock # 47.915 CPUs utilized S5418-D0 48 176 context-switches # 0.002 K/sec S5418-D0 48 48 cpu-migrations # 0.001 K/sec S5418-D0 48 0 page-faults # 0.000 K/sec S5418-D0 48 5,677,218 cycles # 0.000 GHz S5418-D0 48 3,872,285 instructions # 0.68 insn per cycleS5418-D0 1 <not supported> branches
S5418-D0 48 29,208 branch-misses # 0.00% of all branches1.506615297 seconds time elapsedbut at least it works now. Thanks.
Quoted 17 lines
Quoted 14 lines
tools/perf/builtin-stat.c | 128 ++++++++++++------------ tools/perf/tests/topology.c | 64 ++++++++++-- tools/perf/util/cpumap.c | 171 ++++++++++++++++++++++----------- tools/perf/util/cpumap.h | 55 ++++++----- tools/perf/util/stat-display.c | 102 ++++++++++++-------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 9 +- 7 files changed, 337 insertions(+), 194 deletions(-)Signature · 1 line
2.28.0.
Arnaldo Carvalho de Melo
maintainerEm Wed, Dec 23, 2020 at 11:17:47PM +0100, Jiri Olsa escreveu:
Quoted 25 lines · John Garry
Quoted 24 lines · Jiri Olsa
+
Quoted 20 lines · James Clark
Quoted 18 lines
Changes since v5:
* Fix test forcpu_map__get_die()by shifting id before testing.
* Fix test forcpu_map__get_socket()by not usingcpu_map__id_to_socket()which is only valid in CPU aggregation mode.James Clark (12):
perf tools: Improve topology test
perf tools: Use allocator forperf_cpu_mapperf tools: Add new struct for cpu aggregation perf tools: Replace aggregation ID with a struct perf tools: add new map type for aggregation perf tools: drop incpu_aggr_mapstruct perf tools: Start usingcpu_aggr_idin map perf tools: Add separate node member perf tools: Add separate socket member perf tools: Add separate die member
perf tools: Add separate core member perf tools: Add separate thread member
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Acked-by Jiri Olsa <[email protected]>Tested-by John Garry <[email protected]>hi,
I was wondering where this went, and noticed that
Arnaldo was not CC-ed on the cover letter ;-)
Looking at it right now, used the Message-ID and b4 got everything, there are some fuzzies that I'm checking:
[acme@five perf]$ git am --show-current-patch=diff | patch -p1 patching file tools/perf/builtin-stat.c
Hunk #1 succeeded at 1186 (offset -2 lines).
Hunk #2 succeeded at 1347 (offset -2 lines).
Hunk #3 succeeded at 1373 (offset -2 lines).
Hunk #4 succeeded at 1399 (offset -2 lines).
Hunk #5 succeeded at 1448 (offset -2 lines). patching file tools/perf/tests/topology.c
patching file tools/perf/util/cpumap.c
patching file tools/perf/util/cpumap.h
patching file tools/perf/util/stat-display.c
Hunk #8 succeeded at 326 with fuzz 2 (offset -3 lines). Hunk #9 succeeded at 334 (offset -3 lines).
Hunk #10 succeeded at 397 (offset -3 lines).
Hunk #11 succeeded at 500 (offset -3 lines).
Hunk #12 succeeded at 589 (offset -3 lines).
Hunk #13 succeeded at 598 (offset -3 lines).
Hunk #14 succeeded at 634 (offset -3 lines).
Hunk #15 succeeded at 656 (offset -3 lines).
Hunk #16 succeeded at 739 (offset -3 lines).
Hunk #17 succeeded at 763 (offset -3 lines).
Hunk #18 succeeded at 781 (offset -3 lines).
Hunk #19 succeeded at 827 (offset -3 lines).
Hunk #20 succeeded at 855 (offset -3 lines).
Hunk #21 succeeded at 870 (offset -3 lines).
Hunk #22 succeeded at 888 (offset -3 lines).
Hunk #23 succeeded at 897 (offset -3 lines).
Hunk #24 succeeded at 908 (offset -3 lines).
Hunk #25 succeeded at 1159 (offset -3 lines). patching file tools/perf/util/stat.c
patching file tools/perf/util/stat.h
[acme@five perf]$
[acme@five perf]$ git am --show-current-patch=diff | head -20
--- tools/perf/builtin-stat.c | 76 +++++++++++++---------- tools/perf/tests/topology.c | 17 +++--- tools/perf/util/cpumap.c | 82 ++++++++++++++----------- tools/perf/util/cpumap.h | 10 +-- tools/perf/util/stat-display.c | 108 +++++++++++++++++++-------------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 5 +- 7 files changed, 173 insertions(+), 127 deletions(-)
tools/perf/builtin-stat.c +1 -1
@@ -1188,65 +1188,67 @@ static struct option stat_options[] = {OPT_END () }; -static int perf_stat__get_socket(struct perf_stat_config *config __maybe_unused, +static struct aggr_cpu_id perf_stat__get_socket(struct perf_stat_config *config __maybe_unused,
[acme@five perf]$
Quoted 51 lines
jirka
Quoted 48 lines
I still think that vendors (like us) need to fix/improve their firmware tables so that we don't get silly big numbers for socket/package IDs, like S5418-D0, below:
$./perf stat -a --per-die
Performance counter stats for 'system wide':
S36-D0 48 72,216.31 msec cpu-clock # 47.933 CPUs utilized S36-D0 48 174 context-switches # 0.002 K/sec S36-D0 48 48 cpu-migrations # 0.001 K/sec S36-D0 48 0 page-faults # 0.000 K/sec S36-D0 48 7,991,698 cycles # 0.000 GHz S36-D0 48 4,750,040 instructions # 0.59 insn per cycle S36-D0 1 <not supported> branches S36-D0 48 32,928 branch-misses # 0.00% of all branches S5418-D0 48 72,189.54 msec cpu-clock # 47.915 CPUs utilized S5418-D0 48 176 context-switches # 0.002 K/sec S5418-D0 48 48 cpu-migrations # 0.001 K/sec S5418-D0 48 0 page-faults # 0.000 K/sec S5418-D0 48 5,677,218 cycles # 0.000 GHz S5418-D0 48 3,872,285 instructions # 0.68 insn per cycleS5418-D0 1 <not supported> branches
S5418-D0 48 29,208 branch-misses # 0.00% of all branches1.506615297 seconds time elapsedbut at least it works now. Thanks.
Quoted 17 lines
Quoted 14 lines
tools/perf/builtin-stat.c | 128 ++++++++++++------------ tools/perf/tests/topology.c | 64 ++++++++++-- tools/perf/util/cpumap.c | 171 ++++++++++++++++++++++----------- tools/perf/util/cpumap.h | 55 ++++++----- tools/perf/util/stat-display.c | 102 ++++++++++++-------- tools/perf/util/stat.c | 2 +- tools/perf/util/stat.h | 9 +- 7 files changed, 337 insertions(+), 194 deletions(-)Signature · 1 line
2.28.0.
Signature · 1 line
- Arnaldo