[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200124104943.6abkjzegmewnoeiv@kamzik.brq.redhat.com>
Date: Fri, 24 Jan 2020 11:49:43 +0100
From: Andrew Jones <drjones@...hat.com>
To: Ben Gardon <bgardon@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Paolo Bonzini <pbonzini@...hat.com>,
Cannon Matthews <cannonmatthews@...gle.com>,
Peter Xu <peterx@...hat.com>, Peter Shier <pshier@...gle.com>,
Oliver Upton <oupton@...gle.com>
Subject: Re: [PATCH v4 07/10] KVM: selftests: Support multiple vCPUs in
demand paging test
On Thu, Jan 23, 2020 at 10:04:33AM -0800, Ben Gardon wrote:
...
> -static struct kvm_vm *create_vm(enum vm_guest_mode mode, uint32_t vcpuid,
> - uint64_t extra_mem_pages, void *guest_code)
> +#define PAGE_SHIFT_4K 12
> +#define PTES_PER_4K_PT 512
> +
> +static struct kvm_vm *create_vm(enum vm_guest_mode mode, int vcpus,
> + uint64_t vcpu_memory_bytes)
> {
> struct kvm_vm *vm;
> - uint64_t extra_pg_pages = extra_mem_pages / 512 * 2;
> + uint64_t pages = DEFAULT_GUEST_PHY_PAGES;
> +
> + /* Account for a few pages per-vCPU for stacks */
> + pages += DEFAULT_STACK_PGS * vcpus;
> +
> + /*
> + * Reserve twice the ammount of memory needed to map the test region and
> + * the page table / stacks region, at 4k, for page tables. Do the
> + * calculation with 4K page size: the smallest of all archs. (e.g., 64K
> + * page size guest will need even less memory for page tables).
> + */
> + pages += (2 * pages) / PTES_PER_4K_PT;
> + pages += ((2 * vcpus * vcpu_memory_bytes) >> PAGE_SHIFT_4K) /
> + PTES_PER_4K_PT;
pages needs to be rounded up to the next multiple of 16 in order for this
to work on aarch64 machines with 64k pages.
Thanks,
drew
Powered by blists - more mailing lists