From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752428AbbFZJ3s (ORCPT ); Fri, 26 Jun 2015 05:29:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54634 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051AbbFZJ3f (ORCPT ); Fri, 26 Jun 2015 05:29:35 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Adrian Hunter , Andi Kleen , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Stephane Eranian Subject: [PATCHv5 00/22] perf stat: Introduce --per-thread option Date: Fri, 26 Jun 2015 11:29:05 +0200 Message-Id: <1435310967-14570-1-git-send-email-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi, adding the possibility to display stat data per thread. Allowing following commands and output: $ perf stat -e cycles,instructions --per-thread -p 30190,30242 ^C Performance counter stats for process id '30190,30242': cat-30190 0 cycles yes-30242 3,842,525,421 cycles cat-30190 0 instructions yes-30242 10,370,817,010 instructions 1.143155657 seconds time elapsed Also works under interval mode: $ perf stat -e cycles,instructions --per-thread -p 30190,30242 -I 1000 # time comm-pid counts unit events 1.000073435 cat-30190 89,058 cycles 1.000073435 yes-30242 3,360,786,902 cycles (100.00%) 1.000073435 cat-30190 14,066 instructions 1.000073435 yes-30242 9,069,937,462 instructions 2.000204830 cat-30190 0 cycles 2.000204830 yes-30242 3,351,667,626 cycles 2.000204830 cat-30190 0 instructions 2.000204830 yes-30242 9,045,796,885 instructions ^C 2.771286639 cat-30190 0 cycles 2.771286639 yes-30242 2,593,884,166 cycles 2.771286639 cat-30190 0 instructions 2.771286639 yes-30242 7,001,171,191 instructions Available in here: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git perf/per_thread v5 changes: - reading comms explicitly by thread_map__read_comms, so it gets read only within 'perf stat --per-thread' - introducing thread_map__reset function - several patches got accepted, rebased on latest perf/core v4 changes: - add thread_map__set_(pid|comm) interface - several fixes for task comm string reading - added perf_evlist__reset_stats function v3 changes: - some patches already pulled in, rebased on latest acme's perf/core - fixed cpu_map__get/thread_map__get to accept NULL map - renamed propagate_maps to perf_evlist__propagate_maps - renamed --per-task option to --per-thread - changed 'task-pid' header output to 'comm-pid' v2 changes: - renamed xyarray__zero to xyarray__reset - using atomic_t for cpu_map/thread_map refcnt - moving all stat functions into stat object - using init_stats to initialize 'struct stats*' - change TASK-$pid output into $comm-$pid - updated doc with --per-task option thanks, jirka --- Jiri Olsa (22): perf thread_map: Introduce thread_map__reset function perf tools: Add comm string into struct thread_map perf tests: Add thread_map object tests perf stat: Introduce perf_counts function perf stat: Use xyarray for cpu evsel counts perf stat: Make stats work over the thread dimension perf stat: Rename struct perf_counts::cpu member to values perf stat: Introduce perf_evlist__reset_stats perf stat: Move perf_evsel__(alloc|free|reset)_stat_priv into stat object perf stat: Move perf_evsel__(alloc|free)_prev_raw_counts into stat object perf stat: Move perf_evlist__(alloc|free|reset)_stats into stat object perf stat: Introduce perf_evsel__alloc_stats function perf stat: Introduce perf_evsel__read function perf stat: Introduce read_counters function perf stat: Separate counters reading and processing perf stat: Move zero_per_pkg into counter process code perf stat: Move perf_stat initialization counter process code perf stat: Remove perf_evsel__read_cb function perf stat: Rename print_interval to process_interval perf stat: Using init_stats instead of memset perf stat: Introduce print_counters function perf stat: Introduce --per-thread option tools/perf/Documentation/perf-stat.txt | 4 + tools/perf/builtin-stat.c | 402 +++++++++++++++++++++++++++++++------------------------------ tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 + tools/perf/tests/openat-syscall-all-cpus.c | 6 +- tools/perf/tests/openat-syscall.c | 4 +- tools/perf/tests/tests.h | 1 + tools/perf/tests/thread-map.c | 38 ++++++ tools/perf/util/evlist.h | 1 - tools/perf/util/evsel.c | 24 ++-- tools/perf/util/evsel.h | 28 +---- tools/perf/util/python-ext-sources | 1 + tools/perf/util/stat.c | 132 ++++++++++++++++++-- tools/perf/util/stat.h | 47 +++++++- tools/perf/util/thread_map.c | 76 +++++++++++- tools/perf/util/thread_map.h | 8 ++ 16 files changed, 523 insertions(+), 254 deletions(-) create mode 100644 tools/perf/tests/thread-map.c