Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752287AbbEKWIz (ORCPT ); Mon, 11 May 2015 18:08:55 -0400 Received: from mail-by2on0128.outbound.protection.outlook.com ([207.46.100.128]:29630 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751350AbbEKWIv (ORCPT ); Mon, 11 May 2015 18:08:51 -0400 Authentication-Results: linux.vnet.ibm.com; dkim=none (message not signed) header.d=none; Message-ID: <1431382120.16357.471.camel@freescale.com> Subject: Re: [PATCH v3 1/2] perf/kvm: Port perf kvm to powerpc From: Scott Wood To: Hemant Kumar CC: , , , , , , , , , , , Date: Mon, 11 May 2015 17:08:40 -0500 In-Reply-To: <1431047266-6206-1-git-send-email-hemant@linux.vnet.ibm.com> References: <1431047266-6206-1-git-send-email-hemant@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.10-0ubuntu1~14.10.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [2601:2:5800:3f7:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BN3PR0401CA0025.namprd04.prod.outlook.com (25.162.159.163) To BN3PR03MB1480.namprd03.prod.outlook.com (25.163.35.143) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1480; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN3PR03MB1480;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1480; X-Forefront-PRVS: 05739BA1B5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(377424004)(24454002)(5820100001)(122386002)(103116003)(40100003)(92566002)(47776003)(2950100001)(62966003)(77156002)(19580405001)(50466002)(23676002)(36756003)(15975445007)(77096005)(87976001)(86362001)(46102003)(50986999)(110136002)(189998001)(42186005)(50226001)(33646002)(19580395003)(76176999)(5001960100002);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR03MB1480;H:[IPv6:2601:2:5800:3f7:12bf:48ff:fe84:c9a0];FPR:;SPF:None;MLV:sfv;LANG:en; X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2015 22:08:47.6658 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1480 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4143 Lines: 114 On Fri, 2015-05-08 at 06:37 +0530, Hemant Kumar wrote: > From: Srikar Dronamraju > > perf kvm can be used to analyze guest exit reasons. This support already > exists in x86. Hence, porting it to powerpc. > > - To trace KVM events : > perf kvm stat record > If many guests are running, we can track for a specific guest by using > --pid as in : perf kvm stat record --pid > > - To see the results : > perf kvm stat report > > The result shows the number of exits (from the guest context to > host/hypervisor context) grouped by their respective exit reasons with > their frequency. > > This patch makes use of the guest exit reasons available in > "trace_book3s.h". It records on two already available tracepoints : > "kvm_hv:kvm_guest_exit" and "kvm_hv:kvm_guest_enter". > > Note : This patch has a dependency on the patch "kvm/powerpc: Export > kvm exit reasons" which exports the KVM exit reasons through the uapi. > > Here is a sample o/p: > # pgrep qemu > 19378 > 60515 > > 2 Guests are running on the host. > > # perf kvm stat record -a > ^C[ perf record: Woken up 1 times to write data ] > [ perf record: Captured and wrote 4.153 MB perf.data.guest (39624 samples) ] > > # perf kvm stat report -p 60515 > Analyze events for pid(s) 60515, all VCPUs: > > VM-EXIT Samples Samples% Time% Min Time Max Time Avg time > > H_DATA_STORAGE 5006 35.30% 0.13% 1.94us 49.46us 12.37us ( +- 0.52% ) > HV_DECREMENTER 4457 31.43% 0.02% 0.72us 16.14us 1.91us ( +- 0.96% ) > SYSCALL 2690 18.97% 0.10% 2.84us 528.24us 18.29us ( +- 3.75% ) > RETURN_TO_HOST 1789 12.61% 99.76% 1.58us 672791.91us 27470.23us ( +- 3.00% ) > EXTERNAL 240 1.69% 0.00% 0.69us 10.67us 1.33us ( +- 5.34% ) > > Total Samples:14182, Total events handled time:49264158.30us. > > Signed-off-by: Srikar Dronamraju > Signed-off-by: Hemant Kumar > --- > Patch has a dependency on : https://patchwork.ozlabs.org/patch/469839/ > which exports the exit reasons to perf through uapi. > > Changes: > - Original series split into two patchsets now : perf and powerpc > side changes. > > arch/powerpc/include/uapi/asm/kvm_perf.h | 15 +++++++++++++++ > tools/perf/arch/powerpc/Makefile | 1 + > tools/perf/arch/powerpc/util/Build | 1 + > tools/perf/arch/powerpc/util/kvm-stat.c | 33 ++++++++++++++++++++++++++++++++ > 4 files changed, 50 insertions(+) > create mode 100644 arch/powerpc/include/uapi/asm/kvm_perf.h > create mode 100644 tools/perf/arch/powerpc/util/kvm-stat.c > > diff --git a/arch/powerpc/include/uapi/asm/kvm_perf.h b/arch/powerpc/include/uapi/asm/kvm_perf.h > new file mode 100644 > index 0000000..30fa670 > --- /dev/null > +++ b/arch/powerpc/include/uapi/asm/kvm_perf.h > @@ -0,0 +1,15 @@ > +#ifndef _ASM_POWERPC_KVM_PERF_H > +#define _ASM_POWERPC_KVM_PERF_H > + > +#include > +#include > + > +#define DECODE_STR_LEN 20 > + > +#define VCPU_ID "vcpu_id" > + > +#define KVM_ENTRY_TRACE "kvm_hv:kvm_guest_enter" > +#define KVM_EXIT_TRACE "kvm_hv:kvm_guest_exit" > +#define KVM_EXIT_REASON "trap" > + > +#endif /* _ASM_POWERPC_KVM_PERF_H */ Please make sure that anything book3s-specific is named that way. And shouldn't this be part of the arch/powerpc-side patchset? > diff --git a/tools/perf/arch/powerpc/Makefile b/tools/perf/arch/powerpc/Makefile > index 7fbca17..21322e0 100644 > --- a/tools/perf/arch/powerpc/Makefile > +++ b/tools/perf/arch/powerpc/Makefile > @@ -1,3 +1,4 @@ > ifndef NO_DWARF > PERF_HAVE_DWARF_REGS := 1 > endif > +HAVE_KVM_STAT_SUPPORT := 1 Does this stuff fail gracefully if used on a PPC target that doesn't support this? -Scott -- 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/