Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3682752ybg; Sun, 20 Oct 2019 19:26:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNi2nerb/QVDTrP98xBe/Dmpd4OwQUwVDCh6FdI/dL68WnSs9tpev9kfp0w37Ir4IxZnGP X-Received: by 2002:a05:6402:1612:: with SMTP id f18mr22666697edv.66.1571624809961; Sun, 20 Oct 2019 19:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571624809; cv=none; d=google.com; s=arc-20160816; b=kImZJhjyy6bpI2QF1ikRb+hNjpBgcQzpGHdIM5smh9uSev0vRCGCQ1sxWj2o50ZqIE 4cNK0YdROFFFFZGkTsEKXye8f+79BFu9mzw+DP+uPzcmwEgFHGSLtLaNWKcGdu4i7cJe 3Kiyafem38UtN9jNLy29GYxlz2/rzgtoOfzos70Xa1veTLDM7OmlC62IHRGncPwHFBgP eoDpX0hj5uKCpubSOtLAuQfhWqNNFWFzFP73ItZ/CtkNcsVCkY+KLAkQMASkqbcxT/Vy G8ZInOQFgkfCTa1bAViQ239Q/9UC0ID6NxtM5NFCwiIbEuWvNvACKaA6nBTUqzXU5CvD vikA== 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:organization:references:cc:to:from:subject; bh=LPpcsO7t/S68cZGYHz/AClNNtVuO9+ES9pUBn37YoNs=; b=MPs6H8Sqt5IStD/ZqTLh0APMaRhjulAs3zdfhpZfx84HMCKZerROvjj7C12oOm6SPV P1tWsHCjYN8fZr7TZad1UjPYTlDB1CLsTMrFNXzwcelNg8J8idOW4HEYNf6Vc2mexKZI CQ28TAu5iw0bo3SRNavc3hlLYsQKR+y0s9lDyzkDG9UFvPcY57sJDbVs2XusmCPLfOWQ No5rTulNKlj3v25M5Uj/98BHm7IsrGIPpFDvri+C1Rbb+zsPYGmNDzW6WJ+1ZJ7iO1Q6 r1blik2F6lkhsU0G2MGZC+WURKRbNT4yzCTGHyht+mskLgMxBDAa9ll4XOI4IbQVbdzW hLfQ== 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 cf19si610125ejb.14.2019.10.20.19.26.26; Sun, 20 Oct 2019 19:26:49 -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 S1726899AbfJUC0H (ORCPT + 99 others); Sun, 20 Oct 2019 22:26:07 -0400 Received: from mga02.intel.com ([134.134.136.20]:24376 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726738AbfJUC0H (ORCPT ); Sun, 20 Oct 2019 22:26:07 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Oct 2019 19:26:06 -0700 X-IronPort-AV: E=Sophos;i="5.67,321,1566889200"; d="scan'208";a="190965593" Received: from likexu-mobl1.ccr.corp.intel.com (HELO [10.239.196.130]) ([10.239.196.130]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/AES256-SHA; 20 Oct 2019 19:26:03 -0700 Subject: Re: [PATCH v2 0/4] KVM: x86/vPMU: Efficiency optimization by reusing last created perf_event From: Like Xu To: Paolo Bonzini Cc: kvm@vger.kernel.org, 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> Organization: Intel OTC Message-ID: Date: Mon, 21 Oct 2019 10:26:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191013091533.12971-1-like.xu@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed 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 2019/10/13 17:15, Like Xu wrote: ... Hi Paolo, Do you have any concerns or comments for the KVM codes (the last two patches) about this vPMU efficiency optimization? Thanks, Like Xu > > --- > Changes in v2: > - use perf_event_pause() to disable, read, reset by only one lock; > - use __perf_event_read_value() after _perf_event_disable(); > - replace bitfields with 'u8 event_count; bool need_cleanup;'; > - refine comments and commit messages; > - fix two issues reported by kbuild test robot for ARCH=[nds32|sh] > > v1: > https://lore.kernel.org/kvm/20190930072257.43352-1-like.xu@linux.intel.com/ > > Like Xu (4): > perf/core: Provide a kernel-internal interface to recalibrate event > period > perf/core: Provide a kernel-internal interface to pause perf_event > KVM: x86/vPMU: Reuse perf_event to avoid unnecessary > pmc_reprogram_counter > KVM: x86/vPMU: Add lazy mechanism to release perf_event per vPMC > > arch/x86/include/asm/kvm_host.h | 17 +++++++ > arch/x86/kvm/pmu.c | 88 ++++++++++++++++++++++++++++++++- > arch/x86/kvm/pmu.h | 15 +++++- > arch/x86/kvm/pmu_amd.c | 14 ++++++ > arch/x86/kvm/vmx/pmu_intel.c | 27 ++++++++++ > arch/x86/kvm/x86.c | 12 +++++ > include/linux/perf_event.h | 10 ++++ > kernel/events/core.c | 44 ++++++++++++++--- > 8 files changed, 216 insertions(+), 11 deletions(-) >