From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932555AbYD1HaV (ORCPT ); Mon, 28 Apr 2008 03:30:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1763654AbYD1HaI (ORCPT ); Mon, 28 Apr 2008 03:30:08 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:44820 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763172AbYD1HaH (ORCPT ); Mon, 28 Apr 2008 03:30:07 -0400 Date: Mon, 28 Apr 2008 00:28:53 -0700 From: Andrew Morton To: Heiko Carstens Cc: Gautham R Shenoy , Ingo Molnar , Paul Jackson , linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched: missing locking in sched_domains code Message-Id: <20080428002853.1693e7fd.akpm@linux-foundation.org> In-Reply-To: <20080428070946.GA4507@osiris.boeblingen.de.ibm.com> References: <20080427211224.GA21830@osiris.boeblingen.de.ibm.com> <20080427183926.acb66fff.akpm@linux-foundation.org> <20080428070946.GA4507@osiris.boeblingen.de.ibm.com> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.5; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 28 Apr 2008 09:09:46 +0200 Heiko Carstens 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 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 ;)