All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
To: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH] c/r: [signal 3/3] pending signals (private, shared)
Date: Fri, 24 Jul 2009 08:59:39 -0400	[thread overview]
Message-ID: <4A69B03B.2010806@librato.com> (raw)
In-Reply-To: <20090724123629.GH11101-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>



Louis Rilling wrote:
> Hi Oren,
> 
> 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-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
>> ---
>>  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
> 
> [...]
> 
>> +
>> +static int restore_sigpending(struct ckpt_ctx *ctx, struct sigpending *pending)
>> +{
>> +	struct ckpt_hdr_sigpending *h;
>> +	struct ckpt_hdr_siginfo *si;
>> +	struct sigqueue *q, *n;
>> +	int ret = 0;
>> +
>> +	h = ckpt_read_buf_type(ctx, 0, CKPT_HDR_SIGPENDING);
>> +	if (IS_ERR(h))
>> +		return PTR_ERR(h);
>> +
>> +	INIT_LIST_HEAD(&pending->list);
>> +	load_sigset(&pending->signal, &h->signal);
>> +
>> +	si = h->siginfo;
>> +	while (h->nr_pending--) {
>> +		q = sigqueue_alloc();
> 
> This introduces a memory leak, since collect_signal() won't free q. Better to
> use __sigqueue_alloc() here, or clear the SIGQUEUE_PREALLOC flag.
> 

You're totally right.

I thought I needed it because of sigqueue_free() below, but in fact
it should be __sigqueue_alloc() and __sigqueue_free().

Thanks,

Oren.

> Thanks,
> 
> Louis
> 
>> +		if (!q) {
>> +			ret = -ENOMEM;
>> +			break;
>> +		}
>> +
>> +		ret = load_siginfo(&q->info, si++);
>> +		if (ret < 0) {
>> +			sigqueue_free(q);
>> +			break;
>> +		}
>> +
>> +		list_add_tail(&pending->list, &q->list);
>> +	}
>> +
>> +	if (ret < 0) {
>> +		list_for_each_entry_safe(q, n, &pending->list, list) {
>> +			list_del_init(&q->list);
>> +			sigqueue_free(q);
>> +		}
>> +	}
>> +
>> +	ckpt_hdr_put(ctx, h);
>> +	return ret;
>> +}
>> +
> 
> [...]
> 

  parent reply	other threads:[~2009-07-24 12:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-23 14:48 [PATCH] c/r: [signal 1/3] blocked and template for shared signals Oren Laadan
     [not found] ` <1248360514-20710-1-git-send-email-orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-07-23 14:48   ` [PATCH] c/r: [signal 2/3] checkpoint/restart of rlimit Oren Laadan
     [not found]     ` <1248360514-20710-2-git-send-email-orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-07-23 22:28       ` Serge E. Hallyn
     [not found]         ` <20090723222825.GA23596-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-07-24  1:39           ` Oren Laadan
     [not found]             ` <4A6910E5.4010605-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-07-24 14:22               ` Serge E. Hallyn
     [not found]                 ` <20090724142235.GB6910-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-07-24 17:11                   ` Oren Laadan
2009-07-24 20:04               ` Matt Helsley
2009-07-23 14:48   ` [PATCH] c/r: [signal 3/3] pending signals (private, shared) Oren Laadan
     [not found]     ` <1248360514-20710-3-git-send-email-orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-07-24 12:36       ` Louis Rilling
     [not found]         ` <20090724123629.GH11101-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>
2009-07-24 12:59           ` Oren Laadan [this message]
2009-07-24 13:13       ` Louis Rilling

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=4A69B03B.2010806@librato.com \
    --to=orenl-rdfvbdnroixbdgjk7y7tuq@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@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.