From: Yosry Ahmed Date: Wed, 27 May 2026 23:47:01 +0000 (+0000) Subject: KVM: x86/pmu: Do a single atomic OR when reprogramming counters X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e48810e06f45251a56bc007485854112e6cfc430;p=thirdparty%2Fkernel%2Flinux.git KVM: x86/pmu: Do a single atomic OR when reprogramming counters Do a single atomic OR using the atomic overlay of reprogram_pmi bitmask, instead of one atomic set_bit() call per counter. Signed-off-by: Yosry Ahmed Link: https://patch.msgid.link/20260527234711.4175166-8-yosry@kernel.org Signed-off-by: Sean Christopherson --- diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h index f8286067722b..0e99022168a8 100644 --- a/arch/x86/kvm/pmu.h +++ b/arch/x86/kvm/pmu.h @@ -213,13 +213,10 @@ static inline void kvm_pmu_request_counter_reprogram(struct kvm_pmc *pmc) static inline void kvm_pmu_request_counters_reprogram(struct kvm_pmu *pmu, u64 counters) { - int bit; - if (!counters) return; - for_each_set_bit(bit, (unsigned long *)&counters, X86_PMC_IDX_MAX) - set_bit(bit, pmu->reprogram_pmi); + atomic64_or(counters, &pmu->__reprogram_pmi); kvm_make_request(KVM_REQ_PMU, pmu_to_vcpu(pmu)); }