[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 09/13] util/mmap-alloc: Implement resizable mmaps
From: |
Richard Henderson |
Subject: |
Re: [PATCH v1 09/13] util/mmap-alloc: Implement resizable mmaps |
Date: |
Thu, 6 Feb 2020 12:08:47 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 2/3/20 6:31 PM, David Hildenbrand wrote:
> +void *qemu_ram_mmap_resize(void *ptr, int fd, size_t old_size, size_t
> new_size,
> + bool shared, bool is_pmem)
> {
> const size_t pagesize = mmap_pagesize(fd);
>
> /* we can only map whole pages */
> - size = QEMU_ALIGN_UP(size, pagesize);
> + old_size = QEMU_ALIGN_UP(old_size, pagesize);
> + new_size = QEMU_ALIGN_UP(new_size, pagesize);
> +
> + /* we support actually resizable memory regions only on Linux */
> + if (old_size < new_size) {
> + /* populate the missing piece into the reserved area */
> + ptr = mmap_populate(ptr + old_size, new_size - old_size, fd,
> old_size,
> + shared, is_pmem);
> + } else if (old_size > new_size) {
> + /* discard this piece, keeping the area reserved (should never fail)
> */
> + ptr = mmap_reserve(ptr + new_size, old_size - new_size, fd);
> + }
> + return ptr;
> +}
What does the return value indicate?
Is it just for != MAP_FAILED?
Would we be better off with an assert? There's the comment re mmap_reserve,
but I can't see why mmap_populate should fail either.
Assuming an assert isn't viable, are we better off with a boolean return? With
an Error **ptr?
r~
- Re: [PATCH v1 04/13] exec: Drop "shared" parameter from ram_block_add(), (continued)
- [PATCH v1 05/13] util/mmap-alloc: Factor out calculation of pagesize to mmap_pagesize(), David Hildenbrand, 2020/02/03
- [PATCH v1 07/13] util/mmap-alloc: Factor out populating of memory to mmap_populate(), David Hildenbrand, 2020/02/03
- [PATCH v1 10/13] numa: Introduce ram_block_notify_resized() and ram_block_notifiers_support_resize(), David Hildenbrand, 2020/02/03
- [PATCH v1 09/13] util/mmap-alloc: Implement resizable mmaps, David Hildenbrand, 2020/02/03
- Re: [PATCH v1 09/13] util/mmap-alloc: Implement resizable mmaps,
Richard Henderson <=
- Re: [PATCH v1 09/13] util/mmap-alloc: Implement resizable mmaps, Murilo Opsfelder Araújo, 2020/02/06
- [PATCH v1 08/13] util/mmap-alloc: Prepare for resizable mmaps, David Hildenbrand, 2020/02/03
- Re: [PATCH v1 08/13] util/mmap-alloc: Prepare for resizable mmaps, David Hildenbrand, 2020/02/06