public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matt Helsley <matthltc@us.ibm.com>
To: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: arnd@arndb.de, jeremy@goop.org,
	containers@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC v2][PATCH 8/9] Remove some BUG_ON()s that need some proper error handling instead.
Date: Thu, 28 Aug 2008 21:18:02 -0700	[thread overview]
Message-ID: <1219983482.11632.61.camel@localhost.localdomain> (raw)
In-Reply-To: <20080820192607.91E0AFF2@nimitz>

On Wed, 2008-08-20 at 12:26 -0700, Dave Hansen wrote:
> 
> 
> ---
> 
>  oren-cr.git-dave/checkpoint/checkpoint.c |   12 ++++++++++--
>  oren-cr.git-dave/checkpoint/restart.c    |   15 +++++++++++++++
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff -puN checkpoint/checkpoint.c~0002-Remove-some-BUG_ON-s-that-need-some-proper-error-ha checkpoint/checkpoint.c
> --- oren-cr.git/checkpoint/checkpoint.c~0002-Remove-some-BUG_ON-s-that-need-some-proper-error-ha	2008-08-20 12:12:51.000000000 -0700
> +++ oren-cr.git-dave/checkpoint/checkpoint.c	2008-08-20 12:12:51.000000000 -0700
> @@ -125,7 +125,8 @@ static int cr_write_tail(struct cr_ctx *
>  	h.id = 0;
> 
>  	hh->magic = CR_HEADER_MAGIC;
> -	hh->cksum[0] = hh->cksum[1] = 1;	/* TBD ... */
> +	hh->cksum[0] = 1;
> +       	hh->cksum[1] = 1;	/* TBD ... */
> 
>  	ret = cr_write_obj(ctx, &h, hh);
>  	kfree(hh);
> @@ -183,7 +184,14 @@ static int cr_write_task(struct cr_ctx *
>  {
>  	int ret ;
> 
> -	BUG_ON(t->state == TASK_DEAD);
> +	/*
> +	 * This was a BUG_ON(), which kinda makes sense if you
> +	 * are only allowing checkpointing of 'current'.  But,
> +	 * it is still pretty silly in that case.  Make it
> +	 * something a bit more sensible.
> +	 */
> +	if (t->state == TASK_DEAD)
> +		return -EAGAIN;

	This is OK for a debug patch but I think in the end we'd want to do
something similar early in sys_checkpoint -- before we start writing
anything. We should check to ensure the task is properly frozen there
and return -EBUSY if not frozen. Something like:

/* Only current can self-checkpoint. Everything else must be frozen first. */
for_each_task_being_checkpointed(t) {
	if ((t != current) && !is_task_frozen_enough(t))
		return -EBUSY;
}


is_task_frozen_enough() current lives in kernel/cgroup_freezer.c. I
think it can easily be pulled out of the cgroup_freezer.c code so that
we don't introduce a CONFIG dependency...

>  	ret = cr_write_task_struct(ctx, t);
>  	pr_debug("ret (task_struct) %d\n", ret);
> diff -puN checkpoint/restart.c~0002-Remove-some-BUG_ON-s-that-need-some-proper-error-ha checkpoint/restart.c
> --- oren-cr.git/checkpoint/restart.c~0002-Remove-some-BUG_ON-s-that-need-some-proper-error-ha	2008-08-20 12:12:51.000000000 -0700
> +++ oren-cr.git-dave/checkpoint/restart.c	2008-08-20 12:12:51.000000000 -0700
> @@ -74,6 +74,11 @@ static int cr_read_hdr(struct cr_ctx *ct
>  	struct cr_hdr_head *hh = kmalloc(sizeof(*hh), GFP_KERNEL);
>  	int ret;
> 
> +	if (!hh) {
> +		pr_debug("unable to get %d bytes from ctx buf for header\n",
> +				sizeof(*hh));
> +		return -ENOMEM;
> +	}
>  	ret = cr_read_obj_type(ctx, hh, sizeof(*hh), CR_HDR_HEAD);
>  	if (ret < 0)
>  		return ret;
> @@ -99,6 +104,11 @@ static int cr_read_tail(struct cr_ctx *c
>  	struct cr_hdr_tail *hh = kmalloc(sizeof(*hh), GFP_KERNEL);
>  	int ret;
> 
> +	if (!hh) {
> +		pr_debug("unable to get %d bytes from ctx buf for tail\n",
> +				sizeof(*hh));
> +		return -ENOMEM;
> +	}
>  	ret = cr_read_obj_type(ctx, hh, sizeof(*hh), CR_HDR_TAIL);
>  	if (ret < 0)
>  		return ret;
> @@ -118,6 +128,11 @@ static int cr_read_task_struct(struct cr
>  	struct task_struct *t = current;
>  	int ret;
> 
> +	if (!hh) {
> +		pr_debug("unable to get %d bytes from ctx buf for task\n",
> +				sizeof(*hh));
> +		return -ENOMEM;
> +	}
>  	ret = cr_read_obj_type(ctx, hh, sizeof(*hh), CR_HDR_TASK);
>  	if (ret < 0)
>  		return ret;
> _
> _______________________________________________
> Containers mailing list
> Containers@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/containers


  parent reply	other threads:[~2008-08-29  4:18 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-20 19:25 [RFC v2][PATCH 0/9] kernel-based checkpoint-restart Dave Hansen
2008-08-20 19:25 ` [RFC v2][PATCH 1/9] checkpoint-restart: general infrastructure Dave Hansen
2008-08-29  3:34   ` Matt Helsley
2008-08-20 19:25 ` [RFC v2][PATCH 2/9] Remove CAP_SYS_ADMIN for checkpoint/restart Dave Hansen
2008-08-20 19:26 ` [RFC v2][PATCH 3/9] checkpoint/restart: x86 support Dave Hansen
2008-08-20 19:26 ` [RFC v2][PATCH 4/9] checkpoint/restart: memory management Dave Hansen
2008-08-20 19:26 ` [RFC v2][PATCH 5/9] Create trivial sys_checkpoint and sys_restore system calls Dave Hansen
2008-08-20 19:26 ` [RFC v2][PATCH 6/9] Simplify filename handling for now Dave Hansen
2008-08-20 19:26 ` [RFC v2][PATCH 7/9] remove temporary buffer structures Dave Hansen
2008-08-20 19:26 ` [RFC v2][PATCH 8/9] Remove some BUG_ON()s that need some proper error handling instead Dave Hansen
2008-08-20 20:29   ` Dave Hansen
2008-08-29  4:18   ` Matt Helsley [this message]
2008-08-20 19:26 ` [RFC v2][PATCH 9/9] remove ->cksum field Dave Hansen

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=1219983482.11632.61.camel@localhost.localdomain \
    --to=matthltc@us.ibm.com \
    --cc=arnd@arndb.de \
    --cc=containers@lists.linux-foundation.org \
    --cc=dave@linux.vnet.ibm.com \
    --cc=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.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