[CRIU] [PATCH] page-pipe: drop dead code

Mike Rapoport rppt at linux.vnet.ibm.com
Thu Jul 13 08:50:36 MSK 2017


The page_pipe_read obsoleted page_pipe_split and related functions and
there is no point in keeping them.

Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
 criu/include/page-pipe.h |   3 -
 criu/page-pipe.c         | 161 -----------------------------------------------
 2 files changed, 164 deletions(-)

diff --git a/criu/include/page-pipe.h b/criu/include/page-pipe.h
index 76ec1fd..301edaa 100644
--- a/criu/include/page-pipe.h
+++ b/criu/include/page-pipe.h
@@ -133,9 +133,6 @@ extern int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr,
 extern void debug_show_page_pipe(struct page_pipe *pp);
 void page_pipe_reinit(struct page_pipe *pp);
 
-extern int page_pipe_split(struct page_pipe *pp, unsigned long addr,
-			   unsigned int *nr_pages);
-
 extern void page_pipe_destroy_ppb(struct page_pipe_buf *ppb);
 
 struct pipe_read_dest {
diff --git a/criu/page-pipe.c b/criu/page-pipe.c
index 4b4b3fc..63c5a8a 100644
--- a/criu/page-pipe.c
+++ b/criu/page-pipe.c
@@ -83,25 +83,6 @@ static int ppb_resize_pipe(struct page_pipe_buf *ppb, unsigned long new_size)
 	return 0;
 }
 
-static struct page_pipe_buf *ppb_alloc_resize(struct page_pipe *pp, int size)
-{
-	struct page_pipe_buf *ppb;
-	int nr_pages = size / PAGE_SIZE;
-
-	ppb = ppb_alloc(pp);
-	if (!ppb)
-		return NULL;
-
-	if (ppb->pipe_size < nr_pages) {
-		if (ppb_resize_pipe(ppb, nr_pages)) {
-			ppb_destroy(ppb);
-			return NULL;
-		}
-	}
-
-	return ppb;
-}
-
 static int page_pipe_grow(struct page_pipe *pp, unsigned int flags)
 {
 	struct page_pipe_buf *ppb;
@@ -332,148 +313,6 @@ static struct page_pipe_buf *get_ppb(struct page_pipe *pp, unsigned long addr,
 	return NULL;
 }
 
-static int page_pipe_split_iov(struct page_pipe *pp, struct page_pipe_buf *ppb,
-			       struct iovec *iov, unsigned long addr,
-			       bool popup_new)
-{
-	unsigned long len = addr - (unsigned long)iov->iov_base;
-	struct page_pipe_buf *ppb_new;
-	struct iovec *iov_new;
-	int ret;
-
-	if (len == iov->iov_len)
-		return 0;
-
-	ppb_new = ppb_alloc_resize(pp, len);
-	if (!ppb_new)
-		return -1;
-
-	ret = splice(ppb->p[0], NULL, ppb_new->p[1], NULL, len, SPLICE_F_MOVE);
-	if (ret != len)
-		return -1;
-
-	iov_new = &pp->iovs[pp->free_iov++];
-	BUG_ON(pp->free_iov > pp->nr_iovs);
-	iov_new->iov_base = iov->iov_base;
-	iov_new->iov_len = len;
-
-	ppb_init(ppb_new, len / PAGE_SIZE, 1, ppb->flags, iov_new);
-
-	ppb->pages_in -= len / PAGE_SIZE;
-
-	iov->iov_base += len;
-	iov->iov_len -= len;
-
-	if (popup_new)
-		ppb = ppb_new;
-	list_move(&ppb->l, &pp->bufs);
-
-	return 0;
-}
-
-static int page_pipe_split_ppb(struct page_pipe *pp, struct page_pipe_buf *ppb,
-			       struct iovec *iov, unsigned long len,
-			       bool popup_new)
-{
-	struct page_pipe_buf *ppb_new;
-	int ret;
-
-	ppb_new = ppb_alloc_resize(pp, len);
-	if (!ppb_new)
-		return -1;
-
-	ret = splice(ppb->p[0], NULL, ppb_new->p[1], NULL, len, SPLICE_F_MOVE);
-	if (ret != len)
-		return -1;
-
-	ppb_init(ppb_new, len / PAGE_SIZE, iov - ppb->iov, ppb->flags, ppb->iov);
-
-	ppb->iov += ppb_new->nr_segs;
-	ppb->nr_segs -= ppb_new->nr_segs;
-	ppb->pages_in -= len / PAGE_SIZE;
-
-	if (popup_new)
-		ppb = ppb_new;
-	list_move(&ppb->l, &pp->bufs);
-
-	return 0;
-}
-
-/*
- * Find the ppb containing addr and split so that we can splice
- * nr_pages starting from addr. Make the ppb containing relavant pages
- * the first entry in bb->bufs list
- */
-int page_pipe_split(struct page_pipe *pp, unsigned long addr,
-		    unsigned int *nr_pages)
-{
-	struct page_pipe_buf *ppb;
-	struct iovec *iov = NULL;
-	unsigned long len = 0;
-	int ret;
-
-	/*
-	 * Get ppb that contains addr and count length of data between
-	 * the beginning of the pipe and addr. If no ppb is found, the
-	 * requested page is mapped to zero pfn
-	 */
-	ppb = get_ppb(pp, addr, &iov, &len);
-	if (!ppb) {
-		*nr_pages = 0;
-		return 0;
-	}
-
-	/*
-	 * Split origingal ppb on boundary of iov that contains
-	 * addr. The ppb containing the address will remain at the
-	 * pp->buf list head.
-	 */
-	if (iov != ppb->iov) {
-		len -= (addr - (unsigned long)iov->iov_base);
-		ret = page_pipe_split_ppb(pp, ppb, iov, len, false);
-		if (ret)
-			return -1;
-	}
-
-	/*
-	 * Split the tail of the ppb. We presume that requests do not
-	 * cross IOV (that is pagemap entry) boundaries.
-	 * The newly created ppb will contain the desired IOV and will
-	 * be poped to the head of the pp->buf list
-	 */
-	if (ppb->nr_segs > 1) {
-		len = iov->iov_len;
-		ret = page_pipe_split_ppb(pp, ppb, iov + 1, len, true);
-		if (ret)
-			return -1;
-		ppb = list_first_entry(&pp->bufs, struct page_pipe_buf, l);
-	}
-
-	/*
-	 * if address does not match iov base, split the iov and
-	 * create a new ppb pointing to the new iov
-	 */
-	if (addr != (unsigned long)iov->iov_base) {
-		ret = page_pipe_split_iov(pp, ppb, iov, addr, false);
-		if (ret)
-			return -1;
-	}
-
-	/*
-	 * at this point iov_base points to addr, so we need to split
-	 * the part after addr + requested pages to a separate iov
-	 */
-	len = min((unsigned long)iov->iov_base + iov->iov_len - addr,
-		  (unsigned long)(*nr_pages) * PAGE_SIZE);
-	ret = page_pipe_split_iov(pp, ppb, iov, addr + len, true);
-	if (ret)
-		return -1;
-
-	*nr_pages = len / PAGE_SIZE;
-
-	return 0;
-}
-
 int pipe_read_dest_init(struct pipe_read_dest *prd)
 {
 	int ret;
-- 
2.7.4



More information about the CRIU mailing list