Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932672AbbGUMjt (ORCPT ); Tue, 21 Jul 2015 08:39:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39508 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754756AbbGUMcz (ORCPT ); Tue, 21 Jul 2015 08:32:55 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra Subject: [PATCH 24/47] perf tools: Add stat round event Date: Tue, 21 Jul 2015 14:31:44 +0200 Message-Id: <1437481927-29538-25-git-send-email-jolsa@kernel.org> In-Reply-To: <1437481927-29538-1-git-send-email-jolsa@kernel.org> References: <1437481927-29538-1-git-send-email-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4404 Lines: 138 Adding stat round event to be stored afer each stat interval round, so report tools (report/script) get notified and process interval data. Link: http://lkml.kernel.org/n/tip-nqhzuxrv12ulccx11k7x86mr@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 7 +++++++ tools/perf/util/session.c | 20 ++++++++++++++++++++ tools/perf/util/tool.h | 3 ++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 02954385ccdc..658cb81eb27f 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -40,6 +40,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_CPU_MAP] = "CPU_MAP", [PERF_RECORD_STAT_CONFIG] = "STAT_CONFIG", [PERF_RECORD_STAT] = "STAT", + [PERF_RECORD_STAT_ROUND] = "STAT_ROUND", }; const char *perf_event__name(unsigned int id) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 375b1de34cc6..a4d3b3098613 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -229,6 +229,7 @@ enum perf_user_event_type { /* above any possible kernel type */ PERF_RECORD_CPU_MAP = 74, PERF_RECORD_STAT_CONFIG = 75, PERF_RECORD_STAT = 76, + PERF_RECORD_STAT_ROUND = 77, PERF_RECORD_HEADER_MAX }; @@ -404,6 +405,11 @@ struct stat_event { }; }; +struct stat_round_event { + struct perf_event_header header; + u64 time; +}; + union perf_event { struct perf_event_header header; struct mmap_event mmap; @@ -429,6 +435,7 @@ union perf_event { struct cpu_map_event cpu_map; struct stat_config_event stat_config; struct stat_event stat; + struct stat_round_event stat_round; }; void perf_event__print_totals(void); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index e0ad3e691e6a..4b957c02fffb 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -347,6 +347,15 @@ static int process_stat_stub(struct perf_tool *tool __maybe_unused, return 0; } +static int process_stat_round_stub(struct perf_tool *tool __maybe_unused, + union perf_event *event __maybe_unused, + struct perf_session *perf_session + __maybe_unused) +{ + dump_printf(": unhandled!\n"); + return 0; +} + void perf_tool__fill_defaults(struct perf_tool *tool) { if (tool->sample == NULL) @@ -403,6 +412,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->stat_config = process_event_stat_config_stub; if (tool->stat == NULL) tool->stat = process_stat_stub; + if (tool->stat_round == NULL) + tool->stat_round = process_stat_round_stub; } static void swap_sample_id_all(union perf_event *event, void *data) @@ -703,6 +714,12 @@ static void perf_event__stat_swap(union perf_event *event, event->stat.run = bswap_64(event->stat.run); } +static void perf_event__stat_round_swap(union perf_event *event, + bool sample_id_all __maybe_unused) +{ + event->stat_round.time = bswap_64(event->stat_round.time); +} + typedef void (*perf_event__swap_op)(union perf_event *event, bool sample_id_all); @@ -732,6 +749,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_CPU_MAP] = perf_event__cpu_map_swap, [PERF_RECORD_STAT_CONFIG] = perf_event__stat_config_swap, [PERF_RECORD_STAT] = perf_event__stat_swap, + [PERF_RECORD_STAT_ROUND] = perf_event__stat_round_swap, [PERF_RECORD_HEADER_MAX] = NULL, }; @@ -1262,6 +1280,8 @@ static s64 perf_session__process_user_event(struct perf_session *session, return tool->stat_config(tool, event, session); case PERF_RECORD_STAT: return tool->stat(tool, event, session); + case PERF_RECORD_STAT_ROUND: + return tool->stat_round(tool, event, session); default: return -EINVAL; } diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index 49224232995b..fca37b3460cb 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -58,7 +58,8 @@ struct perf_tool { thread_map, cpu_map, stat_config, - stat; + stat, + stat_round; event_op3 auxtrace; bool ordered_events; bool ordering_requires_timestamps; -- 2.4.3 -- 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/