Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934831AbcKWXl3 (ORCPT ); Wed, 23 Nov 2016 18:41:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49696 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752458AbcKWXl2 (ORCPT ); Wed, 23 Nov 2016 18:41:28 -0500 Date: Thu, 24 Nov 2016 00:41:22 +0100 From: Jiri Olsa To: kan.liang@intel.com Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, tglx@linutronix.de, namhyung@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, wangnan0@huawei.com, mark.rutland@arm.com, andi@firstfloor.org Subject: Re: [PATCH 01/14] perf/x86: Introduce PERF_RECORD_OVERHEAD Message-ID: <20161123234122.GA19783@krava> References: <1479894292-16277-1-git-send-email-kan.liang@intel.com> <1479894292-16277-2-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479894292-16277-2-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 23 Nov 2016 23:41:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2549 Lines: 75 On Wed, Nov 23, 2016 at 04:44:39AM -0500, kan.liang@intel.com wrote: > From: Kan Liang > > A new perf record is introduced to export perf overhead information to > userspace. So we can measure the overhead of sampling directly. > > To output the overhead information, it takes advantage of the existing > event log mechanism. But the overhead information is the system > overhead, not per-event overhead. > > Signed-off-by: Kan Liang > --- > include/linux/perf_event.h | 4 ++++ > include/uapi/linux/perf_event.h | 29 +++++++++++++++++++++++++++ > kernel/events/core.c | 43 +++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 76 insertions(+) > > diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h > index 4741ecd..3a530a7 100644 > --- a/include/linux/perf_event.h > +++ b/include/linux/perf_event.h > @@ -998,6 +998,10 @@ perf_event__output_id_sample(struct perf_event *event, > extern void > perf_log_lost_samples(struct perf_event *event, u64 lost); > > +extern void > +perf_log_overhead(struct perf_event *event, u32 type, > + struct perf_overhead_entry *entry); > + > static inline bool is_sampling_event(struct perf_event *event) > { > return event->attr.sample_period != 0; > diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h > index c66a485..ae571be 100644 > --- a/include/uapi/linux/perf_event.h > +++ b/include/uapi/linux/perf_event.h > @@ -862,6 +862,17 @@ enum perf_event_type { > */ > PERF_RECORD_SWITCH_CPU_WIDE = 15, > > + /* > + * Records perf overhead > + * struct { > + * struct perf_event_header header; > + * u32 type; > + * struct perf_overhead_entry entry; > + * struct sample_id sample_id; > + * }; > + */ > + PERF_RECORD_OVERHEAD = 16, > + > PERF_RECORD_MAX, /* non-ABI */ > }; I think we should make this optional/configurable like the rest of the aux events, like below.. jirka --- diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h index 5e7c52278ef0..853a919bd9ae 100644 --- a/include/uapi/linux/perf_event.h +++ b/include/uapi/linux/perf_event.h @@ -344,7 +344,8 @@ struct perf_event_attr { use_clockid : 1, /* use @clockid for time fields */ context_switch : 1, /* context switch data */ write_backward : 1, /* Write ring buffer from end to beginning */ - __reserved_1 : 36; + overhead : 1, + __reserved_1 : 35; union { __u32 wakeup_events; /* wakeup every n events */