From daf8b4f75c9ea680a48e4b4828384fed7c9681e2 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 6 Jul 2017 12:41:12 +0300 Subject: [PATCH] page-xfer: Move lazy bool on xfer Same thing for the boolean value saying whether or not to send lazy pagemaps alone or follow them with the respective pages. This value is non-true in the single place, so let's simplify the API and keep this bool on xfer object. Acked-by: Mike Rapoport Signed-off-by: Pavel Emelyanov Signed-off-by: Andrei Vagin --- criu/cr-dump.c | 2 +- criu/include/page-xfer.h | 3 ++- criu/mem.c | 10 ++++++---- criu/page-xfer.c | 6 +++--- criu/shmem.c | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/criu/cr-dump.c b/criu/cr-dump.c index cf0ac8093..8fdf85259 100644 --- a/criu/cr-dump.c +++ b/criu/cr-dump.c @@ -1491,7 +1491,7 @@ static int cr_pre_dump_finish(int ret) goto err; mem_pp = dmpi(item)->mem_pp; - ret = page_xfer_dump_pages(&xfer, mem_pp, true); + ret = page_xfer_dump_pages(&xfer, mem_pp); xfer.close(&xfer); diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h index 00b18d3b4..3769be482 100644 --- a/criu/include/page-xfer.h +++ b/criu/include/page-xfer.h @@ -22,6 +22,7 @@ struct page_xfer { * relative to some address. Used, e.g. by shmem. */ unsigned long offset; + bool transfer_lazy; /* private data for every page-xfer engine */ union { @@ -41,7 +42,7 @@ struct page_xfer { extern int open_page_xfer(struct page_xfer *xfer, int fd_type, long id); struct page_pipe; -extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *, bool dump_lazy); +extern int page_xfer_dump_pages(struct page_xfer *, struct page_pipe *); extern int connect_to_page_server_to_send(void); extern int connect_to_page_server_to_recv(int epfd); extern int disconnect_from_page_server(void); diff --git a/criu/mem.c b/criu/mem.c index 599c3036e..f3b2c224d 100644 --- a/criu/mem.c +++ b/criu/mem.c @@ -275,7 +275,7 @@ static int drain_pages(struct page_pipe *pp, struct parasite_ctl *ctl, return 0; } -static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy) +static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer) { int ret; @@ -284,7 +284,7 @@ static int xfer_pages(struct page_pipe *pp, struct page_xfer *xfer, bool lazy) * pre-dump action (see pre_dump_one_task) */ timing_start(TIME_MEMWRITE); - ret = page_xfer_dump_pages(xfer, pp, !lazy); + ret = page_xfer_dump_pages(xfer, pp); timing_stop(TIME_MEMWRITE); return ret; @@ -346,6 +346,8 @@ static int __parasite_dump_pages_seized(struct pstree_item *item, ret = open_page_xfer(&xfer, CR_FD_PAGEMAP, vpid(item)); if (ret < 0) goto out_pp; + + xfer.transfer_lazy = !mdc->lazy; } else { ret = check_parent_page_xfer(CR_FD_PAGEMAP, vpid(item)); if (ret < 0) @@ -387,7 +389,7 @@ again: ret = drain_pages(pp, ctl, args); if (!ret) - ret = xfer_pages(pp, &xfer, mdc->lazy /* false actually */); + ret = xfer_pages(pp, &xfer); if (!ret) { page_pipe_reinit(pp); goto again; @@ -403,7 +405,7 @@ again: sizeof(struct iovec) * pp->nr_iovs); ret = drain_pages(pp, ctl, args); if (!ret && !mdc->pre_dump) - ret = xfer_pages(pp, &xfer, mdc->lazy); + ret = xfer_pages(pp, &xfer); if (ret) goto out_xfer; diff --git a/criu/page-xfer.c b/criu/page-xfer.c index 737e05fa3..8237e7749 100644 --- a/criu/page-xfer.c +++ b/criu/page-xfer.c @@ -379,6 +379,7 @@ out: int open_page_xfer(struct page_xfer *xfer, int fd_type, long id) { xfer->offset = 0; + xfer->transfer_lazy = true; if (opts.use_page_server) return open_page_server_xfer(xfer, fd_type, id); @@ -433,8 +434,7 @@ static int dump_holes(struct page_xfer *xfer, struct page_pipe *pp, return 0; } -int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp, - bool dump_lazy) +int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp) { struct page_pipe_buf *ppb; unsigned int cur_hole = 0; @@ -461,7 +461,7 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp, (unsigned int)(iov.iov_len / PAGE_SIZE)); if (ppb->flags & PPB_LAZY) { - if (!dump_lazy) { + if (!xfer->transfer_lazy) { if (xfer->write_pagemap(xfer, &iov, PE_LAZY)) return -1; continue; diff --git a/criu/shmem.c b/criu/shmem.c index 7ab396359..5314cb504 100644 --- a/criu/shmem.c +++ b/criu/shmem.c @@ -640,7 +640,7 @@ static int dump_pages(struct page_pipe *pp, struct page_xfer *xfer) return -1; } - return page_xfer_dump_pages(xfer, pp, true); + return page_xfer_dump_pages(xfer, pp); } static int next_data_segment(int fd, unsigned long pfn,