[CRIU] [PATCHv2 4/9] shmem: pass anonymous shmem pagemap to add_shmem_area
Eugene Batalov
eabatalov89 at gmail.com
Tue Dec 22 07:22:49 PST 2015
From: Fyodor Bocharov <bocharovfedor at gmail.com>
So we would be able to analyze pagemap bits for each
anonymous shmem page and decide on its dirtiness and usage
by dumpee process.
Signed-off-by: Fyodor Bocharov <fbocharov at yandex.ru>
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
cr-dump.c | 2 --
include/shmem.h | 3 ++-
mem.c | 29 ++++++++++++++++++-----------
shmem.c | 4 +++-
4 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index 6cafd64..679ea16 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -455,8 +455,6 @@ static int dump_task_mm(pid_t pid, const struct proc_pid_stat *stat,
ret = 0;
else if (vma_entry_is(vma, VMA_AREA_SYSVIPC))
ret = check_sysvipc_map_dump(pid, vma);
- else if (vma_entry_is(vma, VMA_ANON_SHARED))
- ret = add_shmem_area(pid, vma);
else if (vma_entry_is(vma, VMA_FILE_PRIVATE) ||
vma_entry_is(vma, VMA_FILE_SHARED))
ret = dump_filemap(pid, vma_area, imgset);
diff --git a/include/shmem.h b/include/shmem.h
index 47dd0fd..066b5c3 100644
--- a/include/shmem.h
+++ b/include/shmem.h
@@ -1,6 +1,7 @@
#ifndef __CR_SHMEM_H__
#define __CR_SHMEM_H__
+#include "asm/int.h"
#include "lock.h"
#include "protobuf/vma.pb-c.h"
@@ -10,6 +11,6 @@ extern void show_saved_shmems(void);
extern int get_shmem_fd(int pid, VmaEntry *vi);
extern int cr_dump_shmem(void);
-extern int add_shmem_area(pid_t pid, VmaEntry *vma);
+extern int add_shmem_area(pid_t pid, VmaEntry *vma, u64 *map);
#endif /* __CR_SHMEM_H__ */
diff --git a/mem.c b/mem.c
index 78cc2fe..c48a22b 100644
--- a/mem.c
+++ b/mem.c
@@ -246,6 +246,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
struct vma_area *vma_area;
struct page_xfer xfer = { .parent = NULL };
int ret = -1;
+ unsigned long pmc_size;
pr_info("\n");
pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid.real);
@@ -262,8 +263,9 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
* Step 0 -- prepare
*/
+ pmc_size = max(vma_area_list->priv_longest, vma_area_list->shared_longest);
if (pmc_init(&pmc, ctl->pid.real, &vma_area_list->h,
- vma_area_list->priv_longest * PAGE_SIZE))
+ pmc_size * PAGE_SIZE))
return -1;
ret = -1;
@@ -293,22 +295,27 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
u64 off = 0;
u64 *map;
- if (!vma_area_is_private(vma_area, kdat.task_size))
+ if (!vma_area_is_private(vma_area, kdat.task_size) &&
+ !vma_area_is(vma_area, VMA_ANON_SHARED))
continue;
map = pmc_get_map(&pmc, vma_area);
if (!map)
goto out_xfer;
+ if (vma_area_is(vma_area, VMA_ANON_SHARED))
+ ret = add_shmem_area(ctl->pid.real, vma_area->e, map);
+ else {
again:
- ret = generate_iovs(vma_area, pp, map, &off, xfer.parent);
- if (ret == -EAGAIN) {
- BUG_ON(pp_ret);
-
- ret = dump_pages(pp, ctl, args, &xfer);
- if (ret)
- goto out_xfer;
- page_pipe_reinit(pp);
- goto again;
+ ret = generate_iovs(vma_area, pp, map, &off, xfer.parent);
+ if (ret == -EAGAIN) {
+ BUG_ON(pp_ret);
+
+ ret = dump_pages(pp, ctl, args, &xfer);
+ if (ret)
+ goto out_xfer;
+ page_pipe_reinit(pp);
+ goto again;
+ }
}
if (ret < 0)
goto out_xfer;
diff --git a/shmem.c b/shmem.c
index b2900f4..dcbe19f 100644
--- a/shmem.c
+++ b/shmem.c
@@ -12,6 +12,7 @@
#include "page-xfer.h"
#include "rst-malloc.h"
#include "vma.h"
+#include "mem.h"
#include "protobuf.h"
#include "protobuf/pagemap.pb-c.h"
@@ -301,10 +302,11 @@ static struct shmem_info_dump *shmem_find(struct shmem_info_dump **chain,
return NULL;
}
-int add_shmem_area(pid_t pid, VmaEntry *vma)
+int add_shmem_area(pid_t pid, VmaEntry *vma, u64 *map)
{
struct shmem_info_dump *si, **chain;
unsigned long size = vma->pgoff + (vma->end - vma->start);
+ (void)map;
chain = &shmems_hash[vma->shmid % SHMEM_HASH_SIZE];
si = shmem_find(chain, vma->shmid);
--
1.9.1
More information about the CRIU
mailing list