Re: [PATCH] sched: missing locking in sched_domains code

From: Andrew Morton
Date: Mon Apr 28 2008 - 03:30:23 EST


On Mon, 28 Apr 2008 09:09:46 +0200 Heiko Carstens <heiko.carstens@xxxxxxxxxx> wrote:

> On Sun, Apr 27, 2008 at 06:39:26PM -0700, Andrew Morton wrote:
> > On Sun, 27 Apr 2008 23:12:24 +0200 Heiko Carstens <heiko.carstens@xxxxxxxxxx> wrote:
> > > Index: linux-2.6/kernel/cpuset.c
> > > ===================================================================
> > > --- linux-2.6.orig/kernel/cpuset.c
> > > +++ linux-2.6/kernel/cpuset.c
> > > @@ -684,7 +684,9 @@ restart:
> > > rebuild:
> > > /* Have scheduler rebuild sched domains */
> > > get_online_cpus();
> > > + mutex_lock(&sched_domains_mutex);
> > > partition_sched_domains(ndoms, doms, dattr);
> > > + mutex_unlock(&sched_domains_mutex);
> > > put_online_cpus();
> > >
> >
> > It seems a bit fragile to take this lock in the caller without even adding
> > a comment at the callee site which documents the new locking rule.
> >
> > It would be more robust to take the lock within partition_sched_domains().
> >
> > partition_sched_domains() already covers itself with lock_doms_cur(). Can
> > we take that in arch_reinit_sched_domains() rather than adding the new lock?
>
> I think you meant taking it in partition_sched_domains?

What I meant was: rather than adding the new sched_domains_mutex, can we
instead call lock_doms_cur() from arch_reinit_sched_domains() and
sched_init_smp()? Borrow the existing lock?

Whether that makes sense depends upon what lock_doms_cur() semantically
*means*. As that appears to be somewhat of a secret, we get to decide ;)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/