From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>,
kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
cohuck@redhat.com, david@redhat.com, schwidefsky@de.ibm.com,
frankja@linux.vnet.ibm.com
Subject: Re: [PATCH v2 1/2] KVM: s390x: some utility functions for migration
Date: Thu, 25 Jan 2018 17:37:22 +0100 [thread overview]
Message-ID: <20180125163721.GE19884@flask> (raw)
In-Reply-To: <51b530d8-7016-9004-9adb-e749b7611858@de.ibm.com>
2018-01-22 10:08+0100, Christian Borntraeger:
> On 01/18/2018 01:56 PM, 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 | 32 ++++++++++++++++++++++++++++++++
> > arch/s390/kvm/kvm-s390.h | 6 ++++++
> > 2 files changed, 38 insertions(+)
> >
> > diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
> > index 6f17031..5a69334 100644
> > --- a/arch/s390/kvm/kvm-s390.c
> > +++ b/arch/s390/kvm/kvm-s390.c
> > @@ -1512,6 +1512,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
>
> gfn_to_memslot returns a memslot, this returns an int?
>
> > + * in a hole. In that case a memslot near the hole is returned.
>
> Can you please clarify that statement? Will it be the slot that is closest
> in terms of bytes or what? Maybe also provide a use case and an example
> > + */
> > +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);
> > + }
>
> Another question for Paolo/Radim. In case we need such function, would
> it be better in common code (kvm_main.c)
Please keep it in s390 and don't do it in the best case.
The function doesn't look reusable. If a gfn isn't in a slot, then we
shouldn't be using slots to work with it.
I don't understand why CMMA need adresses in the gaps, so I can't
provide a good idea here -- maybe we can add slots where needed?
next prev parent reply other threads:[~2018-01-25 16:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 12:56 [PATCH v2 0/2] KVM: s390: fix storage attributes migration Claudio Imbrenda
2018-01-18 12:56 ` [PATCH v2 1/2] KVM: s390x: some utility functions for migration Claudio Imbrenda
2018-01-22 9:08 ` Christian Borntraeger
2018-01-22 9:12 ` Christian Borntraeger
2018-01-22 9:49 ` Claudio Imbrenda
2018-01-25 16:37 ` Radim Krčmář [this message]
2018-01-25 18:15 ` Claudio Imbrenda
2018-01-18 12:56 ` [PATCH v2 2/2] KVM: s390: Fix storage attributes migration with memory slots Claudio Imbrenda
2018-01-19 15:41 ` Christian Borntraeger
2018-01-22 14:26 ` Christian Borntraeger
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=20180125163721.GE19884@flask \
--to=rkrcmar@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.vnet.ibm.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).