On Sun, Apr 27, 2008 at 06:39:26PM -0700, Andrew Morton wrote:I think you meant taking it in partition_sched_domains? But anyway, I moved it all over to sched.c. So here's the new patch. Shorter and doesn't export a new lock :) Subject: [PATCH] sched: fix sched_domains locking From: Heiko Carstens <heiko.carstens@de.ibm.com> Concurrent calls to detach_destroy_domains and arch_init_sched_domains were prevented by the old scheduler subsystem cpu hotplug mutex. When this got converted to get_online_cpus() the locking got broken. Unlike before now several processes can concurrently enter the critical sections that were protected by the old lock. So add a new sched_domains_mutex which protects these sections again. Cc: Gautham R Shenoy <ego@in.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Jackson <pj@sgi.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> --- kernel/sched.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) Index: linux-2.6/kernel/sched.c =================================================================== --- linux-2.6.orig/kernel/sched.c +++ linux-2.6/kernel/sched.c @@ -7730,6 +7730,12 @@ static int dattrs_equal(struct sched_dom } /* + * Protects against concurrent calls to detach_destroy_domains + * and arch_init_sched_domains. + */ +static DEFINE_MUTEX(sched_domains_mutex); + +/* * Partition sched domains as specified by the 'ndoms_new' * cpumasks in the array doms_new[] of cpumasks. This compares * doms_new[] to the current sched domain partitioning, doms_cur[]. @@ -7756,7 +7762,8 @@ void partition_sched_domains(int ndoms_n int i, j; lock_doms_cur(); - + mutex_lock(&sched_domains_mutex); + /* always unregister in case we don't destroy any domains */ unregister_sched_domain_sysctl(); @@ -7804,6 +7811,7 @@ match2: register_sched_domain_sysctl(); + mutex_unlock(&sched_domains_mutex); unlock_doms_cur(); } @@ -7813,8 +7821,10 @@ int arch_reinit_sched_domains(void) int err; get_online_cpus(); + mutex_lock(&sched_domains_mutex); detach_destroy_domains(&cpu_online_map); err = arch_init_sched_domains(&cpu_online_map); + mutex_unlock(&sched_domains_mutex); put_online_cpus(); return err; @@ -7932,10 +7942,12 @@ void __init sched_init_smp(void) BUG_ON(sched_group_nodes_bycpu == NULL); #endif get_online_cpus(); + mutex_lock(&sched_domains_mutex); arch_init_sched_domains(&cpu_online_map); cpus_andnot(non_isolated_cpus, cpu_possible_map, cpu_isolated_map); if (cpus_empty(non_isolated_cpus)) cpu_set(smp_processor_id(), non_isolated_cpus); + mutex_unlock(&sched_domains_mutex); put_online_cpus(); /* XXX: Theoretical race here - CPU may be hotplugged now */ hotcpu_notifier(update_sched_domains, 0); --
| Bron Gondwana | BUG: mmapfile/writev spurious zero bytes (x86_64/not i386, bisected, reproducable) |
| Gabriel C | Re: [Announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] |
| David Miller | [GIT]: Networking |
| Dave Young | Re: 2.6.24-rc3-mm1 |
git: | |
| Matthieu Moy | git push to a non-bare repository |
| Josh Boyer | git-unpack-objects |
| Linus Torvalds | Re: Problem with a push |
| Johannes Schindelin | Re: Git-windows and git-svn? |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| James | Re: OBSD on MacBook |
| Alexey Suslikov | OT: OpenBSD on Asus eeePC |
| Daniel Ouellet | Re: Show your appreciation and get your 4.2 DVD |
| David Pottage | Re: My experience with the Freerunner |
| "Marco Trevisan (Treviño)" | Re: Car charger to GTA02 |
| Neng-Yu Tu (Tony Tu) | GTA02 GPS rework for SD card interference issue |
| Christ van Willegen | Public build host (proposal) |
| Linux Bootup hangs after adding RealTime Premption and HR-Timer | 27 minutes ago | Linux kernel |
| SATA 2 size problems | 1 hour ago | Windows |
| problem with 2.6 kernel driver for a USB MAG Stripe Reader as HID device. | 14 hours ago | Linux kernel |
| get_user_pages failure | 15 hours ago | Linux kernel |
| Reading linux kernel | 16 hours ago | Linux kernel |
| High level of Seagate 2.5" SATA drives failing | 22 hours ago | Hardware |
| Resetting the bios password for Toshiba Laptop | 1 day ago | Hardware |
| Linux 2.6.22 slowly RUNS OUT OF LOWMEM | 1 day ago | Linux kernel |
| Questions about modules | 1 day ago | Linux kernel |
| KDB | 2 days ago | Linux kernel |
