From: David Hildenbrand <david@redhat.com>
To: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>, kvm@vger.kernel.org
Cc: borntraeger@de.ibm.com, cohuck@redhat.com, pbonzini@redhat.com,
schwidefsky@de.ibm.com
Subject: Re: [PATCH v1 1/2] KVM: s390x: some utility functions for migration
Date: Tue, 16 Jan 2018 19:03:00 +0100 [thread overview]
Message-ID: <6c3eeea0-5cf7-442e-8882-a86d79b0fc7d@redhat.com> (raw)
In-Reply-To: <1516035791-10609-2-git-send-email-imbrenda@linux.vnet.ibm.com>
On 15.01.2018 18:03, Claudio Imbrenda wrote:
> These are some utilty functions that will be used later on for storage
> attributes migration.
>
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
> ---
> arch/s390/kvm/kvm-s390.c | 40 ++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
>
> diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> index 6f17031..100ea15 100644
> --- a/arch/s390/kvm/kvm-s390.c
> +++ b/arch/s390/kvm/kvm-s390.c
> @@ -764,6 +764,14 @@ static void kvm_s390_sync_request_broadcast(struct kvm *kvm, int req)
> kvm_s390_sync_request(req, vcpu);
> }
>
> +static inline unsigned long *_cmma_bitmap(struct kvm_memory_slot *ms)
I think you can get rid of the "_" here. And ususally we use two _ ?
> +{
> + unsigned long long len;
> +
> + len = kvm_dirty_bitmap_bytes(ms) / sizeof(*ms->dirty_bitmap);
return (void *) ms->dirty_bitmap + kvm_dirty_bitmap_bytes(ms);
?
> + return ms->dirty_bitmap + len;
> +}
> +
> /*
> * Must be called with kvm->srcu held to avoid races on memslots, and with
> * kvm->lock to avoid races with ourselves and kvm_s390_vm_stop_migration.
> @@ -1512,6 +1520,38 @@ static long kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
> #define KVM_S390_CMMA_SIZE_MAX ((u32)KVM_S390_SKEYS_MAX)
>
> /*
> + * Similar to gfn_to_memslot, but returns a memslot also when the address falls
> + * in a hole. In that case a memslot near the hole is returned.
> + */
> +static int gfn_to_memslot_approx(struct kvm *kvm, gfn_t gfn)
> +{
> + struct kvm_memslots *slots = kvm_memslots(kvm);
> + int start = 0, end = slots->used_slots;
> + int slot = atomic_read(&slots->lru_slot);
> + struct kvm_memory_slot *memslots = slots->memslots;
> +
> + if (gfn >= memslots[slot].base_gfn &&
> + gfn < memslots[slot].base_gfn + memslots[slot].npages)
> + return slot;
> +
> + while (start < end) {
> + slot = start + (end - start) / 2;
> +
> + if (gfn >= memslots[slot].base_gfn)
> + end = slot;
> + else
> + start = slot + 1;
> + }
> +
> + if (gfn >= memslots[start].base_gfn &&
> + gfn < memslots[start].base_gfn + memslots[start].npages) {
> + atomic_set(&slots->lru_slot, start);
> + }
> +
> + return start;
> +}
This looks ugly, hope we can avoid this ....
> +
> +/*
> * This function searches for the next page with dirty CMMA attributes, and
> * saves the attributes in the buffer up to either the end of the buffer or
> * until a block of at least KVM_S390_MAX_BIT_DISTANCE clean bits is found;
>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2018-01-16 18:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-15 17:03 [PATCH v1 0/2] KVM: s390: fix storage attributes migration Claudio Imbrenda
2018-01-15 17:03 ` [PATCH v1 1/2] KVM: s390x: some utility functions for migration Claudio Imbrenda
2018-01-16 18:03 ` David Hildenbrand [this message]
2018-01-17 9:50 ` Claudio Imbrenda
2018-01-17 12:16 ` Christian Borntraeger
2018-01-15 17:03 ` [PATCH v1 2/2] KVM: s390: Fix storage attributes migration with memory slots Claudio Imbrenda
2018-01-17 9:17 ` Janosch Frank
2018-01-17 12:10 ` Claudio Imbrenda
2018-01-17 13:01 ` Janosch Frank
2018-01-17 17:37 ` Claudio Imbrenda
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=6c3eeea0-5cf7-442e-8882-a86d79b0fc7d@redhat.com \
--to=david@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=imbrenda@linux.vnet.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=schwidefsky@de.ibm.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 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).