Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1626689pxj; Wed, 19 May 2021 10:05:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd2ggKJqapnoPnWVufQTNH7zWOSag9m5LQZ0qWSFgxhE1TGfHxUtY7h6HQvvKjJwV1LuxD X-Received: by 2002:aa7:c04e:: with SMTP id k14mr36320edo.157.1621443934491; Wed, 19 May 2021 10:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621443934; cv=none; d=google.com; s=arc-20160816; b=X0hRSuD/S1mtqFIQ2RUEibYlt2t2ZuLUYw0jJUkEyfxmFmrP+WW9Q9P0nm/rICljLM r5fjAGIS8KSt/Fay2pXwdd6V/lz5SGb0fHpcOoWcxAUuhhgP9vMDDSOqYCemjsUqyOin MSR0bp6o6ijxgFDChtc5d7nwnwRvXJdtgnLvKEY0l8zpqdZQwzpx0gErIMupJLqFHRLt omccf4TfXh0FT666R2j5IV830g1A30otPkWWl3bZ9VEuPfGnIf1U6vztd3Of7R4/hFV7 CeNORleyMSfaq3+LqXigslW22iGWhWoHwbcVGee6FXcrqv9ZtMkJ5qmA3uA3MSAx+/vl tWyg== 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=Qo/ejMpseWPZweg994TuCvjOYtuu85Q0Ic4AlvPr1h8=; b=AxmnuKosipi5xOGOH9mIJHpP1NbtrPfcKBHhRoL8fGm8CTPeGiEbej+JoSE6A9z7SV sFiQ4qWxykoKGzYECmk9a/8imSbf8rQLPmNNmW+PyN7G8T+Mc1zw2q6BWA5VW4XJ/RBt lRxLOAK8ySvdR/VfJZJGBi4AfVWJLujowC0ZGM0oAvOVP5oc8ulaKIPkZIC48+KcfkxA /F3yud8P/raB2qJW7gGYWc2bWW2ljlucnO8MLXWgHesiSRASYSQIUINWNrdB9DKmvspc 1ufqiH35cOU5D5hsRly7crlT5wEuIwAhpg4L3/ky5sowmoWwVlQCk3hsG1urw9m9dc0/ DFTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=lC4eEu47; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b19si5743199edx.198.2021.05.19.10.05.10; Wed, 19 May 2021 10:05:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=lC4eEu47; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347566AbhERIs6 (ORCPT + 99 others); Tue, 18 May 2021 04:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241591AbhERIs6 (ORCPT ); Tue, 18 May 2021 04:48:58 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D69EC061573; Tue, 18 May 2021 01:47:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Qo/ejMpseWPZweg994TuCvjOYtuu85Q0Ic4AlvPr1h8=; b=lC4eEu47b6H8uDkjU4w9yr+BPN OWXv04azGL5wtNekiPlJI0OxIFZfeoIG0JNnOw6R0LXlYIISYFzEP4EdgB7gPWqoRObeGzZPi0nRT aBLoyWcOC6QRjXHVl8sTckJwF3U/eF/EDAtMabaBecMW/mwXStZlW5DwP9oFcynvWLOtgkzMKbU3O yQn7KLRwV4yrxbTgpaFLAHLrmLu090zoDaOEMFshOzYtoCjlWtY2ilPccq9bdmsZSzxcjkYXMeHjk 1XiCnb8QOlUX9ff9J8/2x0yVlbIhs54V+IuicKIEtPC3vBGIYySR3wlFXT7lKg6Dnuory24w38O88 JSBniVvw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1livNf-00Hapq-Gs; Tue, 18 May 2021 08:47:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DE6AC30022A; Tue, 18 May 2021 10:47:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C58322BE6E846; Tue, 18 May 2021 10:47:09 +0200 (CEST) Date: Tue, 18 May 2021 10:47:09 +0200 From: Peter Zijlstra To: Andi Kleen Cc: Like Xu , Paolo Bonzini , Borislav Petkov , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, Kan Liang , wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v6 07/16] KVM: x86/pmu: Reprogram PEBS event to emulate guest PEBS counter Message-ID: References: <20210511024214.280733-1-like.xu@linux.intel.com> <20210511024214.280733-8-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 17, 2021 at 07:44:15AM -0700, Andi Kleen wrote: > > On 5/17/2021 1:39 AM, Peter Zijlstra wrote: > > On Tue, May 11, 2021 at 10:42:05AM +0800, Like Xu wrote: > > > + if (pebs) { > > > + /* > > > + * The non-zero precision level of guest event makes the ordinary > > > + * guest event becomes a guest PEBS event and triggers the host > > > + * PEBS PMI handler to determine whether the PEBS overflow PMI > > > + * comes from the host counters or the guest. > > > + * > > > + * For most PEBS hardware events, the difference in the software > > > + * precision levels of guest and host PEBS events will not affect > > > + * the accuracy of the PEBS profiling result, because the "event IP" > > > + * in the PEBS record is calibrated on the guest side. > > > + */ > > > + attr.precise_ip = 1; > > > + } > > You've just destroyed precdist, no? > > precdist can mean multiple things: > > - Convert cycles to the precise INST_RETIRED event. That is not meaningful > for virtualization because "cycles" doesn't exist, just the raw events. > > - For GLC+ and TNT+ it will force the event to a specific counter that is > more precise. This would be indeed "destroyed", but right now the patch kit > only supports Icelake which doesn't support that anyways. > > So I think the code is correct for now, but will need to be changed for > later CPUs. Should perhaps fix the comment though to discuss this. OK, can we then do a better comment that explains *why* this is correct now and what needs help later? Because IIUC the only reason it is correct now is because: - we only support ICL * and ICL has pebs_format>=2, so {1,2} are the same * and ICL doesn't have precise_ip==3 support - Other hardware (GLC+, TNT+) that could possibly care here is unsupported atm. but needs changes. None of which is actually mentioned in that comment it does have.