LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: "Maciej S. Szmigiero" <mail@maciej.szmigiero.name>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Sean Christopherson <seanjc@google.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Huacai Chen <chenhuacai@kernel.org>,
	Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>,
	Paul Mackerras <paulus@ozlabs.org>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	David Hildenbrand <david@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>, Joerg Roedel <joro@8bytes.org>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 10/13] KVM: s390: Introduce kvm_s390_get_gfn_end()
Date: Wed, 18 Aug 2021 16:31:14 +0200	[thread overview]
Message-ID: <20210818163114.7f45646e@p-imbrenda> (raw)
In-Reply-To: <5de2569b7a6c7df38c5fdd3baf88e6d987f42776.1628871413.git.maciej.szmigiero@oracle.com>

On Fri, 13 Aug 2021 21:33:23 +0200
"Maciej S. Szmigiero" <mail@maciej.szmigiero.name> wrote:

> From: "Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>
> 
> And use it where s390 code would just access the memslot with the highest
> gfn directly.
> 
> No functional change intended.
> 
> Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  arch/s390/kvm/kvm-s390.c |  2 +-
>  arch/s390/kvm/kvm-s390.h | 12 ++++++++++++
>  arch/s390/kvm/pv.c       |  4 +---
>  3 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 6b3f05086fae..9c3a85793ba4 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -2006,7 +2006,7 @@ static int kvm_s390_get_cmma(struct kvm *kvm, struct kvm_s390_cmma_log *args,
>  	if (!ms)
>  		return 0;
>  	next_gfn = kvm_s390_next_dirty_cmma(slots, cur_gfn + 1);
> -	mem_end = slots->memslots[0].base_gfn + slots->memslots[0].npages;
> +	mem_end = kvm_s390_get_gfn_end(slots);
>  
>  	while (args->count < bufsize) {
>  		hva = gfn_to_hva(kvm, cur_gfn);
> diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
> index 9fad25109b0d..5787b12aff7e 100644
> --- a/arch/s390/kvm/kvm-s390.h
> +++ b/arch/s390/kvm/kvm-s390.h
> @@ -208,6 +208,18 @@ static inline int kvm_s390_user_cpu_state_ctrl(struct kvm *kvm)
>  	return kvm->arch.user_cpu_state_ctrl != 0;
>  }
>  
> +/* get the end gfn of the last (highest gfn) memslot */
> +static inline unsigned long kvm_s390_get_gfn_end(struct kvm_memslots *slots)
> +{
> +	struct kvm_memory_slot *ms;
> +
> +	if (WARN_ON(!slots->used_slots))
> +		return 0;
> +
> +	ms = slots->memslots;
> +	return ms->base_gfn + ms->npages;
> +}
> +
>  /* implemented in pv.c */
>  int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);
>  int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc);
> diff --git a/arch/s390/kvm/pv.c b/arch/s390/kvm/pv.c
> index c8841f476e91..e51cccfded25 100644
> --- a/arch/s390/kvm/pv.c
> +++ b/arch/s390/kvm/pv.c
> @@ -117,7 +117,6 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
>  	unsigned long base = uv_info.guest_base_stor_len;
>  	unsigned long virt = uv_info.guest_virt_var_stor_len;
>  	unsigned long npages = 0, vlen = 0;
> -	struct kvm_memory_slot *memslot;
>  
>  	kvm->arch.pv.stor_var = NULL;
>  	kvm->arch.pv.stor_base = __get_free_pages(GFP_KERNEL_ACCOUNT, get_order(base));
> @@ -131,8 +130,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
>  	 * Slots are sorted by GFN
>  	 */
>  	mutex_lock(&kvm->slots_lock);
> -	memslot = kvm_memslots(kvm)->memslots;
> -	npages = memslot->base_gfn + memslot->npages;
> +	npages = kvm_s390_get_gfn_end(kvm_memslots(kvm));
>  	mutex_unlock(&kvm->slots_lock);
>  
>  	kvm->arch.pv.guest_len = npages * PAGE_SIZE;


  reply	other threads:[~2021-08-18 14:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 19:33 [PATCH v4 00/13] KVM: Scalable memslots implementation Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 01/13] KVM: x86: Cache total page count to avoid traversing the memslot array Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 02/13] KVM: x86: Don't call kvm_mmu_change_mmu_pages() if the count hasn't changed Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 03/13] KVM: Add "old" memslot parameter to kvm_arch_prepare_memory_region() Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 04/13] KVM: x86: Move n_memslots_pages recalc " Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 05/13] KVM: Integrate gfn_to_memslot_approx() into search_memslots() Maciej S. Szmigiero
2021-08-18 14:29   ` Claudio Imbrenda
2021-08-13 19:33 ` [PATCH v4 06/13] KVM: Move WARN on invalid memslot index to update_memslots() Maciej S. Szmigiero
2021-08-18 14:29   ` Claudio Imbrenda
2021-08-18 14:35   ` David Hildenbrand
2021-08-18 21:43     ` Maciej S. Szmigiero
2021-08-20  9:27       ` David Hildenbrand
2021-08-13 19:33 ` [PATCH v4 07/13] KVM: Just resync arch fields when slots_arch_lock gets reacquired Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 08/13] KVM: Resolve memslot ID via a hash table instead of via a static array Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 09/13] KVM: Use interval tree to do fast hva lookup in memslots Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 10/13] KVM: s390: Introduce kvm_s390_get_gfn_end() Maciej S. Szmigiero
2021-08-18 14:31   ` Claudio Imbrenda [this message]
2021-08-13 19:33 ` [PATCH v4 11/13] KVM: Keep memslots in tree-based structures instead of array-based ones Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 12/13] KVM: Optimize gfn lookup in kvm_zap_gfn_range() Maciej S. Szmigiero
2021-08-13 19:33 ` [PATCH v4 13/13] KVM: Optimize overlapping memslots check Maciej S. Szmigiero

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=20210818163114.7f45646e@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=aleksandar.qemu.devel@gmail.com \
    --cc=borntraeger@de.ibm.com \
    --cc=chenhuacai@kernel.org \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=james.morse@arm.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@maciej.szmigiero.name \
    --cc=maz@kernel.org \
    --cc=paulus@ozlabs.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --subject='Re: [PATCH v4 10/13] KVM: s390: Introduce kvm_s390_get_gfn_end()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).