From patchwork Tue Feb 14 05:07:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Like Xu X-Patchwork-Id: 56673 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2768135wrn; Mon, 13 Feb 2023 21:09:42 -0800 (PST) X-Google-Smtp-Source: AK7set/RHBdvoBNZ3P+XtcWQcPByLXt9C4sq7Ui5E6M9JV1d+i7nQVmgX1/Oz1QWWUiqFwO/lhdU X-Received: by 2002:a17:906:a84:b0:8aa:c358:fc01 with SMTP id y4-20020a1709060a8400b008aac358fc01mr1566400ejf.67.1676351382627; Mon, 13 Feb 2023 21:09:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676351382; cv=none; d=google.com; s=arc-20160816; b=EKcMVINvjVtDA5GYFezlVj8KzG0iYB6vTTEwaZTeiSTHyROZZo2xp5mE+zfpFI0Ykw 8cmO8fcE6m0R13UT1eKVI1eQAcNmEvmg2/69fOxrSWG91EUl6aMnCWfnmWXqVZSgqLTz JaIXYVIlqHa+TYY1wtcSkDwq6mPgv3S/13iD16riRXRm9qJR51UdlFehqm7iAIh7Kckh ikBOHhva1Yc1ASNEAvkohb8wlIP/2BTwK4Cpo6sjRL7jUriPYxKIdmr8SmSABW2IE6iJ 36sj0LAFFIW79CnnqSu8ww1RI2Nmb1IZTB0dq+fDYcyRM1/VUvwMA+dv/BHbi0QPanuf gdew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GUQki7H5qpN4QCO0DqYXuFNVqC2bqcgqgvxbR7osp/o=; b=rXyN0BfolY06/sRKkvJ0MbnSPPi10yvRufmBlPlNTzfdqacOOTT0xD7t94EHgy6CFv caO5sSmY87FbWt+YI/bu3rna36K+mkw9PJ1hYbsYTOEbnkZCpgecgBX6OfB2zeKYa6Hy g0aAg7NtuaJP2bmGOvqzEQNfdnQh8ID+OOsu8Wrcr0kGLES5VKtIW1z6clZVYQS3JA8k kGKhZoKBCikE26vU6uBnB03RdTSM7WGuh63GwFdDvm66blJ7LHir110uPMuSzE4aQiIk CzAu9uHsr9fgV86YnCwSuAFcFLNgJJPka2KuPDTvydJvVZ0S7PApRsHveQpnvgZGSwie Cwjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K1drwbqX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mr40-20020a17090782a800b0086d67b0615esi16215623ejc.242.2023.02.13.21.09.19; Mon, 13 Feb 2023 21:09:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K1drwbqX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231409AbjBNFIi (ORCPT + 99 others); Tue, 14 Feb 2023 00:08:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbjBNFIZ (ORCPT ); Tue, 14 Feb 2023 00:08:25 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6DD72AD; Mon, 13 Feb 2023 21:08:24 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id ct17so3848921pfb.12; Mon, 13 Feb 2023 21:08:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GUQki7H5qpN4QCO0DqYXuFNVqC2bqcgqgvxbR7osp/o=; b=K1drwbqX9SkiRCZGRTQKYZHT/cLGIGGY2cxShLt2OE/2QqrwaZgfEl0jShhLhImkNm pi3Uf3cVc/ML1D88dZ1yWf0f6rBx/NF+3iZCgbKxX3oO8xMc8uNq+z7b+O9vsL9ErHnW zTcPNyEWBhAG0fo2zq8ehOhHvPcYh0xKU7Pw0s7PHrj7EVhzJAGwyRKkDygYV1fw6J5H 3IJZkNhwa5VPq06QRI+y3FvuVtUby6BUNo5Lg6r6LIZYMKNFYxcC8Deb/6DbiOwua+2W NadROIFn0C9g5cgDkquzX6+PS1Q3RVtfsDkAaeegBVdpIiDGPN+nFT0o8cOWofzVy2EU bjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GUQki7H5qpN4QCO0DqYXuFNVqC2bqcgqgvxbR7osp/o=; b=s6kMiCMeSD9/M340RSRd0R37YHGWtMnSEeoZ7DHMTTPzKvJmFOXILRnW7XcIvcCxw3 0drUJ9zvPOZag0+w0Ylv6nNhhyh1JHzgNdD/A9feCZ0GEqPfB69OklF1hPvKSH/HF93Y s3p6fB+nRCvQi2sA3HFE5zzxDziYomBtxNWk5Td7UdRhrC5qdANgHu7Riwms2MW29DHs qtfNOSs61dyC8v36uM9y4phMJFeYTwD2EUGksh7xiZdbRorLSIrxjGh3h1Jwe6pEc+63 iAvMJrvEn+fe1YGXed0CvTHs+dytZXSlkzsmB4CisDhZ+WA/JR7KJYzFM+ZO/UkgEr+T gUuQ== X-Gm-Message-State: AO0yUKWhKdybrG9Yke8L4RXkmx3xdGqR6RgMt8MpyICKWC+nWLN09poM axx0Ay/P7JTZqVNUxMNgSC2Ey9ZbxYSz7Yw9MNM= X-Received: by 2002:aa7:9f49:0:b0:5a8:c90d:ab17 with SMTP id h9-20020aa79f49000000b005a8c90dab17mr906427pfr.15.1676351303761; Mon, 13 Feb 2023 21:08:23 -0800 (PST) Received: from localhost.localdomain ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id j22-20020aa79296000000b005a79f5d9f53sm8738919pfa.165.2023.02.13.21.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 21:08:23 -0800 (PST) From: Like Xu X-Google-Original-From: Like Xu To: Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 04/12] KVM: x86/pmu: Expose reprogram_counters() in pmu.h Date: Tue, 14 Feb 2023 13:07:49 +0800 Message-Id: <20230214050757.9623-5-likexu@tencent.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230214050757.9623-1-likexu@tencent.com> References: <20230214050757.9623-1-likexu@tencent.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757781827658762153?= X-GMAIL-MSGID: =?utf-8?q?1757781827658762153?= From: Like Xu The optimization stands on its own, whereas the code movement is justified only by the incoming AMD PMU v2 support. Suggested-by: Sean Christopherson Signed-off-by: Like Xu --- arch/x86/kvm/pmu.h | 12 ++++++++++++ arch/x86/kvm/vmx/pmu_intel.c | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h index 79988dafb15b..1eb50129fae7 100644 --- a/arch/x86/kvm/pmu.h +++ b/arch/x86/kvm/pmu.h @@ -189,6 +189,18 @@ static inline void kvm_pmu_request_counter_reprogam(struct kvm_pmc *pmc) kvm_make_request(KVM_REQ_PMU, pmc->vcpu); } +static inline void reprogram_counters(struct kvm_pmu *pmu, u64 diff) +{ + int bit; + + if (!diff) + return; + + for_each_set_bit(bit, (unsigned long *)&diff, X86_PMC_IDX_MAX) + set_bit(bit, pmu->reprogram_pmi); + kvm_make_request(KVM_REQ_PMU, pmu_to_vcpu(pmu)); +} + void kvm_pmu_deliver_pmi(struct kvm_vcpu *vcpu); void kvm_pmu_handle_event(struct kvm_vcpu *vcpu); int kvm_pmu_rdpmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data); diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c index 069e1aae418c..904f832fc55d 100644 --- a/arch/x86/kvm/vmx/pmu_intel.c +++ b/arch/x86/kvm/vmx/pmu_intel.c @@ -73,18 +73,6 @@ static struct kvm_pmc *intel_pmc_idx_to_pmc(struct kvm_pmu *pmu, int pmc_idx) } } -static inline void reprogram_counters(struct kvm_pmu *pmu, u64 diff) -{ - int bit; - - if (!diff) - return; - - for_each_set_bit(bit, (unsigned long *)&diff, X86_PMC_IDX_MAX) - set_bit(bit, pmu->reprogram_pmi); - kvm_make_request(KVM_REQ_PMU, pmu_to_vcpu(pmu)); -} - static bool intel_hw_event_available(struct kvm_pmc *pmc) { struct kvm_pmu *pmu = pmc_to_pmu(pmc);