checkpoint: don't checkpoint a task with aio requests
PATCH 1/1 checkpoint: don't checkpoint a task with aio requests
Not sure this is the best way, or entirely foolproof, but at least make an attempt to not checkpoint a task which is using aio.
A checkpoint-aware application using aio can have the checkpointer signal all tasks to complete aio and wait for the checkpoint to complete.
(Note I still have a queue of the patches at
http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/sergeh/linux-cr.git;a=shortlog;h=refs/heads/cr-next
so you should be able to
git fetch git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux-cr.git cr-next:serge
and cherrypick patches from that branch instead
of wrangling all the patches from mbox...)
--- checkpoint/memory.c | 6 ++++++ fs/aio.c | 17 +++++++++++++++++ include/linux/aio.h | 2 ++ 3 files changed, 25 insertions(+), 0 deletions(-)
checkpoint/memory.c +6 -0
@@ -25,6 +25,7 @@#include <linux/swap.h> #include <linux/checkpoint.h> #include <linux/checkpoint_hdr.h> +#include <linux/aio.h> /* * page-array chains: each ckpt_pgarr describes a set of <struct page *,vaddr>
@@ -666,6 +667,11 @@ static int do_checkpoint_mm(struct ckpt_ctx *ctx, struct mm_struct *mm)struct file *exe_file =NULL ;int ret; + ret =check_for_outstanding_aio (mm); +if (ret <0 ) { +ckpt_err (ctx, ret,"(%T)Outstanding aio\n" ); +return ret; + } h =ckpt_hdr_get_type (ctx,sizeof (*h),CKPT_HDR_MM );if (!h)return -ENOMEM ;
fs/aio.c +17 -0
@@ -1784,3 +1784,20 @@ SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,asmlinkage_protect (5 , ret, ctx_id, min_nr, nr, events, timeout);return ret; } + +int check_for_outstanding_aio (struct mm_struct *mm) +{ +int ret = -EBUSY ; +struct kioctx *ctx; +struct hlist_node *n; + +rcu_read_lock (); +hlist_for_each_entry_rcu (ctx, n, &mm->ioctx_list, list) +if (!ctx->dead) + goto found; + ret =0 ; +found: +rcu_read_unlock (); + +return ret; +}
include/linux/aio.h +2 -0
@@ -214,6 +214,7 @@ extern void kick_iocb(struct kiocb *iocb);extern int aio_complete (struct kiocb *iocb,long res,long res2);struct mm_struct ;extern void exit_aio (struct mm_struct *mm); +extern int check_for_outstanding_aio (struct mm_struct *mm);#else static inline ssize_t wait_on_sync_kiocb (struct kiocb *iocb) {return 0 ; }static inline int aio_put_req (struct kiocb *iocb) {return 0 ; }
@@ -221,6 +222,7 @@ static inline void kick_iocb(struct kiocb *iocb) { }static inline int aio_complete (struct kiocb *iocb,long res,long res2) {return 0 ; }struct mm_struct ;static inline void exit_aio (struct mm_struct *mm) { } +static inline int check_for_outstanding_aio (struct mm_struct *mm) {return 0 ; }#endif /* CONFIG_AIO */ #define io_wait_to_kiocb (wait) container_of(wait, struct kiocb, ki_wait)
Signature · 1 line
1.6.0.4
A message that is not in the archive (sent off-list or not yet received): 20091230203722.GA25170-r/[email protected]
Seems sufficient for now - until we get to address AIO. Added, thanks.
Oren.
Quoted 93 lines · Serge E. Hallyn
Not sure this is the best way, or entirely foolproof, but at least make an attempt to not checkpoint a task which is using aio.
A checkpoint-aware application using aio can have the checkpointer signal all tasks to complete aio and wait for the checkpoint to complete.
(Note I still have a queue of the patches at
http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/sergeh/linux-cr.git;a=shortlog;h=refs/heads/cr-next
so you should be able togit fetch
git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux-cr.gitcr-next:sergeand cherrypick patches from that branch instead
of wrangling all the patches from mbox...)Signed-off-by Serge E. Hallyn <serue-r/[email protected]>--- checkpoint/memory.c | 6 ++++++ fs/aio.c | 17 +++++++++++++++++ include/linux/aio.h | 2 ++ 3 files changed, 25 insertions(+), 0 deletions(-)checkpoint/memory.c +6
-0@@ -25,6 +25,7 @@#include <linux/swap.h> #include <linux/checkpoint.h> #include <linux/checkpoint_hdr.h> +#include <linux/aio.h> /* * page-array chains: each ckpt_pgarr describes a set of <struct page *,vaddr> @@ -666,6 +667,11 @@ static int do_checkpoint_mm(struct ckpt_ctx *ctx, struct mm_struct *mm)struct file *exe_file =NULL ;int ret; + ret =check_for_outstanding_aio (mm); +if (ret <0 ) { +ckpt_err (ctx, ret,"(%T)Outstanding aio\n" ); +return ret; + } h =ckpt_hdr_get_type (ctx,sizeof (*h),CKPT_HDR_MM );if (!h)return -ENOMEM ;fs/aio.c +17
-0@@ -1784,3 +1784,20 @@ SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,asmlinkage_protect (5 , ret, ctx_id, min_nr, nr, events, timeout);return ret; } + +int check_for_outstanding_aio (struct mm_struct *mm) +{ +int ret = -EBUSY ; +struct kioctx *ctx; +struct hlist_node *n; + +rcu_read_lock (); +hlist_for_each_entry_rcu (ctx, n, &mm->ioctx_list, list) +if (!ctx->dead) + goto found; + ret =0 ; +found: +rcu_read_unlock (); + +return ret; +}include/linux/aio.h +2
-0@@ -214,6 +214,7 @@ extern void kick_iocb(struct kiocb *iocb);extern int aio_complete (struct kiocb *iocb,long res,long res2);struct mm_struct ;extern void exit_aio (struct mm_struct *mm); +extern int check_for_outstanding_aio (struct mm_struct *mm);#else static inline ssize_t wait_on_sync_kiocb (struct kiocb *iocb) {return 0 ; }static inline int aio_put_req (struct kiocb *iocb) {return 0 ; }@@ -221,6 +222,7 @@ static inline void kick_iocb(struct kiocb *iocb) { }static inline int aio_complete (struct kiocb *iocb,long res,long res2) {return 0 ; }struct mm_struct ;static inline void exit_aio (struct mm_struct *mm) { } +static inline int check_for_outstanding_aio (struct mm_struct *mm) {return 0 ; }#endif /* CONFIG_AIO */ #define io_wait_to_kiocb (wait) container_of(wait, struct kiocb, ki_wait)