v2 mem: if no parent image persists, can't rely on it

here was bug cause if e.g.: iterative snapshots are made and
between two of them new process in process tree was created,
it can have pages which are non dirty, and won't save them
into image. but there is no parent image for it.

pages which are non soft-dirty appear if process with some pages
in non dirty state forks, child will inherit those pte's
and if child don't write to those pages, they will be still in non
soft-dirty state when next dump comes.

also this bug was not catched because of error in zdtm, look 3/3

v2: simplify, add more justification in commit message.

Signed-off-by: Tikhomirov Pavel <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Tikhomirov Pavel 2014-04-16 17:05:00 +04:00 committed by Pavel Emelyanov
parent 8df879941d
commit e01dc7faa6

6
mem.c
View file

@ -106,7 +106,7 @@ static inline bool page_in_parent(u64 pme)
* the memory contents is present in the pagent image set.
*/
static int generate_iovs(struct vma_area *vma, struct page_pipe *pp, u64 *map, u64 *off)
static int generate_iovs(struct vma_area *vma, struct page_pipe *pp, u64 *map, u64 *off, bool has_parent)
{
u64 *at = &map[PAGE_PFN(*off)];
unsigned long pfn, nr_to_scan;
@ -130,7 +130,7 @@ static int generate_iovs(struct vma_area *vma, struct page_pipe *pp, u64 *map, u
* page. The latter would be checked in page-xfer.
*/
if (page_in_parent(at[pfn])) {
if (has_parent && page_in_parent(at[pfn])) {
ret = page_pipe_add_hole(pp, vaddr);
pages[0]++;
} else {
@ -282,7 +282,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
if (!map)
goto out_xfer;
again:
ret = generate_iovs(vma_area, pp, map, &off);
ret = generate_iovs(vma_area, pp, map, &off, xfer.parent);
if (ret == -EAGAIN) {
BUG_ON(pp_ret);