Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753964AbbHRQni (ORCPT ); Tue, 18 Aug 2015 12:43:38 -0400 Received: from mga11.intel.com ([192.55.52.93]:48477 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753712AbbHRQlX (ORCPT ); Tue, 18 Aug 2015 12:41:23 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,702,1432623600"; d="scan'208";a="786447415" From: kan.liang@intel.com To: acme@kernel.org Cc: a.p.zijlstra@chello.nl, mingo@redhat.com, jolsa@kernel.org, namhyung@kernel.org, ak@linux.intel.com, eranian@google.com, linux-kernel@vger.kernel.org, Kan Liang Subject: [PATCH RFC 06/10] perf,tools: New RECORD type PERF_RECORD_STAT_READ Date: Tue, 18 Aug 2015 05:25:42 -0400 Message-Id: <1439889946-28986-7-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1439889946-28986-1-git-send-email-kan.liang@intel.com> References: <1439889946-28986-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4396 Lines: 127 From: Kan Liang Introduce a new user RECORD type PERF_RECORD_STAT_READ to store the stat event read result. Signed-off-by: Kan Liang --- tools/perf/util/event.c | 1 + tools/perf/util/event.h | 10 ++++++++++ tools/perf/util/session.c | 15 +++++++++++++++ tools/perf/util/tool.h | 1 + 4 files changed, 27 insertions(+) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 7ff6127..601f4be 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -37,6 +37,7 @@ static const char *perf_event__names[] = { [PERF_RECORD_AUXTRACE_INFO] = "AUXTRACE_INFO", [PERF_RECORD_AUXTRACE] = "AUXTRACE", [PERF_RECORD_AUXTRACE_ERROR] = "AUXTRACE_ERROR", + [PERF_RECORD_STAT_READ] = "STAT_READ", }; const char *perf_event__name(unsigned int id) diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index f729df5..f6932cf 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -226,6 +226,7 @@ enum perf_user_event_type { /* above any possible kernel type */ PERF_RECORD_AUXTRACE_INFO = 70, PERF_RECORD_AUXTRACE = 71, PERF_RECORD_AUXTRACE_ERROR = 72, + PERF_RECORD_STAT_READ = 73, PERF_RECORD_HEADER_MAX }; @@ -355,6 +356,14 @@ struct context_switch_event { u32 next_prev_tid; }; +struct stat_read_event { + struct perf_event_header header; + u64 value; /* counter value delta */ + u32 cpu; + u32 pos_id; /* event position in evlist */ + u64 time; /* time stamp */ +}; + union perf_event { struct perf_event_header header; struct mmap_event mmap; @@ -377,6 +386,7 @@ union perf_event { struct aux_event aux; struct itrace_start_event itrace_start; struct context_switch_event context_switch; + struct stat_read_event stat_read; }; void perf_event__print_totals(void); diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index 18722e7..1547970 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -337,6 +337,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool) tool->context_switch = perf_event__process_switch; if (tool->read == NULL) tool->read = process_event_sample_stub; + if (tool->stat_read == NULL) + tool->stat_read = process_build_id_stub; if (tool->throttle == NULL) tool->throttle = process_event_stub; if (tool->unthrottle == NULL) @@ -440,6 +442,16 @@ static void perf_event__task_swap(union perf_event *event, bool sample_id_all) swap_sample_id_all(event, &event->fork + 1); } +static void perf_event__stat_read_swap(union perf_event *event, + bool sample_id_all __maybe_unused) +{ + + event->stat_read.value = bswap_64(event->stat_read.value); + event->stat_read.cpu = bswap_32(event->stat_read.cpu); + event->stat_read.pos_id = bswap_32(event->stat_read.pos_id); + event->stat_read.time = bswap_64(event->stat_read.time); +} + static void perf_event__read_swap(union perf_event *event, bool sample_id_all) { event->read.pid = bswap_32(event->read.pid); @@ -642,6 +654,7 @@ static perf_event__swap_op perf_event__swap_ops[] = { [PERF_RECORD_EXIT] = perf_event__task_swap, [PERF_RECORD_LOST] = perf_event__all64_swap, [PERF_RECORD_READ] = perf_event__read_swap, + [PERF_RECORD_STAT_READ] = perf_event__stat_read_swap, [PERF_RECORD_THROTTLE] = perf_event__throttle_swap, [PERF_RECORD_UNTHROTTLE] = perf_event__throttle_swap, [PERF_RECORD_SAMPLE] = perf_event__all64_swap, @@ -1191,6 +1204,8 @@ static s64 perf_session__process_user_event(struct perf_session *session, case PERF_RECORD_AUXTRACE_ERROR: perf_session__auxtrace_error_inc(session, event); return tool->auxtrace_error(tool, event, session); + case PERF_RECORD_STAT_READ: + return tool->stat_read(tool, event, session); default: return -EINVAL; } diff --git a/tools/perf/util/tool.h b/tools/perf/util/tool.h index cab8cc2..3a002a2 100644 --- a/tools/perf/util/tool.h +++ b/tools/perf/util/tool.h @@ -57,6 +57,7 @@ struct perf_tool { auxtrace_info, auxtrace_error; event_op3 auxtrace; + event_op2 stat_read; bool ordered_events; bool ordering_requires_timestamps; }; -- 1.8.3.1 -- 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/