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 {
unsigned int nr_holes; /* number of holes allocated */
unsigned int free_hole; /* number of holes in use */
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 */
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 iovec *, bool chunk_mode);
struct page_pipe *create_page_pipe(unsigned int nr_segs, struct iovec *iovs, unsigned flags);
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_hole(struct page_pipe *p, unsigned long addr);
......
......@@ -267,6 +267,7 @@ static int __parasite_dump_pages_seized(struct parasite_ctl *ctl,
struct vma_area *vma_area;
struct page_xfer xfer = { .parent = NULL };
int ret = -1;
unsigned cpp_flags = 0;
pr_info("\n");
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,
return -1;
ret = -1;
ctl->mem_pp = pp = create_page_pipe(vma_area_list->priv_size, pargs_iovs(args),
!delayed_dump);
if (!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)
goto out;
......
......@@ -91,7 +91,7 @@ static int page_pipe_grow(struct page_pipe *pp)
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;
ppb = ppb_alloc(pp);
......@@ -104,8 +104,7 @@ out:
return 0;
}
struct page_pipe *create_page_pipe(unsigned int nr_segs,
struct iovec *iovs, bool chunk_mode)
struct page_pipe *create_page_pipe(unsigned int nr_segs, struct iovec *iovs, unsigned flags)
{
struct page_pipe *pp;
......@@ -115,11 +114,14 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
if (!pp)
return NULL;
pp->flags = flags;
if (!iovs) {
iovs = xmalloc(sizeof(*iovs) * nr_segs);
if (!iovs)
goto err_free_pp;
pp->own_iovs = true;
pp->flags |= PP_OWN_IOVS;
}
pp->nr_pipes = 0;
......@@ -133,15 +135,13 @@ struct page_pipe *create_page_pipe(unsigned int nr_segs,
pp->free_hole = 0;
pp->holes = NULL;
pp->chunk_mode = chunk_mode;
if (page_pipe_grow(pp))
goto err_free_iovs;
return pp;
err_free_iovs:
if (pp->own_iovs)
if (pp->flags & PP_OWN_IOVS)
xfree(iovs);
err_free_pp:
xfree(pp);
......@@ -158,7 +158,7 @@ void destroy_page_pipe(struct page_pipe *pp)
list_for_each_entry_safe(ppb, n, &pp->bufs, l)
ppb_destroy(ppb);
if (pp->own_iovs)
if (pp->flags & PP_OWN_IOVS)
xfree(pp->iovs);
xfree(pp);
}
......@@ -167,7 +167,7 @@ void page_pipe_reinit(struct page_pipe *pp)
{
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");
......
......@@ -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);
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++) {
struct iovec hole = get_iov(pp->holes, cur_hole,
......
......@@ -564,7 +564,7 @@ static int dump_one_shmem(struct shmem_info *si)
if (err)
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)
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