Commit 598daf50 authored by Pavel Emelyanov's avatar Pavel Emelyanov

pp: Introduce page pipe flags

We already have 3 bool-s on this struct and are going to
have the 4th %) Time to turn this into classical flags.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent cc2eb88c
...@@ -90,14 +90,15 @@ struct page_pipe { ...@@ -90,14 +90,15 @@ struct page_pipe {
unsigned int nr_holes; /* number of holes allocated */ unsigned int nr_holes; /* number of holes allocated */
unsigned int free_hole; /* number of holes in use */ unsigned int free_hole; /* number of holes in use */
struct iovec *holes; /* holes */ struct iovec *holes; /* holes */
unsigned flags; /* PP_FOO flags below */
};
bool chunk_mode; /* Restrict the maximum buffer size of pipes #define PP_CHUNK_MODE 0x1 /* Restrict the maximum buffer size of pipes
and dump memory for a few iterations */ and dump memory for a few iterations */
bool own_iovs; /* create_page_pipe allocated IOVs memory */ #define PP_COMPAT 0x2 /* Use compatible iovs (struct compat_iovec) */
}; #define PP_OWN_IOVS 0x4 /* create_page_pipe allocated IOVs memory */
extern struct page_pipe *create_page_pipe(unsigned int nr, struct page_pipe *create_page_pipe(unsigned int nr_segs, struct iovec *iovs, unsigned flags);
struct iovec *, bool chunk_mode);
extern void destroy_page_pipe(struct page_pipe *p); extern void destroy_page_pipe(struct page_pipe *p);
extern int page_pipe_add_page(struct page_pipe *p, unsigned long addr); extern int page_pipe_add_page(struct page_pipe *p, unsigned long addr);
extern int page_pipe_add_hole(struct page_pipe *p, unsigned long addr); extern int page_pipe_add_hole(struct page_pipe *p, unsigned long addr);
......
...@@ -267,6 +267,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl, ...@@ -267,6 +267,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
struct vma_area *vma_area; struct vma_area *vma_area;
struct page_xfer xfer = { .parent = NULL }; struct page_xfer xfer = { .parent = NULL };
int ret = -1; int ret = -1;
unsigned cpp_flags = 0;
pr_info("\n"); pr_info("\n");
pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid.real); pr_info("Dumping pages (type: %d pid: %d)\n", CR_FD_PAGES, ctl->pid.real);
...@@ -286,8 +287,10 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl, ...@@ -286,8 +287,10 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
return -1; return -1;
ret = -1; ret = -1;
ctl->mem_pp = pp = create_page_pipe(vma_area_list->priv_size, pargs_iovs(args), if (!delayed_dump)
!delayed_dump); cpp_flags |= PP_CHUNK_MODE;
ctl->mem_pp = pp = create_page_pipe(vma_area_list->priv_size,
pargs_iovs(args), cpp_flags);
if (!pp) if (!pp)
goto out; goto out;
......
...@@ -91,7 +91,7 @@ static int page_pipe_grow(struct page_pipe *pp) ...@@ -91,7 +91,7 @@ static int page_pipe_grow(struct page_pipe *pp)
goto out; goto out;
} }
if (pp->chunk_mode && pp->nr_pipes == NR_PIPES_PER_CHUNK) if ((pp->flags & PP_CHUNK_MODE) && (pp->nr_pipes == NR_PIPES_PER_CHUNK))
return -EAGAIN; return -EAGAIN;
ppb = ppb_alloc(pp); ppb = ppb_alloc(pp);
...@@ -104,8 +104,7 @@ out: ...@@ -104,8 +104,7 @@ out:
return 0; return 0;
} }
struct page_pipe *create_page_pipe(unsigned int nr_segs, struct page_pipe *create_page_pipe(unsigned int nr_segs, struct iovec *iovs, unsigned flags)
struct iovec *iovs, bool chunk_mode)
{ {
struct page_pipe *pp; struct page_pipe *pp;
...@@ -115,11 +114,14 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs, ...@@ -115,11 +114,14 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
if (!pp) if (!pp)
return NULL; return NULL;
pp->flags = flags;
if (!iovs) { if (!iovs) {
iovs = xmalloc(sizeof(*iovs) * nr_segs); iovs = xmalloc(sizeof(*iovs) * nr_segs);
if (!iovs) if (!iovs)
goto err_free_pp; goto err_free_pp;
pp->own_iovs = true;
pp->flags |= PP_OWN_IOVS;
} }
pp->nr_pipes = 0; pp->nr_pipes = 0;
...@@ -133,15 +135,13 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs, ...@@ -133,15 +135,13 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
pp->free_hole = 0; pp->free_hole = 0;
pp->holes = NULL; pp->holes = NULL;
pp->chunk_mode = chunk_mode;
if (page_pipe_grow(pp)) if (page_pipe_grow(pp))
goto err_free_iovs; goto err_free_iovs;
return pp; return pp;
err_free_iovs: err_free_iovs:
if (pp->own_iovs) if (pp->flags & PP_OWN_IOVS)
xfree(iovs); xfree(iovs);
err_free_pp: err_free_pp:
xfree(pp); xfree(pp);
...@@ -158,7 +158,7 @@ void destroy_page_pipe(struct page_pipe *pp) ...@@ -158,7 +158,7 @@ void destroy_page_pipe(struct page_pipe *pp)
list_for_each_entry_safe(ppb, n, &pp->bufs, l) list_for_each_entry_safe(ppb, n, &pp->bufs, l)
ppb_destroy(ppb); ppb_destroy(ppb);
if (pp->own_iovs) if (pp->flags & PP_OWN_IOVS)
xfree(pp->iovs); xfree(pp->iovs);
xfree(pp); xfree(pp);
} }
...@@ -167,7 +167,7 @@ void page_pipe_reinit(struct page_pipe *pp) ...@@ -167,7 +167,7 @@ void page_pipe_reinit(struct page_pipe *pp)
{ {
struct page_pipe_buf *ppb, *n; struct page_pipe_buf *ppb, *n;
BUG_ON(!pp->chunk_mode); BUG_ON(!(pp->flags & PP_CHUNK_MODE));
pr_debug("Clean up page pipe\n"); pr_debug("Clean up page pipe\n");
......
...@@ -354,7 +354,7 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp, ...@@ -354,7 +354,7 @@ int page_xfer_dump_pages(struct page_xfer *xfer, struct page_pipe *pp,
pr_debug("\tbuf %d/%d\n", ppb->pages_in, ppb->nr_segs); pr_debug("\tbuf %d/%d\n", ppb->pages_in, ppb->nr_segs);
for (i = 0; i < ppb->nr_segs; i++) { for (i = 0; i < ppb->nr_segs; i++) {
struct iovec iov = get_iov(ppb->iov, i, pp->compat_iov); struct iovec iov = get_iov(ppb->iov, i);
for (; cur_hole < pp->free_hole ; cur_hole++) { for (; cur_hole < pp->free_hole ; cur_hole++) {
struct iovec hole = get_iov(pp->holes, cur_hole, struct iovec hole = get_iov(pp->holes, cur_hole,
......
...@@ -564,7 +564,7 @@ static int dump_one_shmem(struct shmem_info *si) ...@@ -564,7 +564,7 @@ static int dump_one_shmem(struct shmem_info *si)
if (err) if (err)
goto err_unmap; goto err_unmap;
pp = create_page_pipe((nrpages + 1) / 2, NULL, true); pp = create_page_pipe((nrpages + 1) / 2, NULL, PP_CHUNK_MODE);
if (!pp) if (!pp)
goto err_unmap; goto err_unmap;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment