Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3035967ybl; Thu, 29 Aug 2019 17:16:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3Nh1ltV+fpSuCyE8n8F498CdE+5fvA+I+KCVVnjdS+yZgPVm+Izeju/QsOms0T5GHzKq+ X-Received: by 2002:a17:902:5ac3:: with SMTP id g3mr13577861plm.25.1567124202395; Thu, 29 Aug 2019 17:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567124202; cv=none; d=google.com; s=arc-20160816; b=MwAj/RQi0N4Ms/LqfP4+YYpijP1cmiZ2sjD8xCeRlUYZrTu7I8ho/QP9Hv38/Jb7Rg XPyOZOeYeSwHawtVoEER5Y4Tu4vCVWE9zWXeDq03wT1NWD1mPN7+DV4O9wvxBtxdOwOE Mo8DA2LkljkU18qUSrisBiFpkZTPa7UckX5aYiPe3chofstvl5UwKlkimlXKFVc5HQZm D28HOzA4dfd/EsN/dczkIfbyyWg/G5MHe1rEfD3fN4PKrICBxwG74CEp5qeSNDhyGtpi 2YUDokccTO4XWnFdB30eLMqztHi55MtqB/mZ2fyFUnuh3+8u6LIr5lk8lpohk8CsHsKt asDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=CCktCmVy+vQbEbZBhTxYSjvzVsHt6BmZCDgv5vyQrW8=; b=RCyLs+Khav17Ho6uB15HEDZWRd0dTGuIdqROXUf73ClNufKYYxI6XikdN1jwfvmCVp Hl4TFMvGY3NeXWbraEokfzmJ7yQ4m61t5pkklwEaPQJgyRf9LpJ+e0FUXNDMavb807up iDSXXufDZRphMCec7dArde7a76N4PHMcQNWKhjRdDy5S4Qf3U+ovLAIqUNHT53t6/Yjy EgZmnO1+wobNg1iveOXKpTMi6vVM8xdH0TLCX4tlcd8Q3Yx2fmj/FH4So+R2/k8G1J2b BI6WLaOwvHajgoU8BraK/dt1IwZRFixd5qvl8i6JBbQdT9FB5HN4o8LuL/XyO3nkWr2K gcZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k193si3102954pge.330.2019.08.29.17.16.24; Thu, 29 Aug 2019 17:16:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727020AbfH3APe convert rfc822-to-8bit (ORCPT + 99 others); Thu, 29 Aug 2019 20:15:34 -0400 Received: from mga03.intel.com ([134.134.136.65]:36471 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725826AbfH3APe (ORCPT ); Thu, 29 Aug 2019 20:15:34 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Aug 2019 17:15:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,445,1559545200"; d="scan'208";a="332693126" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga004.jf.intel.com with ESMTP; 29 Aug 2019 17:15:32 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 29 Aug 2019 17:15:32 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 29 Aug 2019 17:15:32 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.112]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.163]) with mapi id 14.03.0439.000; Fri, 30 Aug 2019 08:15:30 +0800 From: "Kang, Luwei" To: Andi Kleen CC: "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "Christopherson, Sean J" , "vkuznets@redhat.com" , "wanpengli@tencent.com" , "jmattson@google.com" , "joro@8bytes.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" , "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [RFC v1 1/9] KVM: x86: Add base address parameter for get_fixed_pmc function Thread-Topic: [RFC v1 1/9] KVM: x86: Add base address parameter for get_fixed_pmc function Thread-Index: AQHVXiwTvN9l0Wf/9ESeUncX5js89qcSGdmAgAC25tA= Date: Fri, 30 Aug 2019 00:15:29 +0000 Message-ID: <82D7661F83C1A047AF7DC287873BF1E1737F7892@SHSMSX104.ccr.corp.intel.com> References: <1567056849-14608-1-git-send-email-luwei.kang@intel.com> <1567056849-14608-2-git-send-email-luwei.kang@intel.com> <20190829211015.GU5447@tassilo.jf.intel.com> In-Reply-To: <20190829211015.GU5447@tassilo.jf.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > /* returns fixed PMC with the specified MSR */ -static inline struct > > kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 msr) > > +static inline struct kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 > msr, > > + int base) > > Better define a __get_fixed_pmc just for this case, with the existing > get_fixed_pmc being a wrapper. > > This would avoid changing all the callers below. Do you mean change the code like this, and call "__get_fixed_pmc" in my patch? We already have a similar function to get gp counters. struct kvm_pmc *get_gp_pmc(struct kvm_pmu *pmu, u32 msr, u32 base) // get gp counters struct kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 msr) // get fixed counters -/* returns fixed PMC with the specified MSR */ -static inline struct kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 msr) +static inline struct kvm_pmc *__get_fixed_pmc(struct kvm_pmu *pmu, u32 msr, u32 base) { - int base = MSR_CORE_PERF_FIXED_CTR0; - if (msr >= base && msr < base + pmu->nr_arch_fixed_counters) return &pmu->fixed_counters[msr - base]; return NULL; } +/* returns fixed PMC with the specified MSR */ +static inline struct kvm_pmc *get_fixed_pmc(struct kvm_pmu *pmu, u32 msr) +{ + return __get_fixed_pmc(pmu, msr, MSR_CORE_PERF_FIXED_CTR0) +} Thanks, Luwei Kang > > > -Andi