aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuzuki K Poulose <suzuki.poulose@arm.com>2023-04-05 12:09:05 +0100
committerWill Deacon <will@kernel.org>2023-04-06 15:26:59 +0100
commit77b108c6a6f1c66fb7f60a80d17596bb80bda8ad (patch)
tree98cda87984783e9681156d95cdec878fb85a8276
parent9b46ebc561d3cc3bb54a350e4eed94d24562f347 (diff)
downloadkvmtool-77b108c6a6f1c66fb7f60a80d17596bb80bda8ad.tar.gz
arm: Do not add padding alignment for hugetlbfs backed memory
The arm code tries to align the memory allocation size to 2M to potentially make use of the transparent hugepages. But this would be problematic if we try to allocate from the hugetlbfs, where the allocation size could be more than 2M. Given we support upto 1G, let use leave it to the user to align the requested memory when hugetlbfs is used. Without the patch: $ echo 1 > /sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages $ mount -t hugetlbfs -o pagesize=1G none /root/hugemem/ $ lkvm run -m 1024 --hugetlbfs /root/hugemem/ ... # lkvm run -k ... -m 1024 -c 6 Fatal: Can't ftruncate for mem mapping size 1075838976 Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Acked-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230405110905.669217-1-suzuki.poulose@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arm/kvm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arm/kvm.c b/arm/kvm.c
index d51cc15d..9f958232 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -37,7 +37,9 @@ void kvm__init_ram(struct kvm *kvm)
* 2M trumps 64K, so let's go with that.
*/
kvm->ram_size = kvm->cfg.ram_size;
- kvm->arch.ram_alloc_size = kvm->ram_size + SZ_2M;
+ kvm->arch.ram_alloc_size = kvm->ram_size;
+ if (!kvm->cfg.hugetlbfs_path)
+ kvm->arch.ram_alloc_size += SZ_2M;
kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm,
kvm->cfg.hugetlbfs_path,
kvm->arch.ram_alloc_size);