From: Oren Laadan <orenl-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
To: Dave Hansen <dave-gkUM19QKKo4@public.gmane.org>
Cc: containers <containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org>,
Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
Subject: Re: External checkpoint patch
Date: Tue, 21 Oct 2008 18:49:28 -0400 [thread overview]
Message-ID: <48FE5C78.3020202@cs.columbia.edu> (raw)
In-Reply-To: <1224612971.1848.193.camel@nimitz>
Dave Hansen wrote:
> Oren,
>
> Could you take a look over Cedric's external checkpoint patch?
>
> http://git.kernel.org/?p=linux/kernel/git/daveh/linux-2.6-cr.git;a=commit;h=28ffabbc17d3641eee2a7eb66f714c266c400263
>
> It seems pretty small to me.
>
> --
>
>>From a2f88cbc023e2e9be5eb554fe64078a3d7d2ade6 Mon Sep 17 00:00:00 2001
> From: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
> Date: Tue, 30 Sep 2008 10:45:13 +0200
> Subject: [PATCH] enable external checkpoint
>
> Modify self checkpoint syscall to allow another process to initiate
> checkpoint
>
> Signed-off-by: Cedric Le Goater <clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
> ---
> arch/x86/mm/checkpoint.c | 2 +-
> checkpoint/checkpoint.c | 2 +-
> checkpoint/sys.c | 28 +++++++++++++++++++++-------
> include/linux/checkpoint.h | 1 +
> 4 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/mm/checkpoint.c b/arch/x86/mm/checkpoint.c
> index d6c5263..202a579 100644
> --- a/arch/x86/mm/checkpoint.c
> +++ b/arch/x86/mm/checkpoint.c
> @@ -164,7 +164,7 @@ void cr_write_cpu_fpu(struct cr_hdr_cpu *hh, struct task_struct *t)
> * except if we are in process context, in which case we do
> */
> if (thread_info->status & TS_USEDFPU)
> - unlazy_fpu(current);
> + unlazy_fpu(t);
This is not needed (only needed in self checkpoint).
>
> hh->has_fxsr = cpu_has_fxsr;
> memcpy(&hh->xstate, &thread->xstate, sizeof(thread->xstate));
> diff --git a/checkpoint/checkpoint.c b/checkpoint/checkpoint.c
> index 87420dc..c4e8242 100644
> --- a/checkpoint/checkpoint.c
> +++ b/checkpoint/checkpoint.c
> @@ -227,7 +227,7 @@ int do_checkpoint(struct cr_ctx *ctx)
> ret = cr_write_head(ctx);
> if (ret < 0)
> goto out;
> - ret = cr_write_task(ctx, current);
> + ret = cr_write_task(ctx, ctx->task);
> if (ret < 0)
> goto out;
> ret = cr_write_tail(ctx);
> diff --git a/checkpoint/sys.c b/checkpoint/sys.c
> index 4fcd3e0..ec028c6 100644
> --- a/checkpoint/sys.c
> +++ b/checkpoint/sys.c
> @@ -176,7 +176,8 @@ void cr_ctx_free(struct cr_ctx *ctx)
> kfree(ctx);
> }
>
> -struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
> +struct cr_ctx *cr_ctx_alloc(struct task_struct *t, pid_t pid, int fd,
> + unsigned long flags)
> {
> struct cr_ctx *ctx;
>
> @@ -184,6 +185,7 @@ struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
> if (!ctx)
> return ERR_PTR(-ENOMEM);
>
> + ctx->task = t;
> ctx->file = fget(fd);
> if (!ctx->file) {
> cr_ctx_free(ctx);
> @@ -205,7 +207,7 @@ struct cr_ctx *cr_ctx_alloc(pid_t pid, int fd, unsigned long flags)
> * assume checkpointer is in container's root vfs
> * FIXME: this works for now, but will change with real containers
> */
> - ctx->vfsroot = ¤t->fs->root;
> + ctx->vfsroot = &t->fs->root;
> path_get(ctx->vfsroot);
>
> INIT_LIST_HEAD(&ctx->pgarr_list);
> @@ -231,20 +233,32 @@ asmlinkage long sys_checkpoint(pid_t pid, int fd, unsigned long flags)
> {
> struct cr_ctx *ctx;
> int ret;
> + struct task_struct *t;
>
> /* no flags for now */
> if (flags)
> return -EINVAL;
>
> - ctx = cr_ctx_alloc(pid, fd, flags | CR_CTX_CKPT);
> - if (IS_ERR(ctx))
> - return PTR_ERR(ctx);
> + read_lock(&tasklist_lock);
> + t = find_task_by_vpid(pid);
> + if (t)
> + get_task_struct(t);
> + read_unlock(&tasklist_lock);
missing put_task_struct() ?
missing security check ?
> +
> + if (!t)
> + return -ESRCH;
>
> + ctx = cr_ctx_alloc(t, pid, fd, flags | CR_CTX_CKPT);
> + if (IS_ERR(ctx)) {
> + ret = PTR_ERR(ctx);
> + goto out;
> + }
> +
> ret = do_checkpoint(ctx);
>
> if (!ret)
> ret = ctx->crid;
> -
> +out:
> cr_ctx_free(ctx);
> return ret;
> }
> @@ -267,7 +281,7 @@ asmlinkage long sys_restart(int crid, int fd, unsigned long flags)
> if (flags)
> return -EINVAL;
>
> - ctx = cr_ctx_alloc(crid, fd, flags | CR_CTX_RSTR);
> + ctx = cr_ctx_alloc(current, crid, fd, flags | CR_CTX_RSTR);
> if (IS_ERR(ctx))
> return PTR_ERR(ctx);
>
> diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
> index 6c1e87f..2983700 100644
> --- a/include/linux/checkpoint.h
> +++ b/include/linux/checkpoint.h
> @@ -17,6 +17,7 @@
>
> struct cr_ctx {
> pid_t pid; /* container identifier */
> + struct task_struct *task;
> int crid; /* unique checkpoint id */
>
> unsigned long flags;
next prev parent reply other threads:[~2008-10-21 22:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-21 18:16 External checkpoint patch Dave Hansen
2008-10-21 22:49 ` Oren Laadan [this message]
2008-10-21 23:07 ` Oren Laadan
[not found] ` <Pine.LNX.4.64.0810211857140.22085-CXF6herHY6ykSYb+qCZC/1i27PF6R63G9nwVQlTi/Pw@public.gmane.org>
2008-10-23 7:51 ` Cedric Le Goater
2008-10-23 13:48 ` Cedric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48FE5C78.3020202@cs.columbia.edu \
--to=orenl-eqauephvms7envbuuze7ea@public.gmane.org \
--cc=clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=dave-gkUM19QKKo4@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox