diff mbox series

[1/3] Revert "selftests: kvm: make allocation of extra memory take effect"

Message ID 20210608233816.423958-2-zhenzhong.duan@intel.com (mailing list archive)
State New
Headers show
Series Restore extra_mem_pages and add slot0_mem_pages | expand

Commit Message

Duan, Zhenzhong June 8, 2021, 11:38 p.m. UTC
This reverts commit 39fe2fc96694164723846fccf6caa42c3aee6ec4.

Parameter extra_mem_pages in vm_create_default() is used to calculate
the page table size for all the memory chunks.
Real memory allocation for non-slot0 memory happens by extra call of
vm_userspace_mem_region_add() outside of vm_create_default().

The reverted commit changed above meaning of extra_mem_pages as extra
slot0 memory size. This way made the page table size calculations
open coded in separate test.

Link: https://lkml.org/lkml/2021/6/3/551
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 tools/testing/selftests/kvm/lib/kvm_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Jones June 8, 2021, 8:21 a.m. UTC | #1
On Wed, Jun 09, 2021 at 07:38:14AM +0800, Zhenzhong Duan wrote:
> This reverts commit 39fe2fc96694164723846fccf6caa42c3aee6ec4.
> 
> Parameter extra_mem_pages in vm_create_default() is used to calculate
> the page table size for all the memory chunks.
> Real memory allocation for non-slot0 memory happens by extra call of
> vm_userspace_mem_region_add() outside of vm_create_default().
> 
> The reverted commit changed above meaning of extra_mem_pages as extra
> slot0 memory size. This way made the page table size calculations
> open coded in separate test.
> 
> Link: https://lkml.org/lkml/2021/6/3/551
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>  tools/testing/selftests/kvm/lib/kvm_util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
> index 28e528c19d28..63418df921f0 100644
> --- a/tools/testing/selftests/kvm/lib/kvm_util.c
> +++ b/tools/testing/selftests/kvm/lib/kvm_util.c
> @@ -320,7 +320,7 @@ struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
>  	 */
>  	uint64_t vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus;
>  	uint64_t extra_pg_pages = (extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2;
> -	uint64_t pages = DEFAULT_GUEST_PHY_PAGES + extra_mem_pages + vcpu_pages + extra_pg_pages;
> +	uint64_t pages = DEFAULT_GUEST_PHY_PAGES + vcpu_pages + extra_pg_pages;
>  	struct kvm_vm *vm;
>  	int i;
>  
> -- 
> 2.25.1
>

Reviewed-by: Andrew Jones <drjones@redhat.com>
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 28e528c19d28..63418df921f0 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -320,7 +320,7 @@  struct kvm_vm *vm_create_with_vcpus(enum vm_guest_mode mode, uint32_t nr_vcpus,
 	 */
 	uint64_t vcpu_pages = (DEFAULT_STACK_PGS + num_percpu_pages) * nr_vcpus;
 	uint64_t extra_pg_pages = (extra_mem_pages + vcpu_pages) / PTES_PER_MIN_PAGE * 2;
-	uint64_t pages = DEFAULT_GUEST_PHY_PAGES + extra_mem_pages + vcpu_pages + extra_pg_pages;
+	uint64_t pages = DEFAULT_GUEST_PHY_PAGES + vcpu_pages + extra_pg_pages;
 	struct kvm_vm *vm;
 	int i;