Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754423AbcC1K64 (ORCPT ); Mon, 28 Mar 2016 06:58:56 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:37758 "EHLO e33.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753282AbcC1K6x (ORCPT ); Mon, 28 Mar 2016 06:58:53 -0400 X-IBM-Helo: d03dlp02.boulder.ibm.com X-IBM-MailFrom: ravi.bangoria@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Subject: Re: [RFC 1/4] perf kvm: Enable 'record' on powerpc To: Arnaldo Carvalho de Melo References: <1456304865-15131-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> <1456304865-15131-2-git-send-email-ravi.bangoria@linux.vnet.ibm.com> <20160322191211.GD25862@kernel.org> <20160323021921.GE25862@kernel.org> <20160324211528.GD32162@kernel.org> Cc: linux-kernel@vger.kernel.org, hemant@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com From: Ravi Bangoria Message-ID: <56F90E65.4030809@linux.vnet.ibm.com> Date: Mon, 28 Mar 2016 16:28:45 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160324211528.GD32162@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16032810-0009-0000-0000-000019AB57F5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3392 Lines: 78 Thanks Arnaldo for putting the effort. I've tested this patch on powerpc and it looks fine to me. Please find my below comments. On Friday 25 March 2016 02:45 AM, Arnaldo Carvalho de Melo wrote: > Em Tue, Mar 22, 2016 at 11:19:21PM -0300, Arnaldo Carvalho de Melo escreveu: >> Em Tue, Mar 22, 2016 at 04:12:11PM -0300, Arnaldo Carvalho de Melo escreveu: >>> Em Wed, Feb 24, 2016 at 02:37:42PM +0530, Ravi Bangoria escreveu: >>>> 'perf kvm record' is not available on powerpc because 'perf' relies on >>>> the 'cycles' event (a PMU event) to profile the guest. However, for >>>> powerpc, this can't be used from the host because the PMUs are controlled >>>> by the guest rather than the host. >>>> >>>> There exists a tracepoint 'kvm_hv:kvm_guest_exit' in powerpc which is >>>> hit whenever any of the threads exit the guest context. The guest >>>> instruction pointer dumped along with this tracepoint data in the field >>>> 'pc', can be used as guest instruction pointer. >>>> >>>> This patch changes default event as kvm_hv:kvm_guest_exit for recording >>>> guest data in host on powerpc. As we are using host event to record guest >>>> data, this approach will enable only --guest option of 'perf kvm'. Still >>>> --host --guest together won't work. >>> It should, i.e. --host --guest should translate to: >>> >>> -e cycles:H,kvm_hv:kvm_guest_exit >>> >>> I.e. both collect cycles only in the host, and also the tracepoint that >>> will allow us to get the guest approximation for the unavailable cycles >>> event, no? >>> >>> I'm putting the infrastructure work needed for this the perf/cpumode >>> branch. More work will be put there soon. >> So I took a different path and made perf_evsel__parse_sample set a new >> perf_sample.cpumode field, this way we'll end up having just to set a >> per-evsel ->post_parse_sample() callback for the event that replaces >> "cycles" for PPC guests where we'll just set data->ip and data->cpumode, >> the rest of the code remains unchanged. >> >> The changes I made looks useful in itself, as, IIRC more code was >> removed than added. >> >> I'll continue tomorrow and will test with the kvm:kvm_exit on x86_64 for >> testing, that has: > Ok, so the infrastructure got merged already and from there the next > steps are in running with: > > perf kvm --guest record -a -e cycles:H,kvm:kvm_exit > > And then, with the patch below applied, try: > > perf kvm --guestkallsyms kallsyms.guest --guestmodules modules.guest report -i perf.data.guest --munge-ppc-guest-sample kvm:kvm_exit The initial proposal was to change the default event as "kvm_guest_exit" for kvm recording/reporting on ppc. If I understand it correctly, your patch creates a handler for reporting kvm events based on "munge_ppc_guest_event" and the required tracepoint i.e., we need to mention the required tracepoint event name for recording and reporting. There might be a little bit of an issue here. For scripts which depend on generic perf kvm record/report, we need to change those appropriately to prevent those from failing on powerpc. Otherwise, (just a thought) can we create some kind of an alias to map the ppc specific perf kvm commands with the generic perf kvm. For e.g : perf kvm record -e "kvm_hv:kvm_guest_exit" mapped to perf kvm record & perf kvm report --munge-ppc-guest-sample kvm_hv:kvm_guest_exit mapped to perf kvm report. Regards, Ravi