Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965544AbcKXNpd convert rfc822-to-8bit (ORCPT ); Thu, 24 Nov 2016 08:45:33 -0500 Received: from mga14.intel.com ([192.55.52.115]:32690 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964853AbcKXNpb (ORCPT ); Thu, 24 Nov 2016 08:45:31 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,543,1473145200"; d="scan'208";a="35199546" From: "Liang, Kan" To: Jiri Olsa 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" , "Hunter, Adrian" , "wangnan0@huawei.com" , "mark.rutland@arm.com" , "andi@firstfloor.org" Subject: RE: [PATCH 01/14] perf/x86: Introduce PERF_RECORD_OVERHEAD Thread-Topic: [PATCH 01/14] perf/x86: Introduce PERF_RECORD_OVERHEAD Thread-Index: AQHSRbFTQeicWOUv7k2N38w8X4Va7aDmtLIAgAFwR5A= Date: Thu, 24 Nov 2016 13:45:28 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F07750CA2BC9@SHSMSX103.ccr.corp.intel.com> References: <1479894292-16277-1-git-send-email-kan.liang@intel.com> <1479894292-16277-2-git-send-email-kan.liang@intel.com> <20161123234122.GA19783@krava> In-Reply-To: <20161123234122.GA19783@krava> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjQ1N2U3YjEtNGFhNi00MjE5LTgzZjQtMGFjYzM1MDRmOTE1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6InNXSE5jNnQ3eE5uUkF6cFJCUEVzK0U5ZXYycU9OSExjaytBNlwvcVB4TlNJPSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2915 Lines: 95 > > 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.. > The overhead logging only happens when event is going to be disabled or the task is scheduling out. It should not be much and expensive. Peter, What do you think? Should we make it configurable? Thanks, Kan > 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 */