diff options
author | Petr Holasek <pholasek@redhat.com> | 2015-04-16 11:38:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-05-04 11:43:41 -0400 |
commit | b64aa553d8430aabd24f303899cfa4de678e2c3a (patch) | |
tree | 19a87df3b52c6d92c792dbf462614e301caa8fb7 /tools/perf/bench/numa.c | |
parent | 762abdc0c6c013425958cd9f5105f4e32268d434 (diff) |
perf bench numa: Show more stats of particular threads in verbose mode
In verbose mode perf bench numa shows also GB/s speed, system and user cpu
time for each particular thread. Using of getrusage() can provide much more
per process or per thread stats in future.
Signed-off-by: Petr Holasek <pholasek@redhat.com>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1429198699-25039-3-git-send-email-pholasek@redhat.com
[ Rename 'usage' variable to not shadow util.h's usage() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bench/numa.c')
-rw-r--r-- | tools/perf/bench/numa.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index ebfa163b80b5..0b704c5f6d90 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <pthread.h> | 23 | #include <pthread.h> |
24 | #include <sys/mman.h> | 24 | #include <sys/mman.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <sys/resource.h> | ||
26 | #include <sys/wait.h> | 27 | #include <sys/wait.h> |
27 | #include <sys/prctl.h> | 28 | #include <sys/prctl.h> |
28 | #include <sys/types.h> | 29 | #include <sys/types.h> |
@@ -51,6 +52,9 @@ struct thread_data { | |||
51 | unsigned int loops_done; | 52 | unsigned int loops_done; |
52 | u64 val; | 53 | u64 val; |
53 | u64 runtime_ns; | 54 | u64 runtime_ns; |
55 | u64 system_time_ns; | ||
56 | u64 user_time_ns; | ||
57 | double speed_gbs; | ||
54 | pthread_mutex_t *process_lock; | 58 | pthread_mutex_t *process_lock; |
55 | }; | 59 | }; |
56 | 60 | ||
@@ -1034,6 +1038,7 @@ static void *worker_thread(void *__tdata) | |||
1034 | u64 bytes_done; | 1038 | u64 bytes_done; |
1035 | long work_done; | 1039 | long work_done; |
1036 | u32 l; | 1040 | u32 l; |
1041 | struct rusage rusage; | ||
1037 | 1042 | ||
1038 | bind_to_cpumask(td->bind_cpumask); | 1043 | bind_to_cpumask(td->bind_cpumask); |
1039 | bind_to_memnode(td->bind_node); | 1044 | bind_to_memnode(td->bind_node); |
@@ -1186,6 +1191,13 @@ static void *worker_thread(void *__tdata) | |||
1186 | timersub(&stop, &start0, &diff); | 1191 | timersub(&stop, &start0, &diff); |
1187 | td->runtime_ns = diff.tv_sec * 1000000000ULL; | 1192 | td->runtime_ns = diff.tv_sec * 1000000000ULL; |
1188 | td->runtime_ns += diff.tv_usec * 1000ULL; | 1193 | td->runtime_ns += diff.tv_usec * 1000ULL; |
1194 | td->speed_gbs = bytes_done / (td->runtime_ns / 1e9) / 1e9; | ||
1195 | |||
1196 | getrusage(RUSAGE_THREAD, &rusage); | ||
1197 | td->system_time_ns = rusage.ru_stime.tv_sec * 1000000000ULL; | ||
1198 | td->system_time_ns += rusage.ru_stime.tv_usec * 1000ULL; | ||
1199 | td->user_time_ns = rusage.ru_utime.tv_sec * 1000000000ULL; | ||
1200 | td->user_time_ns += rusage.ru_utime.tv_usec * 1000ULL; | ||
1189 | 1201 | ||
1190 | free_data(thread_data, g->p.bytes_thread); | 1202 | free_data(thread_data, g->p.bytes_thread); |
1191 | 1203 | ||
@@ -1412,7 +1424,7 @@ static int __bench_numa(const char *name) | |||
1412 | double runtime_sec_min; | 1424 | double runtime_sec_min; |
1413 | int wait_stat; | 1425 | int wait_stat; |
1414 | double bytes; | 1426 | double bytes; |
1415 | int i, t; | 1427 | int i, t, p; |
1416 | 1428 | ||
1417 | if (init()) | 1429 | if (init()) |
1418 | return -1; | 1430 | return -1; |
@@ -1548,6 +1560,24 @@ static int __bench_numa(const char *name) | |||
1548 | print_res(name, bytes / runtime_sec_max / 1e9, | 1560 | print_res(name, bytes / runtime_sec_max / 1e9, |
1549 | "GB/sec,", "total-speed", "GB/sec total speed"); | 1561 | "GB/sec,", "total-speed", "GB/sec total speed"); |
1550 | 1562 | ||
1563 | if (g->p.show_details >= 2) { | ||
1564 | char tname[32]; | ||
1565 | struct thread_data *td; | ||
1566 | for (p = 0; p < g->p.nr_proc; p++) { | ||
1567 | for (t = 0; t < g->p.nr_threads; t++) { | ||
1568 | memset(tname, 0, 32); | ||
1569 | td = g->threads + p*g->p.nr_threads + t; | ||
1570 | snprintf(tname, 32, "process%d:thread%d", p, t); | ||
1571 | print_res(tname, td->speed_gbs, | ||
1572 | "GB/sec", "thread-speed", "GB/sec/thread speed"); | ||
1573 | print_res(tname, td->system_time_ns / 1e9, | ||
1574 | "secs", "thread-system-time", "system CPU time/thread"); | ||
1575 | print_res(tname, td->user_time_ns / 1e9, | ||
1576 | "secs", "thread-user-time", "user CPU time/thread"); | ||
1577 | } | ||
1578 | } | ||
1579 | } | ||
1580 | |||
1551 | free(pids); | 1581 | free(pids); |
1552 | 1582 | ||
1553 | deinit(); | 1583 | deinit(); |