[CRIU] [PATCH 1/6] criu: pagemap: drop put_pagemap
Mike Rapoport
rppt at linux.vnet.ibm.com
Thu Sep 8 00:39:07 PDT 2016
With in-memory pagemap put_pagemap is not required because it does not
frees any resources. Minor modifications to get_pagemap and init_pagemaps
allow proper bookkeeping without put_pagemap.
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/cr-dedup.c | 13 ++++---------
criu/include/pagemap.h | 2 --
criu/mem.c | 3 ---
criu/pagemap.c | 14 ++++----------
criu/shmem.c | 3 ---
criu/uffd.c | 3 ---
6 files changed, 8 insertions(+), 30 deletions(-)
diff --git a/criu/cr-dedup.c b/criu/cr-dedup.c
index 527a6b6..cc44152 100644
--- a/criu/cr-dedup.c
+++ b/criu/cr-dedup.c
@@ -82,22 +82,17 @@ static int cr_dedup_one_pagemap(int id, int flags)
if (!prp)
goto exit;
- ret = pr.get_pagemap(&pr, &iov);
- if (ret <= 0)
- goto exit;
-
while (1) {
+ ret = pr.get_pagemap(&pr, &iov);
+ if (ret <= 0)
+ goto exit;
+
pr_debug("dedup iovec base=%p, len=%zu\n", iov.iov_base, iov.iov_len);
if (!pr.pe->in_parent) {
ret = dedup_one_iovec(prp, &iov);
if (ret)
goto exit;
}
-
- pr.put_pagemap(&pr);
- ret = pr.get_pagemap(&pr, &iov);
- if (ret <= 0)
- goto exit;
}
exit:
pr.close(&pr);
diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
index 81ff96b..f45b2a9 100644
--- a/criu/include/pagemap.h
+++ b/criu/include/pagemap.h
@@ -48,8 +48,6 @@ struct page_read {
int (*get_pagemap)(struct page_read *, struct iovec *iov);
/* reads page from current pagemap */
int (*read_pages)(struct page_read *, unsigned long vaddr, int nr, void *);
- /* stop working on current pagemap */
- void (*put_pagemap)(struct page_read *);
void (*close)(struct page_read *);
void (*skip_pages)(struct page_read *, unsigned long len);
int (*seek_page)(struct page_read *pr, unsigned long vaddr, bool warn);
diff --git a/criu/mem.c b/criu/mem.c
index 63acec3..1c01a09 100644
--- a/criu/mem.c
+++ b/criu/mem.c
@@ -804,9 +804,6 @@ static int restore_priv_vma_content(struct pstree_item *t)
}
}
-
- if (pr.put_pagemap)
- pr.put_pagemap(&pr);
}
err_read:
diff --git a/criu/pagemap.c b/criu/pagemap.c
index 86591e4..d8fe5b0 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -121,16 +121,12 @@ int dedup_one_iovec(struct page_read *pr, struct iovec *iov)
return 0;
}
-static void put_pagemap(struct page_read *pr)
-{
- pr->curr_pme++;
-}
-
static int get_pagemap(struct page_read *pr, struct iovec *iov)
{
PagemapEntry *pe;
for (;;) {
+ pr->curr_pme++;
if (pr->curr_pme >= pr->nr_pmes)
return 0;
@@ -138,7 +134,6 @@ static int get_pagemap(struct page_read *pr, struct iovec *iov)
if (!pe->zero)
break;
- put_pagemap(pr);
}
pagemap2iovec(pe, iov);
@@ -189,7 +184,6 @@ static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr,
if (iov_end <= vaddr) {
skip_pagemap_pages(pr, iov_end - pr->cvaddr);
- put_pagemap(pr);
new_pagemap:
ret = get_pagemap(pr, &iov);
if (ret <= 0)
@@ -331,7 +325,7 @@ static void reset_pagemap(struct page_read *pr)
{
pr->cvaddr = 0;
pr->pi_off = 0;
- pr->curr_pme = 0;
+ pr->curr_pme = -1;
pr->pe = NULL;
/* FIXME: take care of bunch */
@@ -398,7 +392,8 @@ static int init_pagemaps(struct page_read *pr)
if (!pr->pmes)
return -1;
- pr->nr_pmes = pr->curr_pme = 0;
+ pr->nr_pmes = 0;
+ pr->curr_pme = -1;
while (1) {
int ret = pb_read_one_eof(pr->pmi, &pr->pmes[pr->nr_pmes],
@@ -486,7 +481,6 @@ int open_page_read_at(int dfd, int id, struct page_read *pr, int pr_flags)
}
pr->get_pagemap = get_pagemap;
- pr->put_pagemap = put_pagemap;
pr->read_pages = read_pagemap_page;
pr->close = close_page_read;
pr->skip_pages = skip_pagemap_pages;
diff --git a/criu/shmem.c b/criu/shmem.c
index c422b4c..341e3bc 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -452,9 +452,6 @@ static int restore_shmem_content(void *addr, struct shmem_info *si)
break;
pr.read_pages(&pr, vaddr, nr_pages, addr + vaddr);
-
- if (pr.put_pagemap)
- pr.put_pagemap(&pr);
}
pr.close(&pr);
diff --git a/criu/uffd.c b/criu/uffd.c
index cf03c31..97cacea 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -490,9 +490,6 @@ static int collect_uffd_pages(struct page_read *pr, struct lazy_pages_info *lpi)
base = (unsigned long) iov.iov_base;
pr_debug("iov.iov_base 0x%lx (%ld pages)\n", base, nr_pages);
- if (pr->put_pagemap)
- pr->put_pagemap(pr);
-
for (i = 0; i < nr_pages; i++) {
bool uffd_page = false;
base = (unsigned long) iov.iov_base + (i * ps);
--
1.9.1
More information about the CRIU
mailing list