Commit 605220e7 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Cyrill Gorcunov

crtools: Cleanup the 'whether I should dump this page' decision

Just introduce a helper for further patches.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@gmail.com>
parent 9eeb0037
......@@ -76,6 +76,11 @@ static void sys_write_msg(const char *msg)
sys_write(1, msg, size);
}
static inline int should_dump_page(struct vma_entry *vmae, unsigned char mincore_flags)
{
return (mincore_flags & PAGE_RSS) || vma_entry_is(vmae, VMA_DUMP_ALL);
}
/*
* This is the main page dumping routine, it's executed
* inside a victim process space.
......@@ -87,7 +92,6 @@ static int dump_pages(parasite_args_cmd_dumppages_t *args)
unsigned long prot_old, prot_new;
unsigned char *map_brk = NULL;
unsigned char *map;
bool dump_all = false;
args->nrpages_dumped = 0;
prot_old = prot_new = 0;
......@@ -130,8 +134,6 @@ static int dump_pages(parasite_args_cmd_dumppages_t *args)
}
}
dump_all = vma_entry_is(&args->vma_entry, VMA_DUMP_ALL);
/*
* Try to change page protection if needed so we would
* be able to dump contents.
......@@ -169,7 +171,7 @@ static int dump_pages(parasite_args_cmd_dumppages_t *args)
for (pfn = 0; pfn < nrpages; pfn++) {
unsigned long vaddr, written;
if ((map[pfn] & PAGE_RSS) || dump_all) {
if (should_dump_page(&args->vma_entry, map[pfn])) {
/*
* That's the optimized write of
* page_entry structure, see image.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment