All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Lynch <ntl-e+AXbWqSrlAAvxtiuMwx3w@public.gmane.org>
To: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: Re: [PATCH 2/3] c/r: Add CR_COPY() macro (v2)
Date: Wed, 25 Feb 2009 16:08:41 -0600	[thread overview]
Message-ID: <20090225160841.4d727144@thinkcentre.lan> (raw)
In-Reply-To: <1235585529-806-3-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

On Wed, 25 Feb 2009 13:12:08 -0500
Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org> wrote:

> As suggested by Dave, this provides us a way to make the copy-in and
> copy-out processes symmetric.  I also added CR_COPY_BIT() to use with
> the s390 bitfields, since we can't memcpy() those.
> 
> Changelog:
>     Feb 25:
>             . Changed WARN_ON() to BUILD_BUG_ON()
> 
> Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
> ---
>  include/linux/checkpoint.h |   20 ++++++++++++++++++++
>  1 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
> index 217cf6e..3add90e 100644
> --- a/include/linux/checkpoint.h
> +++ b/include/linux/checkpoint.h
> @@ -149,4 +149,24 @@ static inline void process_deny_checkpointing(struct task_struct *task) {}
>  
>  #endif
>  
> +#define CR_CPT 1
> +#define CR_RST 2
> +
> +#define CR_COPY(op, a, b)				\
> +	do {						\
> +		BUILD_BUG_ON(sizeof(a) != sizeof(b));	\
> +		if (op == CR_CPT)			\
> +			memcpy(&a, &b, sizeof(a));	\
> +		else					\
> +			memcpy(&b, &a, sizeof(a));	\
> +	} while (0);
> +
> +#define CR_COPY_BIT(op, a, b)				\
> +	do {						\
> +		if (op == CR_CPT)			\
> +			a = b;				\
> +		else					\
> +			b = a;				\
> +	} while (0);
> +
>  #endif /* _CHECKPOINT_CKPT_H_ */

No typechecking.  Multiple expansion of arguments (probably harmless
for the current use case, but still).  Generates a memcpy where,
depending on the arguments, simple assignment would be sufficient and
preferred.  Not useful for targets where fields in the checkpoint image
are larger than the register state they reflect (32-bit variants of x86
and powerpc).

Anyway, checkpoint and restart should not be "symmetric" -- the restart
code has to validate certain values, such as privileged registers, in
the image before committing them.

And while these macros may reduce initial development effort, the
reading effort incurred is non-trivial.  It doesn't seem worth it.

  parent reply	other threads:[~2009-02-25 22:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-25 18:12 [PATCH 0/3] c/r: Add s390 support Dan Smith
     [not found] ` <1235585529-806-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-25 18:12   ` [PATCH 1/3] s390: Expose a constant for the number of words representing the CRs Dan Smith
2009-02-25 18:12     ` Dan Smith
2009-02-25 18:12   ` [PATCH 2/3] c/r: Add CR_COPY() macro (v2) Dan Smith
     [not found]     ` <1235585529-806-3-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-25 22:08       ` Nathan Lynch [this message]
     [not found]         ` <20090225160841.4d727144-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-02-25 22:21           ` Serge E. Hallyn
2009-02-25 22:23         ` Dan Smith
2009-02-25 18:12   ` [PATCH 3/3] c/r: define s390-specific checkpoint-restart code (v6) Dan Smith
     [not found]     ` <1235585529-806-4-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-02-25 22:28       ` Nathan Lynch
     [not found]         ` <20090225162817.2003383c-4v5LP+xe+1byhTdZtsIeww@public.gmane.org>
2009-02-25 22:37           ` Dan Smith
2009-02-25 23:34           ` Nathan Lynch
2009-02-25 23:34           ` Serge E. Hallyn

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=20090225160841.4d727144@thinkcentre.lan \
    --to=ntl-e+axbwqsrlaavxtiumwx3w@public.gmane.org \
    --cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
    --cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.