Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753247AbbDPPi4 (ORCPT ); Thu, 16 Apr 2015 11:38:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36772 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751580AbbDPPic (ORCPT ); Thu, 16 Apr 2015 11:38:32 -0400 From: Petr Holasek To: linux-kernel@vger.kernel.org Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Ingo Molnar , Petr Holasek Subject: [PATCH 2/3] perf bench numa: show more stats of particular threads in verbose mode Date: Thu, 16 Apr 2015 17:38:18 +0200 Message-Id: <1429198699-25039-3-git-send-email-pholasek@redhat.com> In-Reply-To: <1429198699-25039-1-git-send-email-pholasek@redhat.com> References: <1429198699-25039-1-git-send-email-pholasek@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2936 Lines: 95 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 --- tools/perf/bench/numa.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c index cd872e9c..72edc49 100644 --- a/tools/perf/bench/numa.c +++ b/tools/perf/bench/numa.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,9 @@ struct thread_data { unsigned int loops_done; u64 val; u64 runtime_ns; + u64 system_time_ns; + u64 user_time_ns; + double speed_gbs; pthread_mutex_t *process_lock; }; @@ -1034,6 +1038,7 @@ static void *worker_thread(void *__tdata) u64 bytes_done; long work_done; u32 l; + struct rusage usage; bind_to_cpumask(td->bind_cpumask); bind_to_memnode(td->bind_node); @@ -1186,6 +1191,13 @@ static void *worker_thread(void *__tdata) timersub(&stop, &start0, &diff); td->runtime_ns = diff.tv_sec * 1000000000ULL; td->runtime_ns += diff.tv_usec * 1000ULL; + td->speed_gbs = bytes_done / (td->runtime_ns / 1e9) / 1e9; + + getrusage(RUSAGE_THREAD, &usage); + td->system_time_ns = usage.ru_stime.tv_sec * 1000000000ULL; + td->system_time_ns += usage.ru_stime.tv_usec * 1000ULL; + td->user_time_ns = usage.ru_utime.tv_sec * 1000000000ULL; + td->user_time_ns += usage.ru_utime.tv_usec * 1000ULL; free_data(thread_data, g->p.bytes_thread); @@ -1412,7 +1424,7 @@ static int __bench_numa(const char *name) double runtime_sec_min; int wait_stat; double bytes; - int i, t; + int i, t, p; if (init()) return -1; @@ -1548,6 +1560,24 @@ static int __bench_numa(const char *name) print_res(name, bytes / runtime_sec_max / 1e9, "GB/sec,", "total-speed", "GB/sec total speed"); + if (g->p.show_details >= 2) { + char tname[32]; + struct thread_data *td; + for (p = 0; p < g->p.nr_proc; p++) { + for (t = 0; t < g->p.nr_threads; t++) { + memset(tname, 0, 32); + td = g->threads + p*g->p.nr_threads + t; + snprintf(tname, 32, "process%d:thread%d", p, t); + print_res(tname, td->speed_gbs, + "GB/sec", "thread-speed", "GB/sec/thread speed"); + print_res(tname, td->system_time_ns / 1e9, + "secs", "thread-system-time", "system CPU time/thread"); + print_res(tname, td->user_time_ns / 1e9, + "secs", "thread-user-time", "user CPU time/thread"); + } + } + } + free(pids); deinit(); -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/