[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/10] dump: simplify a bit kdump get_next_page()
From: |
marcandre . lureau |
Subject: |
[PULL 09/10] dump: simplify a bit kdump get_next_page() |
Date: |
Thu, 6 Oct 2022 19:34:28 +0400 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
This should be functionally equivalent, but slightly easier to read,
with simplified paths and checks at the end of the function.
The following patch is a major rewrite to get rid of the assert().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
dump/dump.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index a905316fe5..b55a497c42 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -1132,17 +1132,11 @@ static bool get_next_page(GuestPhysBlock **blockptr,
uint64_t *pfnptr,
if (!block) {
block = QTAILQ_FIRST(&s->guest_phys_blocks.head);
*blockptr = block;
- assert((block->target_start & ~target_page_mask) == 0);
- assert((block->target_end & ~target_page_mask) == 0);
- *pfnptr = dump_paddr_to_pfn(s, block->target_start);
- if (bufptr) {
- *bufptr = block->host_addr;
- }
- return true;
+ addr = block->target_start;
+ } else {
+ addr = dump_pfn_to_paddr(s, *pfnptr + 1);
}
-
- *pfnptr = *pfnptr + 1;
- addr = dump_pfn_to_paddr(s, *pfnptr);
+ assert(block != NULL);
if ((addr >= block->target_start) &&
(addr + s->dump_info.page_size <= block->target_end)) {
@@ -1154,12 +1148,13 @@ static bool get_next_page(GuestPhysBlock **blockptr,
uint64_t *pfnptr,
if (!block) {
return false;
}
- assert((block->target_start & ~target_page_mask) == 0);
- assert((block->target_end & ~target_page_mask) == 0);
- *pfnptr = dump_paddr_to_pfn(s, block->target_start);
+ addr = block->target_start;
buf = block->host_addr;
}
+ assert((block->target_start & ~target_page_mask) == 0);
+ assert((block->target_end & ~target_page_mask) == 0);
+ *pfnptr = dump_paddr_to_pfn(s, addr);
if (bufptr) {
*bufptr = buf;
}
--
2.37.3
- [PULL 00/10] Dump patches, marcandre . lureau, 2022/10/06
- [PULL 01/10] dump: Replace opaque DumpState pointer with a typed one, marcandre . lureau, 2022/10/06
- [PULL 02/10] dump: Rename write_elf_loads to write_elf_phdr_loads, marcandre . lureau, 2022/10/06
- [PULL 03/10] dump: Refactor dump_iterate and introduce dump_filter_memblock_*(), marcandre . lureau, 2022/10/06
- [PULL 04/10] dump: Rework get_start_block, marcandre . lureau, 2022/10/06
- [PULL 05/10] dump: Rework filter area variables, marcandre . lureau, 2022/10/06
- [PULL 06/10] dump: Rework dump_calculate_size function, marcandre . lureau, 2022/10/06
- [PULL 09/10] dump: simplify a bit kdump get_next_page(),
marcandre . lureau <=
- [PULL 07/10] dump: Split elf header functions into prepare and write, marcandre . lureau, 2022/10/06
- [PULL 08/10] dump: Rename write_elf*_phdr_note to prepare_elf*_phdr_note, marcandre . lureau, 2022/10/06
- [PULL 10/10] dump: fix kdump to work over non-aligned blocks, marcandre . lureau, 2022/10/06
- Re: [PULL 00/10] Dump patches, Stefan Hajnoczi, 2022/10/11