[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] pdumper 77b7416: Keep the DS_DISCARDABLE address space res
From: |
Daniel Colascione |
Subject: |
[Emacs-diffs] pdumper 77b7416: Keep the DS_DISCARDABLE address space reserved |
Date: |
Wed, 14 Feb 2018 14:25:54 -0500 (EST) |
branch: pdumper
commit 77b74161caa07e34870982971b674a5f59a69929
Author: Daniel Colascione <address@hidden>
Commit: Daniel Colascione <address@hidden>
Keep the DS_DISCARDABLE address space reserved
---
configure.ac | 3 +++
src/pdumper.c | 36 +++++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 2b5f050..a3595a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4071,6 +4071,9 @@ dnl No need to check for posix_memalign if aligned_alloc
works.
AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
+# Dump loading
+AC_CHECK_FUNCS([posix_madvise])
+
dnl Cannot use AC_CHECK_FUNCS
AC_CACHE_CHECK([for __builtin_frame_address],
[emacs_cv_func___builtin_frame_address],
diff --git a/src/pdumper.c b/src/pdumper.c
index 6007f4a..a36ec3a 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4251,6 +4251,40 @@ struct dump_memory_map {
void *private;
};
+/* Mark the pages as unneeded, potentially zeroing them, without
+ releasing the address space reservation. */
+static void
+dump_discard_mem (void *mem, size_t size)
+{
+ if (VM_SUPPORTED == VM_MS_WINDOWS)
+ {
+#if VM_SUPPORTED == VM_MS_WINDOWS
+ /* Discard COWed pages. */
+ (void) VirtualFree (mem, size, MEM_DECOMMIT);
+ /* Release the commit charge for the mapping. */
+ (void) VirtualProtect (mem, size, PAGE_NOACCESS, NULL);
+#endif
+ }
+ else if (VM_SUPPORTED == VM_POSIX)
+ {
+#ifdef HAVE_POSIX_MADVISE
+ /* Discard COWed pages. */
+ (void) posix_madvise (mem, size, POSIX_MADV_DONTNEED);
+#endif
+ /* Release the commit charge for the mapping. */
+ (void) mprotect (mem, size, PROT_NONE);
+ }
+ else
+ /* Do nothing */;
+}
+
+static void
+dump_mmap_discard_contents (struct dump_memory_map *map)
+{
+ if (map->mapping)
+ dump_discard_mem (map->mapping, map->spec.size);
+}
+
static void
dump_mmap_reset (struct dump_memory_map *map)
{
@@ -5027,7 +5061,7 @@ pdumper_load (const char *dump_filename)
dump_do_all_dump_relocations (header, dump_base);
dump_do_all_emacs_relocations (header, dump_base);
- dump_mmap_release (§ions[DS_DISCARDABLE]);
+ dump_mmap_discard_contents (§ions[DS_DISCARDABLE]);
for (int i = 0; i < ARRAYELTS (sections); ++i)
dump_mmap_reset (§ions[i]);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] pdumper 77b7416: Keep the DS_DISCARDABLE address space reserved,
Daniel Colascione <=