[CRIU] [PATCH 2/2] pagemap: drop pagemap2iovec and iovec2pagemap
Mike Rapoport
rppt at linux.vnet.ibm.com
Mon Dec 5 06:04:01 PST 2016
The PagemapEntry and struct iovec are quite interchangeable.
PagemapEntry can be used directly in the few places that converted it to
struct iovec.
The only place that used iovec2pagemap can be switched to open-coded
assignments without really hurting code readability.
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/cr-dedup.c | 5 ++---
criu/include/pagemap.h | 2 --
criu/page-xfer.c | 9 ++++-----
criu/pagemap.c | 22 +++-------------------
4 files changed, 9 insertions(+), 29 deletions(-)
diff --git a/criu/cr-dedup.c b/criu/cr-dedup.c
index b17fa20..199d8b9 100644
--- a/criu/cr-dedup.c
+++ b/criu/cr-dedup.c
@@ -72,7 +72,6 @@ static int cr_dedup_one_pagemap(int id, int flags)
int ret;
struct page_read pr;
struct page_read * prp;
- struct iovec iov;
flags |= PR_MOD;
ret = open_page_read(id, &pr, flags);
@@ -88,8 +87,8 @@ static int cr_dedup_one_pagemap(int id, int flags)
if (ret <= 0)
goto exit;
- pagemap2iovec(pr.pe, &iov);
- pr_debug("dedup iovec base=%p, len=%zu\n", iov.iov_base, iov.iov_len);
+ pr_debug("dedup iovec base=%"PRIx64", len=%zu\n",
+ pr.pe->vaddr, pagemap_len(pr.pe));
if (!pagemap_in_parent(pr.pe)) {
ret = dedup_one_iovec(prp, pr.pe->vaddr,
pagemap_len(pr.pe));
diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h
index 89d465e..48c8d4b 100644
--- a/criu/include/pagemap.h
+++ b/criu/include/pagemap.h
@@ -103,8 +103,6 @@ struct page_read {
extern int open_page_read(int pid, struct page_read *, int pr_flags);
extern int open_page_read_at(int dfd, int pid, struct page_read *pr,
int pr_flags);
-extern void pagemap2iovec(PagemapEntry *pe, struct iovec *iov);
-extern void iovec2pagemap(struct iovec *iov, PagemapEntry *pe);
extern int dedup_one_iovec(struct page_read *pr, unsigned long base,
unsigned long len);
diff --git a/criu/page-xfer.c b/criu/page-xfer.c
index 4c65f2a..09f2c06 100644
--- a/criu/page-xfer.c
+++ b/criu/page-xfer.c
@@ -206,7 +206,6 @@ static int check_pagehole_in_parent(struct page_read *p, struct iovec *iov)
off = (unsigned long)iov->iov_base;
end = off + iov->iov_len;
while (1) {
- struct iovec piov;
unsigned long pend;
ret = p->seek_pagemap(p, off, true);
@@ -215,8 +214,7 @@ static int check_pagehole_in_parent(struct page_read *p, struct iovec *iov)
return -1;
}
- pagemap2iovec(p->pe, &piov);
- pr_debug("\tFound %p/%zu\n", piov.iov_base, piov.iov_len);
+ pr_debug("\tFound %"PRIx64"/%zu\n", p->pe->vaddr, pagemap_len(p->pe));
/*
* The pagemap entry in parent may happen to be
@@ -224,7 +222,7 @@ static int check_pagehole_in_parent(struct page_read *p, struct iovec *iov)
* we should go ahead and check the remainder.
*/
- pend = (unsigned long)piov.iov_base + piov.iov_len;
+ pend = p->pe->vaddr + pagemap_len(p->pe);
if (end <= pend)
return 0;
@@ -238,7 +236,8 @@ static int write_pagemap_loc(struct page_xfer *xfer, struct iovec *iov, u32 flag
int ret;
PagemapEntry pe = PAGEMAP_ENTRY__INIT;
- iovec2pagemap(iov, &pe);
+ pe.vaddr = encode_pointer(iov->iov_base);
+ pe.nr_pages = iov->iov_len / PAGE_SIZE;
pe.has_flags = true;
pe.flags = flags;
diff --git a/criu/pagemap.c b/criu/pagemap.c
index c881bb5..be13e61 100644
--- a/criu/pagemap.c
+++ b/criu/pagemap.c
@@ -35,18 +35,6 @@ struct page_read_iov {
struct list_head l;
};
-void pagemap2iovec(PagemapEntry *pe, struct iovec *iov)
-{
- iov->iov_base = decode_pointer(pe->vaddr);
- iov->iov_len = pe->nr_pages * PAGE_SIZE;
-}
-
-void iovec2pagemap(struct iovec *iov, PagemapEntry *pe)
-{
- pe->vaddr = encode_pointer(iov->iov_base);
- pe->nr_pages = iov->iov_len / PAGE_SIZE;
-}
-
static inline bool can_extend_bunch(struct iovec *bunch,
unsigned long off, unsigned long len)
{
@@ -85,16 +73,13 @@ static int punch_hole(struct page_read *pr, unsigned long off,
static int seek_pagemap_page(struct page_read *pr, unsigned long vaddr);
-int dedup_one_iovec(struct page_read *pr, unsigned long base, unsigned long len)
+int dedup_one_iovec(struct page_read *pr, unsigned long off, unsigned long len)
{
- unsigned long off;
unsigned long iov_end;
- iov_end = base + len;
- off = base;
+ iov_end = off + len;
while (1) {
int ret;
- struct iovec piov;
unsigned long piov_end;
struct page_read * prp;
@@ -109,8 +94,7 @@ int dedup_one_iovec(struct page_read *pr, unsigned long base, unsigned long len)
if (!pr->pe)
return -1;
- pagemap2iovec(pr->pe, &piov);
- piov_end = (unsigned long)piov.iov_base + piov.iov_len;
+ piov_end = pr->pe->vaddr + pagemap_len(pr->pe);
if (!pagemap_in_parent(pr->pe)) {
ret = punch_hole(pr, pr->pi_off, min(piov_end, iov_end) - off, false);
if (ret == -1)
--
1.9.1
More information about the CRIU
mailing list