Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754295AbbGaXmo (ORCPT ); Fri, 31 Jul 2015 19:42:44 -0400 Received: from mail-by2on0106.outbound.protection.outlook.com ([207.46.100.106]:23104 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751972AbbGaXml (ORCPT ); Fri, 31 Jul 2015 19:42:41 -0400 Authentication-Results: linux.vnet.ibm.com; dkim=none (message not signed) header.d=none; Message-ID: <1438386140.19345.70.camel@freescale.com> Subject: Re: [PATCH v5 1/2] perf,kvm/ppc: Add kvm_perf.h for powerpc From: Scott Wood To: Hemant Kumar CC: , , , , , , , , , , , , Mihai Caraman Date: Fri, 31 Jul 2015 18:42:20 -0500 In-Reply-To: <55BB37FE.3040002@linux.vnet.ibm.com> References: <1437061722-15438-1-git-send-email-hemant@linux.vnet.ibm.com> <1437077417.2993.108.camel@freescale.com> <55B8ACD9.8090404@linux.vnet.ibm.com> <1438208530.2993.350.camel@freescale.com> <55BB37FE.3040002@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.0-fta1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Originating-IP: [2601:448:8100:f9f:12bf:48ff:fe84:c9a0] X-ClientProxiedBy: BY2PR21CA0016.namprd21.prod.outlook.com (25.162.74.154) To BLUPR03MB1473.namprd03.prod.outlook.com (25.163.81.158) X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB1473;2:oxyv4XC0QRxwj9V7YnNWYnPJu4U5GOJO8q4ZOYHUI5EM/nBBzM8/mPz5ouBzEvOmmw2KRoyxQnRbC4R46ikM3cTcw6gnwvBLqIAIldNt0bUfVfgyLLOAQklOizI2xLsO0M1fyjirIAhIYFoNuUGbN90F9TzJjisBDnM34AEWuws=;3:O0h058wEVOviKBwvzkJvDUOydFKWalzxM2aOggRFkCi/V2m6EEly15e9nF8ESubE7zqZCub148w+q+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+K7JCyYdW+fNJiXO4w66t+khic2/SKf10Jfi8iVoZ0KngFoDTJ+2fAeIMBgu9B+CmIf/6jlgSA+vZElaoKFp9CwQo+qkdmCMs+vf/gVPNEvzKkmuf6YR4vEwriKQDpECOEM+E4x2z5p+Pkb+XvQiMYJPn40xDymcJHf3U1Z3cNGkqZJuOnGY15hc= 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:BLUPR03MB1473;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1473; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(76104003)(479174004)(377424004)(377454003)(107886002)(110136002)(189998001)(36756003)(103116003)(62966003)(5001960100002)(50466002)(50226001)(77096005)(92566002)(77156002)(5820100001)(122386002)(93886004)(86362001)(2950100001)(50986999)(76176999)(47776003)(46102003)(33646002)(19580405001)(23676002)(42186005)(19580395003)(40100003)(142933001)(3826002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB1473;H:[IPv6:2601:448:8100:f9f:12bf:48ff:fe84:c9a0];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTFVQUjAzTUIxNDczOzIzOkFRWFNPdDhMaXB0RzRaZW9NVUNSWXZaaUZF?= =?utf-8?B?cGwyRVo1ejA4R1d5emUvM3dpdjI2WU1VeEUwTVNpSWQ0L1BTVUdjcHM0RXlR?= =?utf-8?B?N0N3amFUOGVsVkdkcUtVKzNnZlFjSnR1QldoS2NVTllSejQ5RVVTUC9wdTht?= =?utf-8?B?Y1BkSDdxWjZ3M0RpV1RyUTRGMmdMdVFIRENMOFZVRlBYeW1wU2FmK1EvSnp5?= =?utf-8?B?R2Z6SzBZNk9sSkw5bmxHL3UvWmZYbWp4b0wxd0dxazFrTytQa0RJ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UnFEdFUzRER2TFo0dDNG?= =?utf-8?B?V3FmRW9PQTZHeitMb1NyQklGVkE0VTR6TlhSVHZ0SmZsbk5GczBBTkNlY0xP?= =?utf-8?B?U1ovNWNjaHd6VnVxK2tyTFpNdnE1cnJKNHVRWnVtQzlrU3lOOGxsdlVzUVBv?= =?utf-8?B?cWhZK2t1MTBESGc9PQ==?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB1473;5:V/2seSiYHaR8af1NIritX8H8oLCMBy3tpOU+w5/J2YZe3vjuSjSUVgSSb7v2k2xUKT3vy9mIMBTBDDulQiplXZRK7oMW6J9pIoFM7FZjKRCP/Pq7OI1V/KI5OTvq97GCUA2vEzgwY28+EnTqgX+ewQ==;24:i9gl2lggCka9mhaMhGY+gTIh1u3N/7R59UqVxoj8pg0ceqPTj2TOYpulspnbAS/K8XFGHobBA0yEqHXxuj+g33BySyrFMYlen2Lcsw1YbdM=;20:4MDRhqae2o8ZihKNp9/fk1a037z18BhHEpmt3oDAidmWzHlL7bqOfctczV+u64B8tWcEnZvdrNwe47orgYh2gw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2015 23:42:34.4531 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB1473 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7071 Lines: 175 [Added KVM lists and a couple relevant people] On Fri, 2015-07-31 at 14:25 +0530, Hemant Kumar wrote: > On 07/30/2015 03:52 AM, Scott Wood wrote: > > On Wed, 2015-07-29 at 16:07 +0530, Hemant Kumar wrote: > > > Hi Scott, > > > > > > On 07/17/2015 01:40 AM, Scott Wood wrote: > > > > On Thu, 2015-07-16 at 21:18 +0530, Hemant Kumar wrote: > > > > > To analyze the exit events with perf, we need kvm_perf.h to be > > > > > added in > > > > > the arch/powerpc directory, where the kvm tracepoints needed to > > > > > trace > > > > > the KVM exit events are defined. > > > > > > > > > > This patch adds "kvm_perf_book3s.h" to indicate that the > > > > > tracepoints are > > > > > book3s specific. Generic "kvm_perf.h" then can just include > > > > > "kvm_perf_book3s.h". > > > > > > > > > > Signed-off-by: Hemant Kumar > > > > > --- > > > > > Changes: > > > > > - Not exporting the exit reasons compared to previous patchset > > > > > (suggested > > > > > by Paul) > > > > > > > > > > arch/powerpc/include/uapi/asm/kvm_perf.h | 6 ++++++ > > > > > arch/powerpc/include/uapi/asm/kvm_perf_book3s.h | 14 > > > > > ++++++++++++++ > > > > > 2 files changed, 20 insertions(+) > > > > > create mode 100644 arch/powerpc/include/uapi/asm/kvm_perf.h > > > > > create mode 100644 > > > > > arch/powerpc/include/uapi/asm/kvm_perf_book3s.h > > > > > > > > > > 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..5ed2ff3 > > > > > --- /dev/null > > > > > +++ b/arch/powerpc/include/uapi/asm/kvm_perf.h > > > > > @@ -0,0 +1,6 @@ > > > > > +#ifndef _ASM_POWERPC_KVM_PERF_H > > > > > +#define _ASM_POWERPC_KVM_PERF_H > > > > > + > > > > > +#include > > > > > + > > > > > +#endif > > > > > diff --git a/arch/powerpc/include/uapi/asm/kvm_perf_book3s.h > > > > > b/arch/powerpc/include/uapi/asm/kvm_perf_book3s.h > > > > > new file mode 100644 > > > > > index 0000000..8c8d8c2 > > > > > --- /dev/null > > > > > +++ b/arch/powerpc/include/uapi/asm/kvm_perf_book3s.h > > > > > @@ -0,0 +1,14 @@ > > > > > +#ifndef _ASM_POWERPC_KVM_PERF_BOOK3S_H > > > > > +#define _ASM_POWERPC_KVM_PERF_BOOK3S_H > > > > > + > > > > > +#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_BOOK3S_H */ > > > > Again, why is book3s stuff being presented via uapi as generic > > > > with generic symbol names? > > > > > > > > -Scott > > > Ok. > > > > > > We can change the KVM_ENTRY_TRACE macro to something like > > > KVM_BOOK3S_ENTRY_TRACE and likewise for KVM_EXIT_TRACE > > > and KVM_EXIT_REASON > > What about DECODE_STR_LEN and VCPU_ID? > > DECODE_STR_LEN can be common, we can give a big enough size to it, if > we need to. > And, VCPU_ID depends on the field in the tracepoint payload data which is > specific to that tracepoint. This field is used to maintain the per vcpu > record > and this field gives us the vcpu id. So, yeah, I guess, since, I can't > find any > such field as "vcpu_id" in the kvm_exit tracepoint for book3e, we have to > make this specific to book3s. Or maybe we could add kvm_guest_enter/kvm_guest_leave, with vcpu_id, to book3e... though the kvm-hv would be a problem for book3s-pr, if anyone cares about this feature there. I'm not sure why the strings are present both in the UAPI header, as well as in kvm_events_tp[] in kvm-stat.c. > > Where is this API documented? > > > > > and then, to resolve the issue of generic > > > macro names in the userspace side, we can handle it using __weak > > > modifier. > > Does userspace get built differently for book3s versus book3e? For now > > it'd > > > > be fine for userspace to check for book3s and not use the feature if it's > > > > book3e. If and when book3e gains this feature, then userspace can be > > changed. > > Well, I couldn't find any way to build user space differently for book3s and > book3e. > > How about keeping this as it is after modifying the tracepoint macro names > to book3s specific in the uapi? And as and when booke decides to implement > this feature, a runtime check for event availability can be added then, > IMHO. > > What do you think? What does userspace use, at runtime, to determine if this feature is present and whether the book3s symbols should be used? Deferring the implementation of book3e support is fine, but from a uapi perspective it should be discoverable at runtime whether the feature exposed by asm/kvm_perf_book3s.h is available. Otherwise, if it is implemented (or even if it isn't), you have the potential for user confusion if an older perf tool is used. This sort of discovery is done all the time in the KVM APIs themselves. FWIW, on x86 cpu_isa_init() uses cpuid to select an exit table. Using PVR seems like it would be a bit cumbersome though compared to the kernel directly exporting which subarch it is (and it wouldn't help with HV versus PR). > > > What would you suggest? > > Another option would be to explain this interface so that we can figure > > out > > if book3e would even want different values for these, and if not, move it > > to > > asm/kvm.h. > > Here is my understanding of the interface. We need to add handlers for > "is_begin_event", "is_end_event" and "decode_key" for any event type > (for which we want to collect the stats). > The first two handlers check when the respective events started/ended > and hence, the time difference stats, event start/end time etc. is > calculated > in these functions. To check if the event has started or ended, they make > use of the macros KVM_ENTRY_TRACE and KVM_EXIT_TRACE. These > macros are exported from the kernel as uapi. Atleast, that's how x86 and > s390 do it. It really seems like something that would have been better handled via some sort of dynamic discovery rather than uapi header file constants. > "decode_key" hanlder is used to find out the reason for > that event (in case of book3s, its "trap" field of kvm_hv:kvm_guest_exit > payload) in semantic terms. It maps an info of interest found in that > particular tracepoint's data to a name(string) through a > table kvm_trace_symbol_exit. All the events are then classified into groups > based on this info. So it tells you what field to use, but not how to decode that field. What's the point? If userspace has inherent knowledge that 0xe20 means "H_INST_STORAGE" why can't it have inherent knowledge that the field to use is "trap"? -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/