lkml.org 
[lkml]   [2022]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/6] KVM: selftests: memslot_perf_test: Support variable guest page size
On 18.10.2022 02:51, Gavin Shan wrote:
> On 10/18/22 8:46 AM, Gavin Shan wrote:
>> On 10/18/22 5:31 AM, Maciej S. Szmigiero wrote:
>>> On 14.10.2022 09:19, Gavin Shan wrote:
>>>> The test case is obviously broken on aarch64 because non-4KB guest
>>>> page size is supported. The guest page size on aarch64 could be 4KB,
>>>> 16KB or 64KB.
>>>>
>>>> This supports variable guest page size, mostly for aarch64.
>>>>
>>>>    - The host determines the guest page size when virtual machine is
>>>>      created. The value is also passed to guest through the synchronization
>>>>      area.
>>>>
>>>>    - The number of guest pages are unknown until the virtual machine
>>>>      is to be created. So all the related macros are dropped. Instead,
>>>>      their values are dynamically calculated based on the guest page
>>>>      size.
>>>>
>>>>    - The static checks on memory sizes and pages becomes dependent
>>>>      on guest page size, which is unknown until the virtual machine
>>>>      is about to be created. So all the static checks are converted
>>>>      to dynamic checks, done in check_memory_sizes().
>>>>
>>>>    - As the address passed to madvise() should be aligned to host page,
>>>>      the size of page chunk is automatically selected, other than one
>>>>      page.
>>>>
>>>>    - All other changes included in this patch are almost mechanical
>>>>      replacing '4096' with 'guest_page_size'.
>>>>
>>>> Signed-off-by: Gavin Shan <gshan@redhat.com>
>>>> ---
>>>>   .../testing/selftests/kvm/memslot_perf_test.c | 191 +++++++++++-------
>>>>   1 file changed, 115 insertions(+), 76 deletions(-)
>>>>
>>>> diff --git a/tools/testing/selftests/kvm/memslot_perf_test.c b/tools/testing/selftests/kvm/memslot_perf_test.c
>>>> index d5aa9148f96f..d587bd952ff9 100644
>>>> --- a/tools/testing/selftests/kvm/memslot_perf_test.c
>>>> +++ b/tools/testing/selftests/kvm/memslot_perf_test.c
(...)
>>>> @@ -77,8 +61,7 @@ static_assert(MEM_TEST_UNMAP_SIZE_PAGES %
>>>>    * for the total size of 25 pages.
>>>>    * Hence, the maximum size here is 50 pages.
>>>>    */
>>>> -#define MEM_TEST_MOVE_SIZE_PAGES    (50)
>>>> -#define MEM_TEST_MOVE_SIZE        (MEM_TEST_MOVE_SIZE_PAGES * 4096)
>>>> +#define MEM_TEST_MOVE_SIZE        0x32000
>>>
>>> The above number seems less readable than an explicit value of 50 pages.
>>>
>>> In addition to that, it's 50 pages only with 4k page size, so at least
>>> the comment above needs to be updated to reflect this fact.
>>>
>>
>> Yeah, I will change the comments like below in next revision.
>>
>>   /*
>>    * When running this test with 32k memslots, actually 32763 excluding
>>    * the reserved memory slot 0, the memory for each slot is 0x4000 bytes.
>>    * The last slot contains 0x19000 bytes memory. Hence, the maximum size
>>    * here is 0x32000 bytes.
>>    */
>>
>
> I will replace those numbers with readable ones like below :)
>
> /*
>  * When running this test with 32k memslots, actually 32763 excluding
>  * the reserved memory slot 0, the memory for each slot is 16KB. The
>  * last slot contains 100KB memory with the remaining 84KB. Hence,
>  * the maximum size is double of that (200KB)
>  */

Still, these numbers are for x86, which has KVM_INTERNAL_MEM_SLOTS
defined as 3.

As far as I can see aarch64 has KVM_INTERNAL_MEM_SLOTS equal to 0, so
this arch has 32766 slot available for the test memory.

Quick calculations show that this will result in 112 KiB of memory in
the last slot for 4 KiB page size (while for 64 KiB page size the
maximum slot count for this test is 8192 anyway - not counting slot 0).

> Thanks,
> Gavin
>

Thanks,
Maciej

\
 
 \ /
  Last update: 2022-10-18 17:59    [W:0.152 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site