From: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org
Subject: [PATCH 1/2] Add ipc_namespace to struct sem_undo_list
Date: Thu, 5 Aug 2010 10:57:05 -0700 [thread overview]
Message-ID: <1281031026-2357-2-git-send-email-danms@us.ibm.com> (raw)
In-Reply-To: <1281031026-2357-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Checkpoint/Restart needs to have a pointer to the ipc_namespace that the
sem_undo_list applies to in order to properly bring up and tear down
the object hash. This patch adds a pointer to the namespace to the list
structure, as well as breaks out the allocation of the undo list to a
separate function (which is needed in a later C/R patch anyway).
Signed-off-by: Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
include/linux/sem.h | 2 ++
ipc/sem.c | 30 +++++++++++++++++++++---------
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/include/linux/sem.h b/include/linux/sem.h
index 8a4adbe..8cf9636 100644
--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -127,12 +127,14 @@ struct sem_undo {
short * semadj; /* array of adjustments, one per semaphore */
};
+struct ipc_namespace;
/* sem_undo_list controls shared access to the list of sem_undo structures
* that may be shared among all a CLONE_SYSVSEM task group.
*/
struct sem_undo_list {
atomic_t refcnt;
spinlock_t lock;
+ struct ipc_namespace *ipc_ns;
struct list_head list_proc;
};
diff --git a/ipc/sem.c b/ipc/sem.c
index 37da85e..e439b73 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -983,6 +983,21 @@ asmlinkage long SyS_semctl(int semid, int semnum, int cmd, union semun arg)
SYSCALL_ALIAS(sys_semctl, SyS_semctl);
#endif
+static struct sem_undo_list *alloc_undo_list(struct ipc_namespace *ipc_ns)
+{
+ struct sem_undo_list *undo_list;
+
+ undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL);
+ if (undo_list == NULL)
+ return NULL;
+ spin_lock_init(&undo_list->lock);
+ atomic_set(&undo_list->refcnt, 1);
+ INIT_LIST_HEAD(&undo_list->list_proc);
+ undo_list->ipc_ns = ipc_ns;
+
+ return undo_list;
+}
+
/* If the task doesn't already have a undo_list, then allocate one
* here. We guarantee there is only one thread using this undo list,
* and current is THE ONE
@@ -994,19 +1009,16 @@ SYSCALL_ALIAS(sys_semctl, SyS_semctl);
*
* This can block, so callers must hold no locks.
*/
-static inline int get_undo_list(struct sem_undo_list **undo_listp)
+static inline int get_undo_list(struct sem_undo_list **undo_listp,
+ struct ipc_namespace *ipc_ns)
{
struct sem_undo_list *undo_list;
undo_list = current->sysvsem.undo_list;
if (!undo_list) {
- undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL);
- if (undo_list == NULL)
+ undo_list = alloc_undo_list(ipc_ns);
+ if (!undo_list)
return -ENOMEM;
- spin_lock_init(&undo_list->lock);
- atomic_set(&undo_list->refcnt, 1);
- INIT_LIST_HEAD(&undo_list->list_proc);
-
current->sysvsem.undo_list = undo_list;
}
*undo_listp = undo_list;
@@ -1057,7 +1069,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
int nsems;
int error;
- error = get_undo_list(&ulp);
+ error = get_undo_list(&ulp, ns);
if (error)
return ERR_PTR(error);
@@ -1328,7 +1340,7 @@ int copy_semundo(unsigned long clone_flags, struct task_struct *tsk)
int error;
if (clone_flags & CLONE_SYSVSEM) {
- error = get_undo_list(&undo_list);
+ error = get_undo_list(&undo_list, tsk->nsproxy->ipc_ns);
if (error)
return error;
atomic_inc(&undo_list->refcnt);
--
1.7.1.1
next prev parent reply other threads:[~2010-08-05 17:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-05 17:57 Add support for SEM_UNDO, round three Dan Smith
[not found] ` <1281031026-2357-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-05 17:57 ` Dan Smith [this message]
[not found] ` <1281031026-2357-2-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-05 21:50 ` [PATCH 1/2] Add ipc_namespace to struct sem_undo_list Matt Helsley
2010-08-05 22:42 ` Oren Laadan
2010-08-05 17:57 ` [PATCH 2/2] Add support for the per-task sem_undo list (v3.01) Dan Smith
[not found] ` <1281031026-2357-3-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-05 21:48 ` Matt Helsley
[not found] ` <20100805214842.GP2927-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-08-05 22:40 ` Oren Laadan
[not found] ` <4C5B3DF9.4000907-eQaUEPhvms7ENvBUuze7eA@public.gmane.org>
2010-08-05 23:49 ` Matt Helsley
[not found] ` <20100805234902.GS2927-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2010-08-06 14:31 ` Dan Smith
-- strict thread matches above, loose matches on Subject: below --
2010-08-10 16:20 SEM_UNDO support round...four? Dan Smith
[not found] ` <1281457254-18890-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-10 16:20 ` [PATCH 1/2] Add ipc_namespace to struct sem_undo_list Dan Smith
[not found] ` <1281457254-18890-2-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-11 3:00 ` Matt Helsley
2010-08-04 17:02 Support for SEM_UNDO, round 2 Dan Smith
[not found] ` <1280941345-27566-1-git-send-email-danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-08-04 17:02 ` [PATCH 1/2] Add ipc_namespace to struct sem_undo_list Dan Smith
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=1281031026-2357-2-git-send-email-danms@us.ibm.com \
--to=danms-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@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