diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-12-25 11:07:34 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-12-25 11:07:34 -0800 |
commit | 5814bc2d4cc241c1a603fac2b5bf1bd4daa108fc (patch) | |
tree | 2d1d4156be425c2d147379d5a6760464b1f8233f /tools/perf/tests/topology.c | |
parent | 42dc45e84452c1ee72c482d477a2e71c0689b143 (diff) | |
parent | 5149303fdfe5c67ddb51c911e23262f781cd75eb (diff) | |
download | lwn-5814bc2d4cc241c1a603fac2b5bf1bd4daa108fc.tar.gz lwn-5814bc2d4cc241c1a603fac2b5bf1bd4daa108fc.zip |
Merge tag 'perf-tools-2020-12-24' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull more perf tools updates from Arnaldo Carvalho de Melo:
- Refactor 'perf stat' per CPU/socket/die/thread aggregation fixing use
cases in ARM machines.
- Fix memory leak when synthesizing SDT probes in 'perf probe'.
- Update kernel header copies related to KVM, epol_pwait. msr-index and
powerpc and s390 syscall tables.
* tag 'perf-tools-2020-12-24' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (24 commits)
perf probe: Fix memory leak when synthesizing SDT probes
perf stat aggregation: Add separate thread member
perf stat aggregation: Add separate core member
perf stat aggregation: Add separate die member
perf stat aggregation: Add separate socket member
perf stat aggregation: Add separate node member
perf stat aggregation: Start using cpu_aggr_id in map
perf cpumap: Drop in cpu_aggr_map struct
perf cpumap: Add new map type for aggregation
perf stat: Replace aggregation ID with a struct
perf cpumap: Add new struct for cpu aggregation
perf cpumap: Use existing allocator to avoid using malloc
perf tests: Improve topology test to check all aggregation types
perf tools: Update s390's syscall.tbl copy from the kernel sources
perf tools: Update powerpc's syscall.tbl copy from the kernel sources
perf s390: Move syscall.tbl check into check-headers.sh
perf powerpc: Move syscall.tbl check to check-headers.sh
tools headers UAPI: Synch KVM's svm.h header with the kernel
tools kvm headers: Update KVM headers from the kernel sources
tools headers UAPI: Sync KVM's vmx.h header with the kernel sources
...
Diffstat (limited to 'tools/perf/tests/topology.c')
-rw-r--r-- | tools/perf/tests/topology.c | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c index 165feedc7863..74748ed75b2c 100644 --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c @@ -65,9 +65,11 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) .mode = PERF_DATA_MODE_READ, }; int i; + struct aggr_cpu_id 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 +87,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 +107,57 @@ 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 == id.core); + + TEST_ASSERT_VAL("Core map - Socket ID doesn't match", + 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 == id.die); + TEST_ASSERT_VAL("Core map - Node ID is set", id.node == -1); + TEST_ASSERT_VAL("Core map - Thread is set", id.thread == -1); + } + + // 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 == id.socket); - 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_ASSERT_VAL("Die map - Die ID doesn't match", + 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 - Core is set", id.core == -1); + TEST_ASSERT_VAL("Die map - Thread is set", id.thread == -1); + } + + // 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.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 - Core is set", id.core == -1); + TEST_ASSERT_VAL("Socket map - Thread is set", id.thread == -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.node); + 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); return 0; |