Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932612AbdHWSM7 convert rfc822-to-8bit (ORCPT ); Wed, 23 Aug 2017 14:12:59 -0400 Received: from mga02.intel.com ([134.134.136.20]:12344 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932111AbdHWSM5 (ORCPT ); Wed, 23 Aug 2017 14:12:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,417,1498546800"; d="scan'208";a="127493716" From: "Liang, Kan" To: Peter Zijlstra CC: "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "acme@kernel.org" , "jolsa@redhat.com" , "tglx@linutronix.de" , "eranian@google.com" , "ak@linux.intel.com" , "mpe@ellerman.id.au" , "maddy@linux.vnet.ibm.com" Subject: RE: [PATCH V6] perf: Add PERF_SAMPLE_PHYS_ADDR Thread-Topic: [PATCH V6] perf: Add PERF_SAMPLE_PHYS_ADDR Thread-Index: AQHTHBttUkw1UFhP0UiKy2wHyaEqH6KReyYAgAAB6oCAALfuUA== Date: Wed, 23 Aug 2017 18:01:25 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F0775378AA5B@SHSMSX103.ccr.corp.intel.com> References: <1503498166-3887-1-git-send-email-kan.liang@intel.com> <20170823143308.v27pgjagxjyd65ci@hirez.programming.kicks-ass.net> <20170823143959.m6k5xojly3q2tacv@hirez.programming.kicks-ass.net> In-Reply-To: <20170823143959.m6k5xojly3q2tacv@hirez.programming.kicks-ass.net> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNTEyNmUzMDYtZWJiYi00ODdlLTlkMDctZDZmYjJlYjFhNDkzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6ImpYd1pLZnFoSGZCUkVkdkZEZWFtWkd2RG44TXlIc20zMlFZcGZkVXVcL0VvPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action 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: 1607 Lines: 42 > On Wed, Aug 23, 2017 at 04:33:08PM +0200, Peter Zijlstra wrote: > > > @@ -6145,6 +6183,9 @@ void perf_prepare_sample(struct > > > perf_event_header *header, > > > > > > header->size += size; > > > } > > > + > > > + if (sample_type & PERF_SAMPLE_PHYS_ADDR) > > > + data->phys_addr = perf_virt_to_phys(data->addr); > > > > Only problem with this now is that it requires SAMPLE_ADDR to also be > > set in order to obtain data->addr. > > > > Either fix all to set data->attr for (SAMPLE_ADDR || SAMPLE_PHYS_ADDR) > > or mandate SAMPLE_ADDR when SAMPLE_PHYS_ADDR. > > I think the former suggestion is better, as it allows for smaller samples. For the latter, it's easy to be implemented, and already in the perf tool patch. But yes, it will bring extra overhead, if the user doesn't care about the virtual address. For the former, do you mean data->type or event->attr? I don't think we can set either of them. It will impact the perf_output_sample and perf_event__header_size. For x86, I think we can do something as below. But I'm not sure other architectures. diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index a322fed..9bf29dc 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -1175,7 +1175,7 @@ static void setup_pebs_sample_data(struct perf_event *event, else regs->flags &= ~PERF_EFLAGS_EXACT; - if ((sample_type & PERF_SAMPLE_ADDR) && + if ((sample_type & (PERF_SAMPLE_ADDR | PERF_SAMPLE_PHYS_ADDR) && x86_pmu.intel_cap.pebs_format >= 1) data->addr = pebs->dla; Thanks, Kan