From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C532C433B4 for ; Tue, 18 May 2021 13:43:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F184B6105A for ; Tue, 18 May 2021 13:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233218AbhERNog (ORCPT ); Tue, 18 May 2021 09:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234487AbhERNoP (ORCPT ); Tue, 18 May 2021 09:44:15 -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 04588C061573; Tue, 18 May 2021 06:42:57 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=FEdlQoyD3PDtpLtM4yznKXxGHpEaCgn204cnBtbvYCk=; b=W7luStfFr08ol2+PUA4kGF3wxR xQee1C6GuP75GOHIjB5LXSPSlSVqpPbZsu6ajL2a2B434rMEjUzbB6Bm/VYR9uZ+HIa/af5LukwPG nfniSH+OKQjLQSEY8PMlGN/4uqZ/IS8BEq4lJNWOcIzRIxvNji+awzd5xIEIXSMDdCZl6isrMiUTF hWxGAbAPES/tU0woQbQLMxeyFHjyQ1NETMPo39QZqefYcG8NK/zz30A4mUhz7Ecb33eBhP/ril9YB jBeq+8KmcO0De0DVQ4O61feEreSVPD2tSFqABqu84vuIrwzR30+mityUvmN3brmPdTkRWY3U3KK29 HHvWouIA==; 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 1lizzX-000tpt-Gj; Tue, 18 May 2021 13:42:35 +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 D892A30022C; Tue, 18 May 2021 15:42:34 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C11663011B372; Tue, 18 May 2021 15:42:34 +0200 (CEST) Date: Tue, 18 May 2021 15:42:34 +0200 From: Peter Zijlstra To: "Xu, Like" Cc: Paolo Bonzini , Borislav Petkov , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , weijiang.yang@intel.com, Kan Liang , ak@linux.intel.com, wei.w.wang@intel.com, eranian@google.com, liuxiangdong5@huawei.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Luwei Kang , Like Xu Subject: Re: [PATCH v6 06/16] KVM: x86/pmu: Add IA32_PEBS_ENABLE MSR emulation for extended PEBS Message-ID: References: <20210511024214.280733-1-like.xu@linux.intel.com> <20210511024214.280733-7-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 04:44:13PM +0800, Xu, Like wrote: > Will adding the following comments help you ? > > +/* > + * Currently, the only caller of this function is the atomic_switch_perf_msrs(). > + * The host perf conext helps to prepare the values of the real hardware for > + * a set of msrs that need to be switched atomically in a vmx transaction. > + * > + * For example, the pseudocode needed to add a new msr should look like: > + * > + * arr[(*nr)++] = (struct perf_guest_switch_msr){ > + *     .msr = the hardware msr address, > + *     .host = the value the hardware has when it doesn't run a guest, > + *     .guest = the value the hardware has when it runs a guest, So personally I think the .host and .guest naming is terrible here, because both values are host values. But I don't know enough about virt to know if there's accepted nomencature for this. > + * }; > + * > + * These values have nothing to do with the emulated values the guest sees > + * when it uses {RD,WR}MSR, which should be handled in the KVM context. > + */ >  static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr, void *data) Yes, now at least one can understand wth this function does, even though the actual naming is still horrible. Thanks! Additionally, would it make sense to add a pointer to the KVM code that does the emulation for each MSR listed in this function?