[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/27] postcopy: enhance ram_block_discard_range for
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [PULL 16/27] postcopy: enhance ram_block_discard_range for hugepages |
Date: |
Tue, 28 Feb 2017 12:40:45 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
Unfortunately madvise DONTNEED doesn't work on hugepagetlb
so use fallocate(FALLOC_FL_PUNCH_HOLE)
qemu_fd_getpagesize only sets the page based off a file
if the file is from hugetlbfs.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
exec.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/exec.c b/exec.c
index 8ac556a..24cdf64 100644
--- a/exec.c
+++ b/exec.c
@@ -46,6 +46,11 @@
#include "sysemu/xen-mapcache.h"
#include "trace-root.h"
+#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
+#include <fcntl.h>
+#include <linux/falloc.h>
+#endif
+
#endif
#include "exec/cpu-all.h"
#include "qemu/rcu_queue.h"
@@ -3326,12 +3331,23 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t
start, size_t length)
errno = ENOTSUP; /* If we are missing MADVISE etc */
+ if (rb->page_size == qemu_host_page_size) {
#if defined(CONFIG_MADVISE)
- /* Note: We need the madvise MADV_DONTNEED behaviour of definitely
- * freeing the page.
- */
- ret = madvise(host_startaddr, length, MADV_DONTNEED);
+ /* Note: We need the madvise MADV_DONTNEED behaviour of definitely
+ * freeing the page.
+ */
+ ret = madvise(host_startaddr, length, MADV_DONTNEED);
#endif
+ } else {
+ /* Huge page case - unfortunately it can't do DONTNEED, but
+ * it can do the equivalent by FALLOC_FL_PUNCH_HOLE in the
+ * huge page file.
+ */
+#ifdef CONFIG_FALLOCATE_PUNCH_HOLE
+ ret = fallocate(rb->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
+ start, length);
+#endif
+ }
if (ret) {
ret = -errno;
error_report("ram_block_discard_range: Failed to discard range "
--
2.9.3
- [Qemu-devel] [PULL 05/27] tests/test-vmstate.c: test array of ptr with null, (continued)
- [Qemu-devel] [PULL 05/27] tests/test-vmstate.c: test array of ptr with null, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 06/27] tests/test-vmstate.c: test array of ptr to primitive, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 07/27] vmstate-static-checker: update white list with spapr_pci, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 08/27] migrate: Introduce a 'dc->vmsd' check to avoid segfault for --only-migratable, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 09/27] migration: fix id leak regression, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 10/27] migration: Update docs to discourage version bumps, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 12/27] postcopy: Transmit ram size summary word, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 11/27] migration: fix use-after-free of to_dst_file, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 13/27] postcopy: Transmit and compare individual page sizes, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 14/27] postcopy: Chunk discards for hugepages, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 16/27] postcopy: enhance ram_block_discard_range for hugepages,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [PULL 17/27] postcopy: Record largest page size, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 15/27] exec: ram_block_discard_range, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 18/27] postcopy: Plumb pagesize down into place helpers, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 19/27] postcopy: Use temporary for placing zero huge pages, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 20/27] postcopy: Load huge pages in one go, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 21/27] postcopy: Mask fault addresses to huge page boundary, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 22/27] postcopy: Send whole huge pages, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 23/27] postcopy: Allow hugepages, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 24/27] postcopy: Update userfaultfd.h header, Dr. David Alan Gilbert (git), 2017/02/28
- [Qemu-devel] [PULL 25/27] postcopy: Check for userfault+hugepage feature, Dr. David Alan Gilbert (git), 2017/02/28