Commit 40dcaf88 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

parasite: page dump -- Map pages huge bitmap inplace

In case if there is the VMA which has a huge size (4,8,16 G)
then the prealoocated bitmap space won't be enough to track
all pages. Thus we call for system help invoking mmap() call
with bitmap length needed.

We simply assume that if such big VMA present the node has enough
memory to provide us space for pages huge bitmap.
Reported-by: 's avatarAdrian Reber <adrian@lisas.de>
Tested-by: 's avatarAdrian Reber <adrian@lisas.de>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ccbbb18a
......@@ -137,6 +137,7 @@ static int dump_pages(struct parasite_dump_pages_args *args)
{
unsigned long nrpages, pfn, length;
unsigned long prot_old, prot_new;
bool bigmap = false;
u64 *map, off;
int ret = -1;
......@@ -154,9 +155,20 @@ static int dump_pages(struct parasite_dump_pages_args *args)
*/
map = brk_alloc(length);
if (!map) {
/*
* Lets try allocate the bitmap inplace. If the VMA
* is that big we assume the node has enough physical
* memory.
*/
map = (u64 *)sys_mmap(NULL, length,
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if ((long)(void *)map > TASK_SIZE) {
ret = -ENOMEM;
goto err;
}
bigmap = true;
}
off = pfn * sizeof(*map);
off = sys_lseek(fd_pagemap, off, SEEK_SET);
......@@ -226,7 +238,10 @@ static int dump_pages(struct parasite_dump_pages_args *args)
ret = 0;
err_free:
if (!bigmap)
brk_free(length);
else
sys_munmap(map, length);
err:
return ret;
}
......
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