Linux Container Development
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Nadia.Derbey-6ktuUTfB/bM@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Pierre Peiffer <pierre.peiffer-6ktuUTfB/bM@public.gmane.org>
Subject: Re: [RFC PATCH 3/6] IPC/sem: start/stop operations for /proc/pid/semundo
Date: Wed, 25 Jun 2008 15:39:50 -0500	[thread overview]
Message-ID: <20080625203950.GC16374@us.ibm.com> (raw)
In-Reply-To: <20080625135539.139605000-6ktuUTfB/bM@public.gmane.org>

Quoting Nadia.Derbey-6ktuUTfB/bM@public.gmane.org (Nadia.Derbey-6ktuUTfB/bM@public.gmane.org):
> PATCH [03/06]
> 
> This patch introduces the .start and .stop seq operations for
> /proc/pid/semundo.
> 
> Signed-off-by: Pierre Peiffer <pierre.peiffer-6ktuUTfB/bM@public.gmane.org>
> Signed-off-by: Nadia Derbey <Nadia.Derbey-6ktuUTfB/bM@public.gmane.org>

Acked-by: Serge Hallyn <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

> ---
>  ipc/sem.c |   43 +++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 41 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6.26-rc5-mm3/ipc/sem.c
> ===================================================================
> --- linux-2.6.26-rc5-mm3.orig/ipc/sem.c	2008-06-24 10:59:46.000000000 +0200
> +++ linux-2.6.26-rc5-mm3/ipc/sem.c	2008-06-24 12:32:36.000000000 +0200
> @@ -1400,7 +1400,42 @@ struct undo_list_data {
>  /* iterator */
>  static void *semundo_start(struct seq_file *m, loff_t *ppos)
>  {
> -	return NULL;
> +	struct undo_list_data *data = m->private;
> +	struct sem_undo_list *ulp = data->undo_list;
> +	struct sem_undo	*undo;
> +	loff_t pos = *ppos;
> +
> +	if (!ulp)
> +		return NULL;
> +
> +	if (pos < 0)
> +		return NULL;
> +
> +	/* If ulp is not NULL, it means that we've successfully grabbed
> +	 * a refcnt in semundo_open. That prevents the undo_list from being
> +	 * freed.
> +	 *
> +	 * Note:
> +	 * 1) the sem_undo structure is RCU-protected. So take the rcu read
> +	 *    lock and only release it during the .stop operation.
> +	 * 2) we accept to release the undo_list lock (i.e. we allow the list
> +	 *    to change) between each iteration, instead of taking that lock
> +	 *    during the .start and releasing it during the .stop operation.
> +	 *    This is to reduce the performance impact on the access to the
> +	 *    undo_list.
> +	 */
> +	rcu_read_lock();
> +	spin_lock(&ulp->lock);
> +	list_for_each_entry_rcu(undo, &ulp->list_proc, list_proc) {
> +		if ((undo->semid != -1) && !(pos--))
> +			break;
> +	}
> +	spin_unlock(&ulp->lock);
> +
> +	if (&undo->list_proc == &ulp->list_proc)
> +		return NULL;
> +
> +	return undo;
>  }
> 
>  static void *semundo_next(struct seq_file *m, void *v, loff_t *ppos)
> @@ -1410,7 +1445,11 @@ static void *semundo_next(struct seq_fil
> 
>  static void semundo_stop(struct seq_file *m, void *v)
>  {
> -	return;
> +	struct undo_list_data *data = m->private;
> +	struct sem_undo_list *ulp = data->undo_list;
> +
> +	if (ulp)
> +		rcu_read_unlock();
>  }
> 
>  static int semundo_show(struct seq_file *m, void *v)
> 
> --

  parent reply	other threads:[~2008-06-25 20:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-25 13:49 [RFC PATCH 0/6] SYSVIPC/semaphores - allow saving/restoring a process' semundo_list Nadia.Derbey-6ktuUTfB/bM
2008-06-25 13:49 ` [RFC PATCH 1/6] IPC/sem: RCU-protect the process semundo list Nadia.Derbey-6ktuUTfB/bM
     [not found]   ` <20080625135538.385496000-6ktuUTfB/bM@public.gmane.org>
2008-06-25 20:33     ` Serge E. Hallyn
2008-06-25 13:49 ` [RFC PATCH 2/6] IPC/sem: per <pid> semundo file in procfs Nadia.Derbey-6ktuUTfB/bM
     [not found]   ` <20080625135538.762662000-6ktuUTfB/bM@public.gmane.org>
2008-06-25 20:33     ` Serge E. Hallyn
2008-06-26  5:08     ` Michael Kerrisk
     [not found]       ` <517f3f820806252208m1f5b91dfm38b8babff73adf72-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-06-26  6:07         ` Nadia Derbey
2008-06-25 13:49 ` [RFC PATCH 3/6] IPC/sem: start/stop operations for /proc/pid/semundo Nadia.Derbey-6ktuUTfB/bM
     [not found]   ` <20080625135539.139605000-6ktuUTfB/bM@public.gmane.org>
2008-06-25 20:39     ` Serge E. Hallyn [this message]
2008-06-25 13:49 ` [RFC PATCH 4/6] IPC/sem: next " Nadia.Derbey-6ktuUTfB/bM
     [not found]   ` <20080625135539.519489000-6ktuUTfB/bM@public.gmane.org>
2008-06-25 20:57     ` Serge E. Hallyn
     [not found]       ` <20080625205719.GD16374-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-06-26  5:35         ` Nadia Derbey
2008-06-25 13:49 ` [RFC PATCH 5/6] IPC/sem: .show operation " Nadia.Derbey-6ktuUTfB/bM
     [not found]   ` <20080625135539.893049000-6ktuUTfB/bM@public.gmane.org>
2008-06-25 20:58     ` Serge E. Hallyn
2008-06-25 13:49 ` [RFC PATCH 6/6] IPC/sem: .write operation for /proc/<self>/semundo Nadia.Derbey-6ktuUTfB/bM
     [not found]   ` <20080625135540.271934000-6ktuUTfB/bM@public.gmane.org>
2008-06-25 21:09     ` Serge E. Hallyn
     [not found]       ` <20080625210937.GF16374-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-06-26  5:44         ` Nadia Derbey
2008-06-27 14:06     ` Serge E. Hallyn
     [not found]       ` <20080627140607.GA20581-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-06-27 14:12         ` Nadia Derbey
2008-06-30  8:37         ` Nadia Derbey

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=20080625203950.GC16374@us.ibm.com \
    --to=serue-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=Nadia.Derbey-6ktuUTfB/bM@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=pierre.peiffer-6ktuUTfB/bM@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