All of lore.kernel.org
 help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Yanan Wang <wangyanan55@huawei.com>
Cc: Marc Zyngier <maz@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	James Morse <james.morse@arm.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com,
	yuzenghui@huawei.com
Subject: Re: [PATCH 2/2] KVM: arm64: Skip the cache flush when coalescing tables into a block
Date: Mon, 8 Mar 2021 16:34:55 +0000	[thread overview]
Message-ID: <20210308163454.GA26561@willie-the-truck> (raw)
In-Reply-To: <20210125141044.380156-3-wangyanan55@huawei.com>

On Mon, Jan 25, 2021 at 10:10:44PM +0800, Yanan Wang wrote:
> After dirty-logging is stopped for a VM configured with huge mappings,
> KVM will recover the table mappings back to block mappings. As we only
> replace the existing page tables with a block entry and the cacheability
> has not been changed, the cache maintenance opreations can be skipped.
> 
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> ---
>  arch/arm64/kvm/mmu.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 8e8549ea1d70..37b427dcbc4f 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -744,7 +744,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  {
>  	int ret = 0;
>  	bool write_fault, writable, force_pte = false;
> -	bool exec_fault;
> +	bool exec_fault, adjust_hugepage;
>  	bool device = false;
>  	unsigned long mmu_seq;
>  	struct kvm *kvm = vcpu->kvm;
> @@ -872,12 +872,18 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  		mark_page_dirty(kvm, gfn);
>  	}
>  
> -	if (fault_status != FSC_PERM && !device)
> +	/*
> +	 * There is no necessity to perform cache maintenance operations if we
> +	 * will only replace the existing table mappings with a block mapping.
> +	 */
> +	adjust_hugepage = fault_granule < vma_pagesize ? true : false;

nit: you don't need the '? true : false' part

That said, your previous patch checks for 'fault_granule > vma_pagesize',
so I'm not sure the local variable helps all that much here because it
obscures the size checks in my opinion. It would be more straight-forward
if we could structure the logic as:


	if (fault_granule < vma_pagesize) {

	} else if (fault_granule > vma_page_size) {

	} else {

	}

With some comments describing what we can infer about the memcache and cache
maintenance requirements for each case.

Will

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will@kernel.org>
To: Yanan Wang <wangyanan55@huawei.com>
Cc: kvm@vger.kernel.org, Marc Zyngier <maz@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH 2/2] KVM: arm64: Skip the cache flush when coalescing tables into a block
Date: Mon, 8 Mar 2021 16:34:55 +0000	[thread overview]
Message-ID: <20210308163454.GA26561@willie-the-truck> (raw)
In-Reply-To: <20210125141044.380156-3-wangyanan55@huawei.com>

On Mon, Jan 25, 2021 at 10:10:44PM +0800, Yanan Wang wrote:
> After dirty-logging is stopped for a VM configured with huge mappings,
> KVM will recover the table mappings back to block mappings. As we only
> replace the existing page tables with a block entry and the cacheability
> has not been changed, the cache maintenance opreations can be skipped.
> 
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> ---
>  arch/arm64/kvm/mmu.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 8e8549ea1d70..37b427dcbc4f 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -744,7 +744,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  {
>  	int ret = 0;
>  	bool write_fault, writable, force_pte = false;
> -	bool exec_fault;
> +	bool exec_fault, adjust_hugepage;
>  	bool device = false;
>  	unsigned long mmu_seq;
>  	struct kvm *kvm = vcpu->kvm;
> @@ -872,12 +872,18 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  		mark_page_dirty(kvm, gfn);
>  	}
>  
> -	if (fault_status != FSC_PERM && !device)
> +	/*
> +	 * There is no necessity to perform cache maintenance operations if we
> +	 * will only replace the existing table mappings with a block mapping.
> +	 */
> +	adjust_hugepage = fault_granule < vma_pagesize ? true : false;

nit: you don't need the '? true : false' part

That said, your previous patch checks for 'fault_granule > vma_pagesize',
so I'm not sure the local variable helps all that much here because it
obscures the size checks in my opinion. It would be more straight-forward
if we could structure the logic as:


	if (fault_granule < vma_pagesize) {

	} else if (fault_granule > vma_page_size) {

	} else {

	}

With some comments describing what we can infer about the memcache and cache
maintenance requirements for each case.

Will
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will@kernel.org>
To: Yanan Wang <wangyanan55@huawei.com>
Cc: Marc Zyngier <maz@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	James Morse <james.morse@arm.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, wanghaibin.wang@huawei.com,
	yuzenghui@huawei.com
Subject: Re: [PATCH 2/2] KVM: arm64: Skip the cache flush when coalescing tables into a block
Date: Mon, 8 Mar 2021 16:34:55 +0000	[thread overview]
Message-ID: <20210308163454.GA26561@willie-the-truck> (raw)
In-Reply-To: <20210125141044.380156-3-wangyanan55@huawei.com>

On Mon, Jan 25, 2021 at 10:10:44PM +0800, Yanan Wang wrote:
> After dirty-logging is stopped for a VM configured with huge mappings,
> KVM will recover the table mappings back to block mappings. As we only
> replace the existing page tables with a block entry and the cacheability
> has not been changed, the cache maintenance opreations can be skipped.
> 
> Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
> ---
>  arch/arm64/kvm/mmu.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
> index 8e8549ea1d70..37b427dcbc4f 100644
> --- a/arch/arm64/kvm/mmu.c
> +++ b/arch/arm64/kvm/mmu.c
> @@ -744,7 +744,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  {
>  	int ret = 0;
>  	bool write_fault, writable, force_pte = false;
> -	bool exec_fault;
> +	bool exec_fault, adjust_hugepage;
>  	bool device = false;
>  	unsigned long mmu_seq;
>  	struct kvm *kvm = vcpu->kvm;
> @@ -872,12 +872,18 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  		mark_page_dirty(kvm, gfn);
>  	}
>  
> -	if (fault_status != FSC_PERM && !device)
> +	/*
> +	 * There is no necessity to perform cache maintenance operations if we
> +	 * will only replace the existing table mappings with a block mapping.
> +	 */
> +	adjust_hugepage = fault_granule < vma_pagesize ? true : false;

nit: you don't need the '? true : false' part

That said, your previous patch checks for 'fault_granule > vma_pagesize',
so I'm not sure the local variable helps all that much here because it
obscures the size checks in my opinion. It would be more straight-forward
if we could structure the logic as:


	if (fault_granule < vma_pagesize) {

	} else if (fault_granule > vma_page_size) {

	} else {

	}

With some comments describing what we can infer about the memcache and cache
maintenance requirements for each case.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-08 16:36 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25 14:10 [PATCH 0/2] Performance improvement about cache flush Yanan Wang
2021-01-25 14:10 ` Yanan Wang
2021-01-25 14:10 ` Yanan Wang
2021-01-25 14:10 ` [PATCH 1/2] KVM: arm64: Distinguish cases of allocating memcache more precisely Yanan Wang
2021-01-25 14:10   ` Yanan Wang
2021-01-25 14:10   ` Yanan Wang
2021-03-08 16:35   ` Will Deacon
2021-03-08 16:35     ` Will Deacon
2021-03-08 16:35     ` Will Deacon
2021-01-25 14:10 ` [PATCH 2/2] KVM: arm64: Skip the cache flush when coalescing tables into a block Yanan Wang
2021-01-25 14:10   ` Yanan Wang
2021-01-25 14:10   ` Yanan Wang
2021-03-08 16:34   ` Will Deacon [this message]
2021-03-08 16:34     ` Will Deacon
2021-03-08 16:34     ` Will Deacon
2021-03-09  8:34     ` wangyanan (Y)
2021-03-09  8:34       ` wangyanan (Y)
2021-03-09  8:34       ` wangyanan (Y)
2021-03-09  8:43       ` Marc Zyngier
2021-03-09  8:43         ` Marc Zyngier
2021-03-09  8:43         ` Marc Zyngier
2021-03-09  9:02         ` wangyanan (Y)
2021-03-09  9:02           ` wangyanan (Y)
2021-03-09  9:02           ` wangyanan (Y)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210308163454.GA26561@willie-the-truck \
    --to=will@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=wangyanan55@huawei.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.