builtin-stat.c (eff54c24bb147afc0a1423b49bfa1b8eaa85a88f) builtin-stat.c (51b826fadf4fc42c8614b752b6cb0cb516589ade)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * builtin-stat.c
4 *
5 * Builtin stat command: Give a precise performance counters summary
6 * overview about any workload, CPU or specific PID.
7 *
8 * Sample output:

--- 1335 unchanged lines hidden (view full) ---

1344 int cpu)
1345{
1346 return cpu_map__get_node_aggr_by_cpu(cpu, /*data=*/NULL);
1347}
1348
1349static struct aggr_cpu_id perf_stat__get_aggr(struct perf_stat_config *config,
1350 aggr_get_id_t get_id, int cpu)
1351{
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * builtin-stat.c
4 *
5 * Builtin stat command: Give a precise performance counters summary
6 * overview about any workload, CPU or specific PID.
7 *
8 * Sample output:

--- 1335 unchanged lines hidden (view full) ---

1344 int cpu)
1345{
1346 return cpu_map__get_node_aggr_by_cpu(cpu, /*data=*/NULL);
1347}
1348
1349static struct aggr_cpu_id perf_stat__get_aggr(struct perf_stat_config *config,
1350 aggr_get_id_t get_id, int cpu)
1351{
1352 struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id();
1352 struct aggr_cpu_id id = aggr_cpu_id__empty();
1353
1353
1354 if (cpu_map__aggr_cpu_id_is_empty(config->cpus_aggr_map->map[cpu]))
1354 if (aggr_cpu_id__is_empty(&config->cpus_aggr_map->map[cpu]))
1355 config->cpus_aggr_map->map[cpu] = get_id(config, cpu);
1356
1357 id = config->cpus_aggr_map->map[cpu];
1358 return id;
1359}
1360
1361static struct aggr_cpu_id perf_stat__get_socket_cached(struct perf_stat_config *config,
1362 int cpu)

--- 112 unchanged lines hidden (view full) ---

1475 cpu_aggr_map__put(stat_config.cpus_aggr_map);
1476 stat_config.aggr_map = NULL;
1477 stat_config.cpus_aggr_map = NULL;
1478}
1479
1480static struct aggr_cpu_id perf_env__get_socket_aggr_by_cpu(int cpu, void *data)
1481{
1482 struct perf_env *env = data;
1355 config->cpus_aggr_map->map[cpu] = get_id(config, cpu);
1356
1357 id = config->cpus_aggr_map->map[cpu];
1358 return id;
1359}
1360
1361static struct aggr_cpu_id perf_stat__get_socket_cached(struct perf_stat_config *config,
1362 int cpu)

--- 112 unchanged lines hidden (view full) ---

1475 cpu_aggr_map__put(stat_config.cpus_aggr_map);
1476 stat_config.aggr_map = NULL;
1477 stat_config.cpus_aggr_map = NULL;
1478}
1479
1480static struct aggr_cpu_id perf_env__get_socket_aggr_by_cpu(int cpu, void *data)
1481{
1482 struct perf_env *env = data;
1483 struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id();
1483 struct aggr_cpu_id id = aggr_cpu_id__empty();
1484
1485 if (cpu != -1)
1486 id.socket = env->cpu[cpu].socket_id;
1487
1488 return id;
1489}
1490
1491static struct aggr_cpu_id perf_env__get_die_aggr_by_cpu(int cpu, void *data)
1492{
1493 struct perf_env *env = data;
1484
1485 if (cpu != -1)
1486 id.socket = env->cpu[cpu].socket_id;
1487
1488 return id;
1489}
1490
1491static struct aggr_cpu_id perf_env__get_die_aggr_by_cpu(int cpu, void *data)
1492{
1493 struct perf_env *env = data;
1494 struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id();
1494 struct aggr_cpu_id id = aggr_cpu_id__empty();
1495
1496 if (cpu != -1) {
1497 /*
1498 * die_id is relative to socket, so start
1499 * with the socket ID and then add die to
1500 * make a unique ID.
1501 */
1502 id.socket = env->cpu[cpu].socket_id;
1503 id.die = env->cpu[cpu].die_id;
1504 }
1505
1506 return id;
1507}
1508
1509static struct aggr_cpu_id perf_env__get_core_aggr_by_cpu(int cpu, void *data)
1510{
1511 struct perf_env *env = data;
1495
1496 if (cpu != -1) {
1497 /*
1498 * die_id is relative to socket, so start
1499 * with the socket ID and then add die to
1500 * make a unique ID.
1501 */
1502 id.socket = env->cpu[cpu].socket_id;
1503 id.die = env->cpu[cpu].die_id;
1504 }
1505
1506 return id;
1507}
1508
1509static struct aggr_cpu_id perf_env__get_core_aggr_by_cpu(int cpu, void *data)
1510{
1511 struct perf_env *env = data;
1512 struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id();
1512 struct aggr_cpu_id id = aggr_cpu_id__empty();
1513
1514 if (cpu != -1) {
1515 /*
1516 * core_id is relative to socket and die,
1517 * we need a global id. So we set
1518 * socket, die id and core id
1519 */
1520 id.socket = env->cpu[cpu].socket_id;
1521 id.die = env->cpu[cpu].die_id;
1522 id.core = env->cpu[cpu].core_id;
1523 }
1524
1525 return id;
1526}
1527
1528static struct aggr_cpu_id perf_env__get_node_aggr_by_cpu(int cpu, void *data)
1529{
1513
1514 if (cpu != -1) {
1515 /*
1516 * core_id is relative to socket and die,
1517 * we need a global id. So we set
1518 * socket, die id and core id
1519 */
1520 id.socket = env->cpu[cpu].socket_id;
1521 id.die = env->cpu[cpu].die_id;
1522 id.core = env->cpu[cpu].core_id;
1523 }
1524
1525 return id;
1526}
1527
1528static struct aggr_cpu_id perf_env__get_node_aggr_by_cpu(int cpu, void *data)
1529{
1530 struct aggr_cpu_id id = cpu_map__empty_aggr_cpu_id();
1530 struct aggr_cpu_id id = aggr_cpu_id__empty();
1531
1532 id.node = perf_env__numa_node(data, cpu);
1533 return id;
1534}
1535
1536static int perf_env__build_socket_map(struct perf_env *env, struct perf_cpu_map *cpus,
1537 struct cpu_aggr_map **sockp)
1538{

--- 1078 unchanged lines hidden ---
1531
1532 id.node = perf_env__numa_node(data, cpu);
1533 return id;
1534}
1535
1536static int perf_env__build_socket_map(struct perf_env *env, struct perf_cpu_map *cpus,
1537 struct cpu_aggr_map **sockp)
1538{

--- 1078 unchanged lines hidden ---