Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28284850rwd; Tue, 4 Jul 2023 16:53:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlHL+1H2KTkAx2pmfFWiXodMY8nHZHoTl9m72XHCQ/8pOqc7b6Ug/RjPYnvlo2B/Sls0eZat X-Received: by 2002:a17:90b:2d82:b0:24e:4b1c:74d2 with SMTP id sj2-20020a17090b2d8200b0024e4b1c74d2mr16324850pjb.32.1688514782181; Tue, 04 Jul 2023 16:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688514782; cv=none; d=google.com; s=arc-20160816; b=Km7ZijoVUGaFoOQWIKphZPLqKLJIZa7bCyy/syIGXuEuPJ5jBQ5FEK02V7AZQiZKKg DyotmJ/X7RptjOxXnUlgumN74f94EBYfFEuNYaThOnEjNVU8/h5i542IXMQ3yINGIzf/ liF1iIj53olhOMCZyjbIo3gOYLp2wnNy1DoDwMojeEA7FiRbUuFltC7sLFz9/zt+St8t LqE+mAoJsqd9tYcEMyedxpmkYPtXKfGo2Rgv3FzlxTtHtTBVclHuu864mSuv0JSKbhTP nuS5fgQJMbYpmwXyTJHdDn2iL/tsfr/cmSCvWFgq8zQLfJUaJWtY2Yg8sXKKvL8azl0H zGoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=SWDhkOVApoINIA9ZPTjwVACEMtw6P7Jwrml0wL1EZHc=; fh=FyIfd4uuR0deF27r+nYhkLfrI5RtUr/XH7Aas6xerkU=; b=KST5MhumWVrLcQ0dUScKxrndWQrDubJbTI01tmoOqlGFQmrlwOZhj8kcp3nwZw+1y+ p2YnH2Pxl00di6g9C6tCn9xzH2+Zw0C8d3We9HcQMy6p3GkBj374gTAdQpuFipO1PV3G F5VzhOidzYI1u9KAS5UudbVRjuLYbSR41+NIWE0Kj6mYeqBCG5KmMZzZQK5q21wGNXIb 4UB8MnscbHzkjLNaqUDPPWrz3IPZu9IGpclh67n6A5XOGqZNlOSGi9gCKacByxsjRyrr 86jtblstxTRUKC+tQ7yVUX6QqF5YZmyfgV7oV6puqdFV7UnNbY7YQS2GjuCeYqfUSyJ2 sUvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OUBYMBo3; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id il14-20020a17090b164e00b00263aff4ccf0si414117pjb.3.2023.07.04.16.52.49; Tue, 04 Jul 2023 16:53:02 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=OUBYMBo3; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbjGDXj2 (ORCPT + 99 others); Tue, 4 Jul 2023 19:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjGDXj1 (ORCPT ); Tue, 4 Jul 2023 19:39:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A991134 for ; Tue, 4 Jul 2023 16:38:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688513923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SWDhkOVApoINIA9ZPTjwVACEMtw6P7Jwrml0wL1EZHc=; b=OUBYMBo3vWBhzsbumsrIvLhaSqR5cjD1cIS/acQk6XIDkjVCFXz9QudtkCd9vw008QxeLA PqVrVZuAV5wTiU5MDKFHe1syGbOq8WrZyfas8FVS0BggCUW4d8Rv7RJccP3qiUvgjY58jj Dztr0UoJ+3f+8As+bReBv5X4490xWQk= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-jAHOdSr_Me2ryNjRr_TQnQ-1; Tue, 04 Jul 2023 19:38:42 -0400 X-MC-Unique: jAHOdSr_Me2ryNjRr_TQnQ-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2630307e6f4so8562269a91.2 for ; Tue, 04 Jul 2023 16:38:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688513921; x=1691105921; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SWDhkOVApoINIA9ZPTjwVACEMtw6P7Jwrml0wL1EZHc=; b=GSZu+02ZhtZmupIKrSQrhgvObR3uBPYk4rF/NyGlUEP1xD6FubyKydspxLTX9A6pS+ 3gNTEIWKgXFKFwwnXuj0zTC7yeINY/utCOpY5vxNLJHAXhaNPIVJdSKJ+9f0KY3+VQDm GjvqUGL9DO8W+jaATyTe8TUf/qncXIqivyoOSWi962oFGzO8eKQSJfVUMFjtbvVVp6xt uQPyT5j22iRphqautV3vZsuBQE+0Zk0QAGqdugiRw79gEfJlM/5gUtoMkBvOe8+VIBH6 BM0gJ5N3VfXYRW5ek4Q3cFvrtZ4COPFT8sOAS7XQSiqKXFVVMhuWlzski7gD7leusE+k efBA== X-Gm-Message-State: ABy/qLapkDKH/4ADXPGpUDUVLUWdeS/Y+nsh4RVMZdZ77IX0aE6kMmhK 8jMmqeGl1FNC0c07tstYBAIUm8SZVm8u0Sgw9txS0iVvCcYGI9ZpjvCyRwtufmNy3O6FjlDoEE9 5+JXbfiQ4/YH8Ih5EBTVRWLqg X-Received: by 2002:a17:90a:7641:b0:262:ece1:5fd9 with SMTP id s1-20020a17090a764100b00262ece15fd9mr14738225pjl.10.1688513921228; Tue, 04 Jul 2023 16:38:41 -0700 (PDT) X-Received: by 2002:a17:90a:7641:b0:262:ece1:5fd9 with SMTP id s1-20020a17090a764100b00262ece15fd9mr14738208pjl.10.1688513920891; Tue, 04 Jul 2023 16:38:40 -0700 (PDT) Received: from ?IPV6:2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5? ([2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5]) by smtp.gmail.com with ESMTPSA id a6-20020a1709027d8600b001b392bf9192sm17621326plm.145.2023.07.04.16.38.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jul 2023 16:38:40 -0700 (PDT) Message-ID: <0bdc3105-fc3d-d0e1-60e7-d626171e1057@redhat.com> Date: Wed, 5 Jul 2023 09:38:29 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RESEND PATCH v5 02/11] KVM: arm64: Use kvm_arch_flush_remote_tlbs() Content-Language: en-US To: Raghavendra Rao Ananta , Oliver Upton , Marc Zyngier , James Morse , Suzuki K Poulose Cc: Paolo Bonzini , Sean Christopherson , Huacai Chen , Zenghui Yu , Anup Patel , Atish Patra , Jing Zhang , Colton Lewis , David Matlack , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-mips@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Zenghui Yu References: <20230621175002.2832640-1-rananta@google.com> <20230621175002.2832640-3-rananta@google.com> From: Gavin Shan In-Reply-To: <20230621175002.2832640-3-rananta@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 6/22/23 03:49, Raghavendra Rao Ananta wrote: > From: David Matlack > > Use kvm_arch_flush_remote_tlbs() instead of > CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL. The two mechanisms solve the same > problem, allowing architecture-specific code to provide a non-IPI > implementation of remote TLB flushing. > > Dropping CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL allows KVM to standardize > all architectures on kvm_arch_flush_remote_tlbs() instead of maintaining > two mechanisms. > > Opt to standardize on kvm_arch_flush_remote_tlbs() since it avoids > duplicating the generic TLB stats across architectures that implement > their own remote TLB flush. > > This adds an extra function call to the ARM64 kvm_flush_remote_tlbs() > path, but that is a small cost in comparison to flushing remote TLBs. > > No functional change intended. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ It's not true and please refer to the below explanation. > > Signed-off-by: David Matlack > Signed-off-by: Raghavendra Rao Ananta > Reviewed-by: Zenghui Yu > Acked-by: Oliver Upton > --- > arch/arm64/include/asm/kvm_host.h | 3 +++ > arch/arm64/kvm/Kconfig | 1 - > arch/arm64/kvm/mmu.c | 6 +++--- > virt/kvm/Kconfig | 3 --- > virt/kvm/kvm_main.c | 2 -- > 5 files changed, 6 insertions(+), 9 deletions(-) > The changes make sense and look good to me. However, there is a functional change because the generic kvm_arch_flush_remote_tlbs() isn't exactly same to ARM64's variant. Strictly speaking, they're not interchangeable. In the generic function, both statistics ( remote_tlb_flush_requests and remote_tlb_flush) are increased. Only the former statistic is increased in ARM64's variant. It looks correct to increase both statistics, but the commit log may need tweak to reflect it. With this resolved: Reviewed-by: Gavin Shan > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 7e7e19ef6993e..81ab41b84f436 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -1078,6 +1078,9 @@ int __init kvm_set_ipa_limit(void); > #define __KVM_HAVE_ARCH_VM_ALLOC > struct kvm *kvm_arch_alloc_vm(void); > > +#define __KVM_HAVE_ARCH_FLUSH_REMOTE_TLBS > +int kvm_arch_flush_remote_tlbs(struct kvm *kvm); > + > static inline bool kvm_vm_is_protected(struct kvm *kvm) > { > return false; > diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig > index f531da6b362e9..6b730fcfee379 100644 > --- a/arch/arm64/kvm/Kconfig > +++ b/arch/arm64/kvm/Kconfig > @@ -25,7 +25,6 @@ menuconfig KVM > select MMU_NOTIFIER > select PREEMPT_NOTIFIERS > select HAVE_KVM_CPU_RELAX_INTERCEPT > - select HAVE_KVM_ARCH_TLB_FLUSH_ALL > select KVM_MMIO > select KVM_GENERIC_DIRTYLOG_READ_PROTECT > select KVM_XFER_TO_GUEST_WORK > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 3b9d4d24c361a..d0a0d3dca9316 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -81,15 +81,15 @@ static bool memslot_is_logging(struct kvm_memory_slot *memslot) > } > > /** > - * kvm_flush_remote_tlbs() - flush all VM TLB entries for v7/8 > + * kvm_arch_flush_remote_tlbs() - flush all VM TLB entries for v7/8 > * @kvm: pointer to kvm structure. > * > * Interface to HYP function to flush all VM TLB entries > */ > -void kvm_flush_remote_tlbs(struct kvm *kvm) > +int kvm_arch_flush_remote_tlbs(struct kvm *kvm) > { > - ++kvm->stat.generic.remote_tlb_flush_requests; > kvm_call_hyp(__kvm_tlb_flush_vmid, &kvm->arch.mmu); > + return 0; > } > > static bool kvm_is_device_pfn(unsigned long pfn) > diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig > index b74916de5183a..484d0873061ca 100644 > --- a/virt/kvm/Kconfig > +++ b/virt/kvm/Kconfig > @@ -62,9 +62,6 @@ config HAVE_KVM_CPU_RELAX_INTERCEPT > config KVM_VFIO > bool > > -config HAVE_KVM_ARCH_TLB_FLUSH_ALL > - bool > - > config HAVE_KVM_INVALID_WAKEUPS > bool > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index a475ff9ef156d..600a985b86215 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -350,7 +350,6 @@ bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req) > } > EXPORT_SYMBOL_GPL(kvm_make_all_cpus_request); > > -#ifndef CONFIG_HAVE_KVM_ARCH_TLB_FLUSH_ALL > void kvm_flush_remote_tlbs(struct kvm *kvm) > { > ++kvm->stat.generic.remote_tlb_flush_requests; > @@ -371,7 +370,6 @@ void kvm_flush_remote_tlbs(struct kvm *kvm) > ++kvm->stat.generic.remote_tlb_flush; > } > EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); > -#endif > > static void kvm_flush_shadow_all(struct kvm *kvm) > {