The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] cgroups: use task_lock() for access tsk->cgroups safe in cgroup_clone()
@ 2008-11-21  8:49 Lai Jiangshan
  2008-11-21 19:18 ` Paul Menage
  0 siblings, 1 reply; 2+ messages in thread
From: Lai Jiangshan @ 2008-11-21  8:49 UTC (permalink / raw)
  To: Andrew Morton, Paul Menage, Linux Kernel Mailing List,
	Linux Containers


use task_lock() protect tsk->cgroups and get_css_set(tsk->cgroups)


Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 358e775..ddc10ac 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2933,6 +2943,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 		mutex_unlock(&cgroup_mutex);
 		return 0;
 	}
+	task_lock(tsk);
 	cg = tsk->cgroups;
 	parent = task_cgroup(tsk, subsys->subsys_id);
 
@@ -2941,6 +2952,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
 
 	/* Keep the cgroup alive */
 	get_css_set(cg);
+	task_unlock(tsk);
 	mutex_unlock(&cgroup_mutex);
 
 	/* Now do the VFS work to create a cgroup */


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cgroups: use task_lock() for access tsk->cgroups safe in  cgroup_clone()
  2008-11-21  8:49 [PATCH] cgroups: use task_lock() for access tsk->cgroups safe in cgroup_clone() Lai Jiangshan
@ 2008-11-21 19:18 ` Paul Menage
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Menage @ 2008-11-21 19:18 UTC (permalink / raw)
  To: Lai Jiangshan; +Cc: Andrew Morton, Linux Kernel Mailing List, Linux Containers

On Fri, Nov 21, 2008 at 12:49 AM, Lai Jiangshan <laijs@cn.fujitsu.com> wrote:
>
> use task_lock() protect tsk->cgroups and get_css_set(tsk->cgroups)
>
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>

Sounds reasonable, given the race with cgroup_exit()

Reviewed-by: Paul Menage <menage@google.com>

Thanks,

Paul

> ---
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 358e775..ddc10ac 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -2933,6 +2943,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
>                mutex_unlock(&cgroup_mutex);
>                return 0;
>        }
> +       task_lock(tsk);
>        cg = tsk->cgroups;
>        parent = task_cgroup(tsk, subsys->subsys_id);
>
> @@ -2941,6 +2952,7 @@ int cgroup_clone(struct task_struct *tsk, struct cgroup_subsys *subsys,
>
>        /* Keep the cgroup alive */
>        get_css_set(cg);
> +       task_unlock(tsk);
>        mutex_unlock(&cgroup_mutex);
>
>        /* Now do the VFS work to create a cgroup */
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-11-21 19:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21  8:49 [PATCH] cgroups: use task_lock() for access tsk->cgroups safe in cgroup_clone() Lai Jiangshan
2008-11-21 19:18 ` Paul Menage

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox