kvmtool: ARM: madvise mergeable and hugepage separately
PATCH 1/1 kvmtool: ARM: madvise mergeable and hugepage separately
The madvise behavior is not a bit field and hence can not be or'ed. Also madvise_behavior_valid checks the flag using a case statement hence only one behavior is supposed to be supplied. Call madvise twice, once for MERGEABLE and once for HUGEPAGE.
--- arm/kvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arm/kvm.c +4 -1
@@ -80,7 +80,10 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) SZ_2M);madvise (kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, -MADV_MERGEABLE |MADV_HUGEPAGE ); +MADV_MERGEABLE ); + +madvise (kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, +MADV_HUGEPAGE );/* Create the virtual GIC. */ if (gic__create (kvm, kvm->cfg.arch.irqchip))
Signature · 1 line
2.9.0
Hi,
Quoted 4 lines · Stefan Agner
The madvise behavior is not a bit field and hence can not be or'ed. Also
madvise_behavior_validchecks the flag using a case statement hence only one behavior is supposed to be supplied. Call madvise twice, once for MERGEABLE and once for HUGEPAGE.
thanks for that catch! Indeed we are only setting HUGEPAGE right now, dropping MERGEABLE due to the OR'ing.
Cheers,
Andre.
Quoted 23 lines
Signed-off-by Stefan Agner <[email protected]>--- arm/kvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arm/kvm.c +4
-1@@ -80,7 +80,10 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) SZ_2M);madvise (kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, -MADV_MERGEABLE |MADV_HUGEPAGE ); +MADV_MERGEABLE ); + +madvise (kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, +MADV_HUGEPAGE );/* Create the virtual GIC. */ if (gic__create (kvm, kvm->cfg.arch.irqchip))
Suzuki K Poulose
reviewerQuoted 15 lines · Stefan Agner
The madvise behavior is not a bit field and hence can not be or'ed. Also
madvise_behavior_validchecks the flag using a case statement hence only one behavior is supposed to be supplied. Call madvise twice, once for MERGEABLE and once for HUGEPAGE.Signed-off-by Stefan Agner <[email protected]>--- arm/kvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)arm/kvm.c +0
-0
arm/kvm.c void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) · line 86
Quoted 8 lines
arm/kvm.c +4
-1@@ -80,7 +80,10 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) SZ_2M);madvise (kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, -MADV_MERGEABLE |MADV_HUGEPAGE ); +MADV_MERGEABLE ); + +madvise (kvm->arch.ram_alloc_start, kvm->arch.ram_alloc_size, +MADV_HUGEPAGE );
Should we also do a MADV_DONTDUMP for guest RAM pages ? This is a security option to strip off any guest data in case of crash in kvmtool. This could also help to reduce the size of the kvmtool core dumps. I think Qemu does this already.
Suzuki