[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate boo
From: |
Peter Xu |
Subject: |
Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap() |
Date: |
Tue, 9 Mar 2021 15:04:51 -0500 |
On Mon, Mar 08, 2021 at 04:05:57PM +0100, David Hildenbrand wrote:
> Let's introduce a new set of flags that abstract mmap logic and replace
> our current set of bools, to prepare for another flag.
>
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
> include/qemu/mmap-alloc.h | 17 +++++++++++------
> softmmu/physmem.c | 8 +++++---
> util/mmap-alloc.c | 14 +++++++-------
> util/oslib-posix.c | 3 ++-
> 4 files changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h
> index 456ff87df1..55664ea9f3 100644
> --- a/include/qemu/mmap-alloc.h
> +++ b/include/qemu/mmap-alloc.h
> @@ -6,6 +6,15 @@ size_t qemu_fd_getpagesize(int fd);
>
> size_t qemu_mempath_getpagesize(const char *mem_path);
>
> +/* 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)
Sorry to speak late - I just noticed that is_pmem can actually be converted too
with "MAP_SYNC | MAP_SHARED_VALIDATE". We can even define MAP_PMEM_EXTRA for
use within qemu if we want. Then we can avoid one layer of QEMU_RAM_* by
directly using MAP_*, I think?
--
Peter Xu
- [PATCH v3 00/12] RAM_NORESERVE, MAP_NORESERVE and hostmem "reserve" property, David Hildenbrand, 2021/03/08
- [PATCH v3 01/12] softmmu/physmem: Mark shared anonymous memory RAM_SHARED, David Hildenbrand, 2021/03/08
- [PATCH v3 02/12] softmmu/physmem: Fix ram_block_discard_range() to handle shared anonymous memory, David Hildenbrand, 2021/03/08
- [PATCH v3 03/12] softmmu/physmem: Fix qemu_ram_remap() to handle shared anonymous memory, David Hildenbrand, 2021/03/08
- [PATCH v3 04/12] util/mmap-alloc: Factor out calculation of the pagesize for the guard page, David Hildenbrand, 2021/03/08
- [PATCH v3 05/12] util/mmap-alloc: Factor out reserving of a memory region to mmap_reserve(), David Hildenbrand, 2021/03/08
- [PATCH v3 06/12] util/mmap-alloc: Factor out activating of memory to mmap_activate(), David Hildenbrand, 2021/03/08
- [PATCH v3 07/12] softmmu/memory: Pass ram_flags into qemu_ram_alloc_from_fd(), David Hildenbrand, 2021/03/08
- [PATCH v3 08/12] softmmu/memory: Pass ram_flags into memory_region_init_ram_shared_nomigrate(), David Hildenbrand, 2021/03/08
- [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), David Hildenbrand, 2021/03/08
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(),
Peter Xu <=
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), David Hildenbrand, 2021/03/09
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), Peter Xu, 2021/03/09
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), David Hildenbrand, 2021/03/10
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), David Hildenbrand, 2021/03/10
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), David Hildenbrand, 2021/03/10
- Re: [PATCH v3 09/12] util/mmap-alloc: Pass flags instead of separate bools to qemu_ram_mmap(), Peter Xu, 2021/03/10
[PATCH v3 10/12] memory: introduce RAM_NORESERVE and wire it up in qemu_ram_mmap(), David Hildenbrand, 2021/03/08
[PATCH v3 11/12] util/mmap-alloc: Support RAM_NORESERVE via MAP_NORESERVE, David Hildenbrand, 2021/03/08
[PATCH v3 12/12] hostmem: Wire up RAM_NORESERVE via "reserve" property, David Hildenbrand, 2021/03/08