[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090805102057.GT29252@hawkmoon.kerlabs.com>
Date: Wed, 5 Aug 2009 12:20:57 +0200
From: Louis Rilling <Louis.Rilling@...labs.com>
To: Paul Menage <menage@...gle.com>
Cc: Benjamin Blum <bblum@...gle.com>,
containers@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Subject: Re: [PATCH 6/6] Makes procs file writable to move all threads by
tgid at once
On 04/08/09 12:28 -0700, Paul Menage wrote:
> On Tue, Aug 4, 2009 at 12:14 PM, Benjamin Blum<bblum@...gle.com> wrote:
> >
> > Hmm, the tasklist_lock section in fork() is entirely inside the
> > read-lock. Presumably then iterating the threadgroup list to take all
> > rwsems is safe from a race in which one thread escapes?
> >
>
> I think so - the write-side locking would be something like:
>
> again:
> read_lock(&tasklist_lock);
> find first not-yet-locked task t
> while (t != group_leader) {
> if (!down_write_trylock(&t->threadgroup_stability_mutex)) {
> get_task_struct(t);
> read_unlock(&tasklist_lock);
> down_write(&t->threadgroup_stability_mutex);
> put_task_struct(t);
> goto again;
> }
> t = t->next_thread;
> }
> read_unlock(&tasklist_lock);
The downside of this is teaching lockdep about this recursive locking. Not that
simple actually... so that such cases are currently handled using a higher-level
lock that prevents races in locking the whole chain (there was one such example
for locking all vmas with KVM). IIUC, the intent here is to avoid such
higher-level lock.
Louis
--
Dr Louis Rilling Kerlabs
Skype: louis.rilling Batiment Germanium
Phone: (+33|0) 6 80 89 08 23 80 avenue des Buttes de Coesmes
http://www.kerlabs.com/ 35700 Rennes
Download attachment "signature.asc" of type "application/pgp-signature" (198 bytes)
Powered by blists - more mailing lists