[PATCH] c/r: [signal 3/3] pending signals (private, shared)

Louis Rilling Louis.Rilling at kerlabs.com
Fri Jul 24 06:13:56 PDT 2009


On 23/07/09 10:48 -0400, Oren Laadan wrote:
> This patch adds checkpoint and restart of pending signals queues:
> struct sigpending, both per-task t->sigpending and shared (per-
> thread-group) t->signal->shared_sigpending.
> 
> To checkpoint pending signals (private/shared) we first detach the
> signal queue (and copy the mask) to a separate struct sigpending.
> This separate structure can be iterated through without locking.
> 
> Once the state is saved, we re-attaches (prepends) the original signal
> queue back to the original struct sigpending.
> 
> Signals that arrive(d) in the meantime will be suitably queued after
> these (for real-time signals). Repeated non-realtime signals will not
> be queued because they will already be marked in the pending mask,
> that remains as is. This is the expected behavior of non-realtime
> signals.
> 
> Signed-off-by: Oren Laadan <orenl at cs.columbia.edu>
> ---
>  checkpoint/signal.c            |  255 +++++++++++++++++++++++++++++++++++++++-
>  include/linux/checkpoint_hdr.h |   23 ++++
>  2 files changed, 277 insertions(+), 1 deletions(-)
> 
> diff --git a/checkpoint/signal.c b/checkpoint/signal.c
> index b3f1d3e..940cc4a 100644
> --- a/checkpoint/signal.c
> +++ b/checkpoint/signal.c
> @@ -166,12 +166,99 @@ int restore_obj_sighand(struct ckpt_ctx *ctx, int sighand_objref)
>   * signal checkpoint/restart
>   */
>  
> +static void fill_siginfo(struct ckpt_hdr_siginfo *si, siginfo_t *info)
> +{
> +	si->signo = info->si_signo;
> +	si->_errno = info->si_errno;
> +	si->code = info->si_code;
> +
> +	/* TODO: convert info->si_uid to uid_objref */
> +
> +	switch(info->si_code & __SI_MASK) {
> +	case __SI_TIMER:
> +		si->pid = info->si_tid;
> +		si->uid = info->si_overrun;
> +		si->sigval_int = info->si_int;
> +	si->utime = info->si_sys_private;
> +		break;
> +	case __SI_POLL:
> +		si->pid = info->si_band;
> +		si->sigval_int = info->si_fd;
> +		break;
> +	case __SI_FAULT:
> +		si->sigval_ptr = (unsigned long) info->si_addr;
> +#ifdef __ARCH_SI_TRAPNO
> +		si->sigval_int = info->si_trapno;
> +#endif
> +		break;
> +	case __SI_CHLD:
> +		si->pid = info->si_pid;
> +		si->uid = info->si_uid;
> +		si->sigval_int = info->si_status;
> +		si->stime = info->si_stime;
> +		si->utime = info->si_utime;
> +		break;
> +	/*
> +	 * case __SI_KILL:
> +	 * case __SI_RT:
> +	 * case __SI_MESGQ:
> +	 */
> +	default:
> +		si->pid = info->si_pid;
> +		si->uid = info->si_uid;
> +		si->sigval_ptr = (unsigned long) info->si_ptr;
> +		break;
> +	}
> +}
> +
> +/*
> + * To checkpoint pending signals (private/shared) the caller moves the
> + * signal queue (and copies the mask) to a separate struct sigpending,
> + * therefore we can iterate through it without locking.
> + * After we return, the caller re-attaches (prepends) the original
> + * signal queue to the original struct sigpending. Thus, signals that
> + * arrive(d) in the meantime will be suitably queued after these.
> + * Finally, repeated non-realtime signals will not be queued because
> + * they will already be marked in the pending mask, that remains as is.
> + * This is the expected behavior of non-realtime signals.
> + */
> +static int checkpoint_sigpending(struct ckpt_ctx *ctx,
> +				 struct sigpending *pending)
> +{
> +	struct ckpt_hdr_sigpending *h;
> +	struct ckpt_hdr_siginfo *si;
> +	struct sigqueue *q;
> +	int nr_pending = 0;
> +	int ret;
> +
> +	list_for_each_entry(q, &pending->list, list)
> +		nr_pending++;
> +	h = ckpt_hdr_get_type(ctx, nr_pending * sizeof(*si) + sizeof(*h),
> +			      CKPT_HDR_SIGPENDING);
> +	if (!h)
> +		return -ENOMEM;
> +
> +	h->nr_pending = nr_pending;
> +	fill_sigset(&h->signal, &pending->signal);
> +
> +	si = h->siginfo;
> +	list_for_each_entry(q, &pending->list, list)
> +		fill_siginfo(si++, &q->info);

If q has SIGQUEUE_PREALLOC, we should probably abort the checkpoint, until POSIX
timers (only users AFAIK) are supported.

Thanks,

Louis

> +
> +	ret = ckpt_write_obj(ctx, &h->h);
> +	ckpt_hdr_put(ctx, h);
> +
> +	return ret;
> +}
> +

[...]

-- 
Dr Louis Rilling			Kerlabs
Skype: louis.rilling			Batiment Germanium
Phone: (+33|0) 6 80 89 08 23		80 avenue des Buttes de Coesmes
http://www.kerlabs.com/			35700 Rennes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.linux-foundation.org/pipermail/containers/attachments/20090724/219f6903/attachment.pgp 


More information about the Containers mailing list