[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC 07/21] ramblock: Cache file offset for file-backed ramblocks
From: |
Peter Xu |
Subject: |
[PATCH RFC 07/21] ramblock: Cache file offset for file-backed ramblocks |
Date: |
Tue, 17 Jan 2023 17:09:00 -0500 |
This value was only used for mmap() when we want to map at a specific
offset of the file for memory. To be prepared that we might do another map
upon the same range for whatever reason, cache the offset so we know how to
map again on the same range.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/exec/ramblock.h | 5 +++++
softmmu/physmem.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h
index adc03df59c..76cd0812c8 100644
--- a/include/exec/ramblock.h
+++ b/include/exec/ramblock.h
@@ -41,6 +41,11 @@ struct RAMBlock {
QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers;
int fd;
size_t page_size;
+ /*
+ * Cache for file offset to map the ramblock. Only used for
+ * file-backed ramblocks.
+ */
+ off_t file_offset;
/* dirty bitmap used during migration */
unsigned long *bmap;
/* bitmap of already received pages in postcopy */
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index a4fb129d8f..aa1a7466e5 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -1543,6 +1543,8 @@ static void *file_ram_alloc(RAMBlock *block,
uint32_t qemu_map_flags;
void *area;
+ /* Remember the offset just in case we'll need to map the range again */
+ block->file_offset = offset;
block->page_size = qemu_fd_getpagesize(fd);
if (block->mr->align % block->page_size) {
error_setg(errp, "alignment 0x%" PRIx64
--
2.37.3
- Re: [PATCH RFC 03/21] physmem: Add qemu_ram_is_hugetlb(), (continued)
- [PATCH RFC 04/21] madvise: Include linux/mman.h under linux-headers/, Peter Xu, 2023/01/17
- [PATCH RFC 05/21] madvise: Add QEMU_MADV_SPLIT, Peter Xu, 2023/01/17
- [PATCH RFC 06/21] madvise: Add QEMU_MADV_COLLAPSE, Peter Xu, 2023/01/17
- [PATCH RFC 07/21] ramblock: Cache file offset for file-backed ramblocks,
Peter Xu <=
- [PATCH RFC 08/21] ramblock: Cache the length to do file mmap() on ramblocks, Peter Xu, 2023/01/17
- [PATCH RFC 01/21] update linux headers, Peter Xu, 2023/01/17
- [PATCH RFC 10/21] ramblock: Add ramblock_file_map(), Peter Xu, 2023/01/17