LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: David Hildenbrand <david@redhat.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Cornelia Huck" <cohuck@redhat.com>,
	"Andrew Jones" <drjones@redhat.com>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-s390@vger.kernel.org
Subject: Re: [RFC PATCH 2/4] KVM: selftests: Align memory region addresses to 1M on s390x
Date: Thu, 16 May 2019 13:59:50 +0200	[thread overview]
Message-ID: <395e1b02-09b7-9420-33e1-a3abb36282f0@redhat.com> (raw)
In-Reply-To: <d9c383ef-6f4b-4f51-b627-7565a67005d3@redhat.com>

On 16/05/2019 13.30, David Hildenbrand wrote:
> On 16.05.19 13:12, Thomas Huth wrote:
>> On s390x, there is a constraint that memory regions have to be aligned
>> to 1M (or running the VM will fail). Introduce a new "alignment" variable
>> in the vm_userspace_mem_region_add() function which now can be used for
>> both, huge page and s390x alignment requirements.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>  tools/testing/selftests/kvm/lib/kvm_util.c | 21 +++++++++++++++++-----
>>  1 file changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
>> index 8d63ccb93e10..64a0da6efe3d 100644
>> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
>> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
>> @@ -559,6 +559,7 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
>>  	unsigned long pmem_size = 0;
>>  	struct userspace_mem_region *region;
>>  	size_t huge_page_size = KVM_UTIL_PGS_PER_HUGEPG * vm->page_size;
>> +	size_t alignment;
>>  
>>  	TEST_ASSERT((guest_paddr % vm->page_size) == 0, "Guest physical "
>>  		"address not on a page boundary.\n"
>> @@ -608,9 +609,20 @@ void vm_userspace_mem_region_add(struct kvm_vm *vm,
>>  	TEST_ASSERT(region != NULL, "Insufficient Memory");
>>  	region->mmap_size = npages * vm->page_size;
>>  
>> -	/* Enough memory to align up to a huge page. */
>> +#ifdef __s390x__
>> +	/* On s390x, the host address must be aligned to 1M (due to PGSTEs) */
>> +	alignment = 0x100000;
> 
> This corresponds to huge_page_size, maybe you can exploit this fact here.
> 
> Something like
> 
> alignment = 1;
> 
> /* On s390x, the host address must always be aligned to the THP size */
> #ifndef __s390x__
> if (src_type == VM_MEM_SRC_ANONYMOUS_THP)
> #endif
> 	alignment = huge_page_size;
> 
> Maybe in a nicer fashion. Not sure.

Hmm, but if I've got your explanation on IRC right, it's rather a
coincidence that the huge page size matches the alignment requirements
for KVM memslots, isn't it? So I think the code would look rather
confusing if I'd try to shorten it this way...?

 Thomas

  reply	other threads:[~2019-05-16 12:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-16 11:12 [RFC PATCH 0/4] KVM selftests for s390x Thomas Huth
2019-05-16 11:12 ` [RFC PATCH 1/4] KVM: selftests: Guard struct kvm_vcpu_events with __KVM_HAVE_VCPU_EVENTS Thomas Huth
2019-05-16 11:22   ` David Hildenbrand
2019-05-20  7:12   ` Christian Borntraeger
2019-05-20  8:08     ` Thomas Huth
2019-05-20  8:13       ` Christian Borntraeger
2019-05-16 11:12 ` [RFC PATCH 2/4] KVM: selftests: Align memory region addresses to 1M on s390x Thomas Huth
2019-05-16 11:30   ` David Hildenbrand
2019-05-16 11:59     ` Thomas Huth [this message]
2019-05-16 12:08       ` David Hildenbrand
2019-05-16 11:12 ` [RFC PATCH 3/4] KVM: selftests: Add processor code for s390x Thomas Huth
2019-05-16 11:12 ` [RFC PATCH 4/4] KVM: selftests: Add the sync_regs test " Thomas Huth
2019-05-20 11:19   ` Paolo Bonzini
2019-05-23 10:56   ` Andrew Jones
2019-05-23 11:19     ` Thomas Huth
2019-05-20 11:20 ` [RFC PATCH 0/4] KVM selftests " Paolo Bonzini
2019-05-20 11:30   ` Thomas Huth
2019-05-20 11:43     ` Paolo Bonzini
2019-05-22  8:44       ` Andrew Jones

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=395e1b02-09b7-9420-33e1-a3abb36282f0@redhat.com \
    --to=thuth@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=drjones@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=shuah@kernel.org \
    --subject='Re: [RFC PATCH 2/4] KVM: selftests: Align memory region addresses to 1M on s390x' \
    /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).