qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 8/9] util/mmap-alloc: Support RAM_NORESERVE via MAP_NORESE


From: David Hildenbrand
Subject: Re: [PATCH v2 8/9] util/mmap-alloc: Support RAM_NORESERVE via MAP_NORESERVE
Date: Fri, 5 Mar 2021 17:24:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0

On 05.03.21 16:51, Peter Xu wrote:
On Fri, Mar 05, 2021 at 04:44:36PM +0100, David Hildenbrand wrote:
On 05.03.21 16:42, Peter Xu wrote:
On Fri, Mar 05, 2021 at 11:16:33AM +0100, David Hildenbrand wrote:
+#define OVERCOMMIT_MEMORY_PATH "/proc/sys/vm/overcommit_memory"
+static bool map_noreserve_effective(int fd, bool readonly, bool shared)
+{

[...]

@@ -184,8 +251,7 @@ void *qemu_ram_mmap(int fd,
       size_t offset, total;
       void *ptr, *guardptr;
-    if (noreserve) {
-        error_report("Skipping reservation of swap space is not supported");
+    if (noreserve && !map_noreserve_effective(fd, shared, readonly)) {

Need to switch "shared" & "readonly"?

Indeed, interestingly it has the same effect (as we don't have anonymous
read-only memory in QEMU :) )

But note there is still a "g_assert(!shared || fd >= 0);" inside.. :)


(wouldn't have happened with flags  ... hmm)

Right.


I'll probably go with

/* Map PROT_READ instead of PROT_READ|PROT_WRITE. */
#define QEMU_RAM_MMAP_READONLY      (1 << 0)

/* Map MAP_SHARED instead of MAP_PRIVATE. */
#define QEMU_RAM_MMAP_SHARED        (1 << 1)

/* Map MAP_SYNC|MAP_SHARED_VALIDATE if possible, fallback and warn otherwise. */
#define QEMU_RAM_MMAP_PMEM          (1 << 2)


for qemu_ram_mmap(). qemu_anon_ram_alloc() will still have bools, but
there it will at least be only two.

--
Thanks,

David / dhildenb




reply via email to

[Prev in Thread] Current Thread [Next in Thread]