Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4403599ybg; Mon, 21 Oct 2019 08:29:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1+jAJOxbIgV1g4RQpTo8o4PFuLRIKjAUv9o63TN/qLG3Guti7MB9CSipUFNF2Xd5usAwg X-Received: by 2002:a50:8e53:: with SMTP id 19mr69007edx.134.1571671755160; Mon, 21 Oct 2019 08:29:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571671755; cv=none; d=google.com; s=arc-20160816; b=Ygg/4n3hnuLtLlULWWhdygjUdBKLQx4ppAOAo3jWRiW43ZX8aT8sBGS3cFzoUVzpbc AtL+YrzP/OB51o2koKlHLOqaZg7PRzisGLzJ3KkJ/iePqRogLrEn16/83mGrgS1lrocS skex1+CvKPDEyeEdRmJKfdYPDZ8yaTVGJLzUpkRODKDb2QJu5UnApWB9hlyYKWm9gBBh AXZoT81c6UrecMjG3P/n62zvTYnsAm2xfdTGMz0mYbtjG3+EjQwvkNcfPe7mcr7B9g1D xnUhQ6MrFz8m48VX0x2yoZtpLD0MrkT3w80Oynno3h06Z0rv75abh73cTjb7jqhMNXrp KlKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=HEmIeXds/Gv0xSpUczzsnAMQ34YFmWv/ybBjSlwqKDI=; b=cKpj89OSp52TzAItc00OwUdTMz1PsRwZ1/DCkoYXkWH9SaLFddIZZ41Ldl0cPni71f g7qsm5y+stOyAmFYoiTikrijEjQ35HrXHtYp4h97wZb3bEABXFE2lj2L02M13Yxf3wC6 2LyUCsUqYqdQJ4DSQdVukLbAUeZSVyECwvCGn5h2XWyRIr+N8mCKyTN2tfi+aFUaByzb A+2TIXVtqYPntlG7Dt5//ribG0QNmKgvDpObfX9uKt2FS2rt8h8jbal1x+Wu2+e5BMKT cqfCqEq900/uce1ml5j48us8tzK6ehCnVIo8XCSFk1thyTlVnKMW4h2l3o3Z8nZx4oYO xPGA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si8739532ejj.40.2019.10.21.08.28.50; Mon, 21 Oct 2019 08:29:15 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729377AbfJUP2g (ORCPT + 99 others); Mon, 21 Oct 2019 11:28:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57024 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727960AbfJUP2g (ORCPT ); Mon, 21 Oct 2019 11:28:36 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC28059455 for ; Mon, 21 Oct 2019 15:28:35 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id z5so3271036wma.5 for ; Mon, 21 Oct 2019 08:28:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HEmIeXds/Gv0xSpUczzsnAMQ34YFmWv/ybBjSlwqKDI=; b=uOrMMsvWOl+pO+PzPt3m0gtRZtmkEhqQ1afyb+nzWiLt/xdzQsuC+vFthUObl5mkVZ YCFis2nzA3jHNSn4Y65rxDp7JtT7h8dpyO971LmnnabFztl3h3VuhO4Jzwr9nNAMbz0W 104et9R8rMwwl9UUcd+2eINh38ih66PHTfSPbXriUvP+IZIfLRkuxS3kQPVN6DKPUBi4 e8Am9ieVWlWIV/R11K2b5Du1j0jORzVxtoi0DQ1TTpCSzeBZbauOZfvOzHtIwz5O2opi v+JLX+iDEA7keYPI7O8SMrKhVXdIu+F78Ly8xMYhQLgGRPOB/oOGaHmoVnTfTugjVNL2 E9uA== X-Gm-Message-State: APjAAAWeyPi44NS75BRMS6m/KUya50RD4vIPDM9O3Ez/CFUSsCLBTSVL mi1JJfsZuYagZwj8PAMkykwflcuYQOM41x2n9qLdBonp0Ogq/lY0JgKc4WtKfPZUMoombm40EZ1 NU0EliOA1/Y4prC58WL5pZSPD X-Received: by 2002:adf:fcd1:: with SMTP id f17mr4908326wrs.82.1571671714172; Mon, 21 Oct 2019 08:28:34 -0700 (PDT) X-Received: by 2002:adf:fcd1:: with SMTP id f17mr4908292wrs.82.1571671713880; Mon, 21 Oct 2019 08:28:33 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:847b:6afc:17c:89dd? ([2001:b07:6468:f312:847b:6afc:17c:89dd]) by smtp.gmail.com with ESMTPSA id a2sm2635979wrv.39.2019.10.21.08.28.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Oct 2019 08:28:33 -0700 (PDT) Subject: Re: [PATCH v2 4/4] KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC To: Like Xu , kvm@vger.kernel.org Cc: peterz@infradead.org, Jim Mattson , rkrcmar@redhat.com, sean.j.christopherson@intel.com, vkuznets@redhat.com, Ingo Molnar , Arnaldo Carvalho de Melo , ak@linux.intel.com, wei.w.wang@intel.com, kan.liang@intel.com, like.xu@intel.com, ehankland@google.com, arbel.moshe@oracle.com, linux-kernel@vger.kernel.org References: <20191013091533.12971-1-like.xu@linux.intel.com> <20191013091533.12971-5-like.xu@linux.intel.com> <5eb638a3-5ebe-219a-c975-19808ab702b9@redhat.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <2175c2cd-2c1e-22e8-2f67-3fc334ef2a40@redhat.com> Date: Mon, 21 Oct 2019 17:28:31 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/10/19 16:04, Like Xu wrote: > >> >> 2) introduce a new callback msr_idx_to_pmc that returns a struct >> kvm_pmc*, and change kvm_pmu_is_valid_msr to do > > For callback msr_idx_to_pmc, > how do we deal with the input 'MSR_CORE_PERF_FIXED_CTR_CTRL' > which may return several fixed kvm_pmcs not just one? For RDMSR, do not do anything. For WRMSR, you can handle it in the set_msr callback. >> >> static int kvm_pmu_mark_pmc_in_use(struct kvm_vcpu *vcpu, u32 msr) > > s/static int/static void/. > >> { >> struct kvm_pmu *pmu = vcpu_to_pmu(vcpu); >> struct kvm_pmc *pmc = kvm_x86_ops->pmu_ops->msr_idx_to_pmc(vcpu, msr); > > We need 'if(pmc)' here. Agreed, sorry for the sloppiness. Never interpret my suggestions as more than pseudocode. :) Paolo