[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A8CB750.7040509@cn.fujitsu.com>
Date: Thu, 20 Aug 2009 10:39:12 +0800
From: Li Zefan <lizf@...fujitsu.com>
To: Paul Menage <menage@...gle.com>
CC: akpm@...ux-foundation.org, bblum@...rew.cmu.edu,
linux-kernel@...r.kernel.org, containers@...ts.linux-foundation.org
Subject: Re: [PATCH 7/8] Adds functionality to read/write lock CLONE_THREAD
fork()ing per-threadgroup
Paul Menage wrote:
> From: Ben Blum <bblum@...gle.com>
>
>
> Adds functionality to read/write lock CLONE_THREAD fork()ing per-threadgroup
>
> This patch adds an rwsem that lives in a threadgroup's sighand_struct (next to
> the sighand's atomic count, to piggyback on its cacheline), and two functions
> in kernel/cgroup.c (for now) for easily+safely obtaining and releasing it. If
> another part of the kernel later wants to use such a locking mechanism, the
> CONFIG_CGROUPS ifdefs should be changed to a higher-up flag that CGROUPS and
> the other system would both depend on, and the lock/unlock functions could be
> moved to sched.c or so.
>
> Signed-off-by: Ben Blum <bblum@...gle.com>
> Signed-off-by: Paul Menage <menage@...gle.com>
>
Looks fine to me.
Acked-by: Li Zefan <lizf@...fujitsu.com>
...
> +struct sighand_struct *threadgroup_fork_lock(struct task_struct *tsk)
> +{
> + struct sighand_struct *sighand;
> + struct task_struct *p;
> +
> + /* tasklist lock protects sighand_struct's disappearance in exit(). */
> + read_lock(&tasklist_lock);
> + if (likely(tsk->sighand)) {
> + /* simple case - check the thread we were given first */
> + sighand = tsk->sighand;
> + } else {
> + sighand = NULL;
> + /*
> + * tsk is exiting; try to find another thread in the group
> + * whose sighand pointer is still alive.
> + */
> + rcu_read_lock();
since we are holding tasklist_lock, I think we don't need to
take rcu lock?
> + list_for_each_entry_rcu(p, &tsk->thread_group, thread_group) {
> + if (p->sighand) {
> + sighand = tsk->sighand;
s/tsk->sighand/p->sighand
> + break;
> + }
> + }
> + rcu_read_unlock();
> + }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists