mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 07:15:31 +00:00
vma: Keep track of lonest vma in list and sum of its lengths
I will have to push some sort of map of pages to dump into parasite. For this, I need to have estimation of how much memory I'd need for than in parasite args. These two values will help with it. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
@@ -119,6 +119,7 @@ int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list)
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
pr_info("Collected, longest ares %lu bytes\n", vma_area_list->longest);
|
||||
pr_info_vma_list(&vma_area_list->h);
|
||||
|
||||
pr_info("----------------------------------------\n");
|
||||
|
@@ -70,7 +70,7 @@ static int restore_task_with_children(void *);
|
||||
static int sigreturn_restore(pid_t pid, CoreEntry *core);
|
||||
static int prepare_restorer_blob(void);
|
||||
|
||||
static VM_AREA_LIST(rst_vmas);
|
||||
static VM_AREA_LIST(rst_vmas); /* XXX .longest is NOT tracked for this guy */
|
||||
|
||||
static int shmem_remap(void *old_addr, void *new_addr, unsigned long size)
|
||||
{
|
||||
|
@@ -219,6 +219,8 @@ void close_cr_fdset(struct cr_fdset **cr_fdset);
|
||||
struct vm_area_list {
|
||||
struct list_head h;
|
||||
unsigned nr;
|
||||
unsigned long priv_size; /* nr of pages in private VMAs */
|
||||
unsigned long longest; /* nr of pages in longest VMA */
|
||||
};
|
||||
|
||||
#define VM_AREA_LIST(name) struct vm_area_list name = { .h = LIST_HEAD_INIT(name.h), .nr = 0, }
|
||||
|
@@ -179,6 +179,8 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
|
||||
FILE *smaps = NULL;
|
||||
|
||||
vma_area_list->nr = 0;
|
||||
vma_area_list->longest = 0;
|
||||
vma_area_list->priv_size = 0;
|
||||
INIT_LIST_HEAD(&vma_area_list->h);
|
||||
|
||||
smaps = fopen_proc(pid, "smaps");
|
||||
@@ -345,6 +347,13 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
|
||||
done:
|
||||
list_add_tail(&vma_area->list, &vma_area_list->h);
|
||||
vma_area_list->nr++;
|
||||
if (privately_dump_vma(vma_area)) {
|
||||
unsigned long pages;
|
||||
|
||||
pages = vma_area_len(vma_area) / PAGE_SIZE;
|
||||
vma_area_list->priv_size += pages;
|
||||
vma_area_list->longest = max(vma_area_list->longest, pages);
|
||||
}
|
||||
}
|
||||
|
||||
vma_area = NULL;
|
||||
|
Reference in New Issue
Block a user