Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3391057rwb; Tue, 8 Nov 2022 04:09:15 -0800 (PST) X-Google-Smtp-Source: AMsMyM54OiG7M2E93rJ26MBxgTZFhUnp2iIZqvfDr8H/j95ozkVhVcxNOVwzFT0XoJGKAb1ZGrYw X-Received: by 2002:a63:2125:0:b0:3c2:1015:988e with SMTP id h37-20020a632125000000b003c21015988emr47216732pgh.280.1667909355718; Tue, 08 Nov 2022 04:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667909355; cv=none; d=google.com; s=arc-20160816; b=L65MH48Zg0Th3gb6aSNnAwsZtqRJWUmlFsX3GR8MJqfTQR/b3dHy29S+VRN+SVLBub vv4EDXnvTuMIZjWkzhSDzpjIde8/WHBbDIPfragTyEJlmEHIMz5AjT6ccvNOHsK2Y888 dQOA42oD69sblX75aKaGS8VklClstt8jqL4IrA6ml8ruxOLqCY7njt9hw+c5PUZP3Wt4 ahCjEx8r2b/gwKHcNa0leWD8aBxDJp1ic5az3FxK4RBG/a1toClye+mD0Y+iNlf7Flra YKEEdrE1r2QdhtbHP7rNWbvmzOgS1FuWpIQnkKZ9gXZ5Rvlb6nIpSMhPQywEOdBOsI4D VkLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zfjKxjXUk1H8XvV8Joi7KrSFnmtiI6pTn2vr1B8zM+U=; b=yRZYegryRgO0yRnJCc87Wk9Jr+BBTYtohSBpxBa4hBHvaPP9f3HfSpWuVaVYtb4XJB WwyYgTg1lHPOad+3+Sw+ZxZ/waAlGHX4RWuMLSxPWoDk7GjvQ0AceuOs1vj7EXx49Hcl jPUWnLXqg3EuwEXmTm4Xmps9sI6ocOjp0kjILjEJ5yL65Jaf7cBm+gqu46L79mj1yXPg OPmBe/XIHBuaDOEhBmyR8qznF9Gc0uEaehs57COqacwMLWYtu7uiGc0CFTn2LonnBQwF lZ3+oFG+8+y3yHod7DUXDUt89/VMuS7LE1BJqZC40AEGRGg/B9z7xE7sbRDwV7SAH2Np 4P4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqUP7cf2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a65580e000000b004704ce49b48si12945342pgr.592.2022.11.08.04.09.03; Tue, 08 Nov 2022 04:09:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqUP7cf2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233657AbiKHLtn (ORCPT + 89 others); Tue, 8 Nov 2022 06:49:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233539AbiKHLtl (ORCPT ); Tue, 8 Nov 2022 06:49:41 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56C4B55BA for ; Tue, 8 Nov 2022 03:49:40 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id o13so3869148pgu.7 for ; Tue, 08 Nov 2022 03:49:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=zfjKxjXUk1H8XvV8Joi7KrSFnmtiI6pTn2vr1B8zM+U=; b=BqUP7cf2VkeswKuK/Q76Q9SSNQ0qyv9NkFINWVV3RFyhGZsqVCcy3ekIipKPj6x1dr yxP8MFlaJ+WBY6dD7XPy82RD/wEVHkhif73yRTZbtPsxNheJMXaorL1/QoRhiGKfqa0h F4kzKKXeBsvx0OsW7FF37umqgGDj1gbKN8VJ3tgVLpCWKL1BrtjMU1PKqgKbqnD48F1u 5QdpuLvi+dCbUSDWEyt2ILKxNCFpHhn83c4tt7xXUlkDSXn7TkoDOUTWGe24YHrWEv43 zb+6pT8tS97Oy0EjMX8AwxkKnWD5Byz0JDWE7jHavUhBkiwiJNGqxl5ULMVk3Z95uh6p 4mTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zfjKxjXUk1H8XvV8Joi7KrSFnmtiI6pTn2vr1B8zM+U=; b=q8MGHz4QrJfZyxTgF32YnLWRMLQlpiJx3eoqv+flZT7IqM0RfSK0x0vXBPEIjryL3h BzLE3gzh+6AQ2kMTFoJZESresbELrFgSgee+8eDZft/KhBeU69q6Jhop8nmkZu4w0dvO oSTEuCqOsBQ1dWMvz/NN91Cgj0sUkjcl4A/l9RYuB5Rn6MDMf7KCSrk8eQHSYWy9Ltwx wBrJguzhM5MYfU53CHnK8NoFkh7Gy4MV6vdgmDRBZksZk7s8cEGhre5NQDE5T2CGNIRk rT+nu4dgPc5aXZ8ULEv9HVAEFvaqEBpnfI79RLljjnoGMWC44NgYdAeLB0cnhOJiwat5 CWdw== X-Gm-Message-State: ANoB5pkvYeIS0YbvIl1R0EzUBB5BOPz8LTVDeNtx7jNcZ61vMP1YNmfW QQP1EDc1dR6TDVOucLuVeAocMfuYMKm900zUx18= X-Received: by 2002:a63:4d52:0:b0:470:71df:a461 with SMTP id n18-20020a634d52000000b0047071dfa461mr10043218pgl.209.1667908179704; Tue, 08 Nov 2022 03:49:39 -0800 (PST) Received: from leoy-huanghe ([218.82.143.143]) by smtp.gmail.com with ESMTPSA id d15-20020a17090a7bcf00b0020d51aefb82sm5933271pjl.19.2022.11.08.03.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 03:49:38 -0800 (PST) Date: Tue, 8 Nov 2022 19:49:31 +0800 From: Leo Yan To: Marc Zyngier Cc: James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon , Arnaldo Carvalho de Melo , John Garry , James Clark , Mike Leach , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH v1 3/3] perf arm64: Support virtual CPU ID for kvm-stat Message-ID: References: <20221105072311.8214-1-leo.yan@linaro.org> <20221105072311.8214-4-leo.yan@linaro.org> <868rkpr0mv.wl-maz@kernel.org> <86y1smpyec.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <86y1smpyec.wl-maz@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 07, 2022 at 03:39:07PM +0000, Marc Zyngier wrote: [...] > > > Please educate me: how useful is it to filter on a vcpu number across > > > all VMs? What sense does it even make? > > > > Now "perf kvm" tool is not sophisticated since it doesn't capture VMID > > and virtual CPU ID together. > > VMID is not a relevant indicator anyway, as it can change at any > point. Thanks for correction. IIUC, VMID is not fixed for virtual machine, it can be re-allocated after overflow. > But that's only to show that everybody has a different view on > what they need to collect. At which point, we need to provide an > infrastructure for data extraction, and not the data itself. Totally agree. [...] > > Option 3: As you suggested, I can bind KVM tracepoints with a eBPF > > program and the eBPF program records perf events. > > > > When I reviewed Arm64's kvm_entry / kvm_exit trace events, they don't > > have vcpu context in the arguments, this means I need to add new trace > > events for accessing "vcpu" context. > > I'm not opposed to adding new trace{point,hook}s if you demonstrate > that they are generic enough or will never need to evolve. > > > > > Option 1 and 3 both need to add trace events; option 1 is more > > straightforward solution and this is why it was choosed in current patch > > set. > > > > I recognized that I made a mistake, actually we can modify the trace > > event's definition for kvm_entry / kvm_exit, note we only modify the > > trace event's arguments, this will change the trace function's > > definition but it will not break ABI (the format is exactly same for > > the user space). Below changes demonstrate what's my proposing: > > > > diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c > > index 94d33e296e10..16f6b61abfec 100644 > > --- a/arch/arm64/kvm/arm.c > > +++ b/arch/arm64/kvm/arm.c > > @@ -917,7 +917,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) > > /************************************************************** > > * Enter the guest > > */ > > - trace_kvm_entry(*vcpu_pc(vcpu)); > > + trace_kvm_entry(vcpu); > > guest_timing_enter_irqoff(); > > > > ret = kvm_arm_vcpu_enter_exit(vcpu); > > diff --git a/arch/arm64/kvm/trace_arm.h b/arch/arm64/kvm/trace_arm.h > > index 33e4e7dd2719..9df4fd30093c 100644 > > --- a/arch/arm64/kvm/trace_arm.h > > +++ b/arch/arm64/kvm/trace_arm.h > > @@ -12,15 +12,15 @@ > > * Tracepoints for entry/exit to guest > > */ > > TRACE_EVENT(kvm_entry, > > - TP_PROTO(unsigned long vcpu_pc), > > - TP_ARGS(vcpu_pc), > > + TP_PROTO(struct kvm_vcpu *vcpu), > > + TP_ARGS(vcpu), > > > > TP_STRUCT__entry( > > __field( unsigned long, vcpu_pc ) > > ), > > > > TP_fast_assign( > > - __entry->vcpu_pc = vcpu_pc; > > + __entry->vcpu_pc = *vcpu_pc(vcpu); > > ), > > > > TP_printk("PC: 0x%016lx", __entry->vcpu_pc) > > > > Please let me know your opinion, if you don't object, I can move > > forward with this approach. > > I have no issue with this if this doesn't change anything else. Thanks for confirmation. > And if you can make use of this with a BPF program and get to the same > result as your initial patch, then please submit it for inclusion in > the kernel as an example. We can then point people to it next time > this crop up (probably before Xmas). Will do. Just head up, if everything is going well, I will place the eBPF program in the folder tools/perf/examples/bpf/, this can be easy for integration and release with perf tool. Thanks, Leo