Change net c/r to use stock page I/O functions
...as discussed on list.
A message that is not in the archive (sent off-list or not yet received): 1258489484-28227-1-git-send-email-danms-r/[email protected]
PATCH 1/2 Expose page read/write functions
Expose checkpoint_dump_page() and restore_read_page() from memory.c. Also convert them to use a common scratch buffer in the ckpt_ctx to avoid alloc/dealloc on every page I/O (or group of them).
--- checkpoint/memory.c | 29 ++++++++--------------------- checkpoint/sys.c | 8 ++++++++ include/linux/checkpoint.h | 3 +++ include/linux/checkpoint_types.h | 2 ++ 4 files changed, 21 insertions(+), 21 deletions(-)
checkpoint/memory.c +8 -21
@@ -394,16 +394,15 @@ static int vma_fill_pgarr(struct ckpt_ctx *ctx, }/* dump contents of a pages: use kmap_atomic() to avoid TLB flush */ -static int checkpoint_dump_page (struct ckpt_ctx *ctx, -struct page *page,char *buf) +int checkpoint_dump_page (struct ckpt_ctx *ctx,struct page *page) {void *ptr; ptr =kmap_atomic (page,KM_USER1 ); -memcpy (buf, ptr,PAGE_SIZE ); +memcpy (ctx->scratch_page, ptr,PAGE_SIZE );kunmap_atomic (ptr,KM_USER1 ); -return ckpt_kwrite (ctx, buf,PAGE_SIZE ); +return ckpt_kwrite (ctx, ctx->scratch_page,PAGE_SIZE ); }/**
@@ -416,7 +415,6 @@ static int checkpoint_dump_page(struct ckpt_ctx *ctx,static int vma_dump_pages (struct ckpt_ctx *ctx,int total) {struct ckpt_pgarr *pgarr; -void *buf;int i, ret =0 ;if (!total)
@@ -434,19 +432,14 @@ static int vma_dump_pages(struct ckpt_ctx *ctx, int total)return ret; } - buf = (void *)__get_free_page (GFP_KERNEL ); -if (!buf) -return -ENOMEM ; -list_for_each_entry_reverse (pgarr, &ctx->pgarr_list, list) {for (i =0 ; i < pgarr->nr_used; i++) { - ret =checkpoint_dump_page (ctx, pgarr->pages[i], buf); + ret =checkpoint_dump_page (ctx, pgarr->pages[i]);if (ret <0 ) goto out; } } out: -free_page ((unsigned long ) buf);return ret; }
@@ -889,17 +882,17 @@ static int read_pages_vaddrs(struct ckpt_ctx *ctx, unsigned long nr_pages)return 0 ; } -static int restore_read_page (struct ckpt_ctx *ctx,struct page *page,void *p) +int restore_read_page (struct ckpt_ctx *ctx,struct page *page) {void *ptr;int ret; - ret =ckpt_kread (ctx, p,PAGE_SIZE ); + ret =ckpt_kread (ctx, ctx->scratch_page,PAGE_SIZE );if (ret <0 )return ret; ptr =kmap_atomic (page,KM_USER1 ); -memcpy (ptr, p,PAGE_SIZE ); +memcpy (ptr, ctx->scratch_page,PAGE_SIZE );kunmap_atomic (ptr,KM_USER1 );return 0 ;
@@ -937,13 +930,8 @@ static int read_pages_contents(struct ckpt_ctx *ctx, struct inode *inode) {struct ckpt_pgarr *pgarr;unsigned long *vaddrs; -char *buf;int i, ret =0 ; - buf =kmalloc (PAGE_SIZE ,GFP_KERNEL ); -if (!buf) -return -ENOMEM ; -down_read (¤t->mm->mmap_sem);list_for_each_entry_reverse (pgarr, &ctx->pgarr_list, list) { vaddrs = pgarr->vaddrs;
@@ -961,7 +949,7 @@ static int read_pages_contents(struct ckpt_ctx *ctx, struct inode *inode) goto out; } - ret =restore_read_page (ctx, page, buf); + ret =restore_read_page (ctx, page);page_cache_release (page);if (ret <0 )
@@ -971,7 +959,6 @@ static int read_pages_contents(struct ckpt_ctx *ctx, struct inode *inode) out:up_read (¤t->mm->mmap_sem); -kfree (buf);return 0 ; }
checkpoint/sys.c +8 -0
@@ -246,6 +246,8 @@ static void ckpt_ctx_free(struct ckpt_ctx *ctx)sock_listening_list_free (&ctx->listen_sockets); +free_page ((unsigned long )ctx->scratch_page); +kfree (ctx); }
@@ -259,6 +261,12 @@ static struct ckpt_ctx *ckpt_ctx_alloc(int fd, unsigned long uflags,if (!ctx)return ERR_PTR (-ENOMEM ); + ctx->scratch_page = (void *)__get_free_page (GFP_KERNEL ); +if (!ctx->scratch_page) { + err = -ENOMEM ; + goto err; + } + ctx->uflags = uflags; ctx->kflags = kflags; ctx->ktime_begin =ktime_get ();
include/linux/checkpoint.h +3 -0
@@ -94,6 +94,9 @@ extern int ckpt_read_consume(struct ckpt_ctx *ctx, int len, int type);extern char *ckpt_fill_fname (struct path *path,struct path *root,char *buf,int *len); +int checkpoint_dump_page (struct ckpt_ctx *ctx,struct page *page); +int restore_read_page (struct ckpt_ctx *ctx,struct page *page); +/* pids */ extern pid_t ckpt_pid_nr (struct ckpt_ctx *ctx,struct pid *pid);extern struct pid *_ckpt_find_pgrp (struct ckpt_ctx *ctx,pid_t pgid);
include/linux/checkpoint_types.h +2 -0
@@ -69,6 +69,8 @@ struct ckpt_ctx {struct list_head pgarr_list;/* page array to dump VMA contents */ struct list_head pgarr_pool;/* pool of empty page arrays chain */ +void *scratch_page;/* Scratch buffer for page I/O */ +/* [multi-process checkpoint] */ struct task_struct **tasks_arr;/* array of all tasks [checkpoint] */ int nr_tasks;/* size of tasks array */
Signature · 1 line
1.6.2.5
PATCH 2/2 Change net c/r to use exported page I/O functions
In reply to a message not in the archiveThis changes the net c/r functions that save out the socket buffers to use the exported page I/O functions, just like the memory dump routines.
--- include/linux/checkpoint_hdr.h | 8 ++++ net/checkpoint.c | 86 ++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 29 deletions(-)
include/linux/checkpoint_hdr.h +8 -0
@@ -170,6 +170,8 @@ enum {#define CKPT_HDR_SOCKET_QUEUE CKPT_HDR_SOCKET_QUEUE CKPT_HDR_SOCKET_BUFFER,#define CKPT_HDR_SOCKET_BUFFER CKPT_HDR_SOCKET_BUFFER + CKPT_HDR_SOCKET_FRAG, +#define CKPT_HDR_SOCKET_FRAG CKPT_HDR_SOCKET_FRAG CKPT_HDR_SOCKET_UNIX,#define CKPT_HDR_SOCKET_UNIX CKPT_HDR_SOCKET_UNIX CKPT_HDR_SOCKET_INET,
@@ -610,6 +612,12 @@ struct ckpt_hdr_socket_buffer {__u8 cb[48 ]; }; +struct ckpt_hdr_socket_buffer_frag { +struct ckpt_hdr h; +__u32 size; +__u32 offset; +}; +#define CKPT_UNIX_LINKED 1struct ckpt_hdr_socket_unix {struct ckpt_hdr h;
net/checkpoint.c +57 -29
118 lines not on this page · raw message
Signature · 1 line
1.6.2.5
A message that is not in the archive (sent off-list or not yet received): 1258489484-28227-3-git-send-email-danms-r/[email protected]
Re: [PATCH 2/2] Change net c/r to use exported page I/O functions
Quoted 15 lines · Dan Smith
net/checkpoint.c +15
-0+static int __sock_write_skb_frag (struct ckpt_ctx *ctx, +skb_frag_t *frag) +{ +struct ckpt_hdr_socket_buffer_frag *h; +int ret; + + h =ckpt_hdr_get_type (ctx,sizeof (*h),CKPT_HDR_SOCKET_FRAG ); +if (!h) +return -ENOMEM ; + + h->size = frag->size; + h->offset = frag->page_offset; + + ret =ckpt_write_obj (ctx, (struct ckpt_hdr *)h); +ckpt_hdr_put (ctx, h);
net/checkpoint.c struct sk_buff *sock_restore_skb(struct ckpt_ctx *ctx, · line 312
Quoted 10 lines
net/checkpoint.c +10
-0+if (ret <0 ) + goto out; + + ret =checkpoint_dump_page (ctx, frag->page); +ckpt_debug ("writing frag page: %i\n" , ret); +if (ret <0 ) + goto out; + + out: +ckpt_hdr_put (ctx, h);
I assume you meant to get rid of this second ckpt_hdr_put()?
Quoted 34 lines
net/checkpoint.c +7
-7+ +return ret; +} +static int __sock_write_skb (struct ckpt_ctx *ctx,struct sk_buff *skb,int dst_objref)@@ -316,16 +348,12 @@ static int __sock_write_skb(struct ckpt_ctx *ctx,for (i =0 ; i <skb_shinfo (skb)->nr_frags; i++) {skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; -u8 *vaddr =kmap (frag->page); - + ret =__sock_write_skb_frag (ctx, frag);ckpt_debug ("writing buffer fragment %i/%i (%i)\n" , - i +1 , h->nr_frags, frag->size); - ret =ckpt_write_obj_type (ctx, vaddr + frag->page_offset, - frag->size,CKPT_HDR_BUFFER ); -kunmap (frag->page); - h->frg_len -= frag->size; + i +1 , h->nr_frags, ret);if (ret <0 ) goto out; + h->frg_len -= frag->size; }WARN_ON (h->frg_len !=0 );Signature · 6 lines
1.6.2.5 _______________________________________________ Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org https://lists.linux-foundation.org/mailman/listinfo/containers
A message that is not in the archive (sent off-list or not yet received): 20091118041707.GA19841-r/[email protected]
Re: [PATCH 2/2] Change net c/r to use exported page I/O functions
SH> I assume you meant to get rid of this second ckpt_hdr_put()?
Yep, that was the reason I broke it out into a separate function and then I forgot to remove it :)
Trivially updated version below.
Signature · 13 lines
Dan Smith IBM Linux Technology Center email: danms-r/[email protected] Change net c/r to use exported page I/O functions (v2) This changes the net c/r functions that save out the socket buffers to use the exported page I/O functions, just like the memory dump routines. Changes in v2: - Remove duplicate ckpt_hdr_put() in __sock_write_skb_frag() Signed-off-by: Dan Smith <danms-r/[email protected]>
include/linux/checkpoint_hdr.h +8 -0
@@ -170,6 +170,8 @@ enum {#define CKPT_HDR_SOCKET_QUEUE CKPT_HDR_SOCKET_QUEUE CKPT_HDR_SOCKET_BUFFER,#define CKPT_HDR_SOCKET_BUFFER CKPT_HDR_SOCKET_BUFFER + CKPT_HDR_SOCKET_FRAG, +#define CKPT_HDR_SOCKET_FRAG CKPT_HDR_SOCKET_FRAG CKPT_HDR_SOCKET_UNIX,#define CKPT_HDR_SOCKET_UNIX CKPT_HDR_SOCKET_UNIX CKPT_HDR_SOCKET_INET,
@@ -610,6 +612,12 @@ struct ckpt_hdr_socket_buffer {__u8 cb[48 ]; }; +struct ckpt_hdr_socket_buffer_frag { +struct ckpt_hdr h; +__u32 size; +__u32 offset; +}; +#define CKPT_UNIX_LINKED 1struct ckpt_hdr_socket_unix {struct ckpt_hdr h;
net/checkpoint.c +56 -29
117 lines not on this page · raw message
Got it for v19-rc2.
Quoted 7 lines · Dan Smith
...as discussed on list.
_______________________________________________
Containers mailing list Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
https://lists.linux-foundation.org/mailman/listinfo/containers