Module Name: src Committed By: dyoung Date: Fri Apr 30 21:17:22 UTC 2010
Modified Files: src/sys/kern: subr_autoconf.c Log Message: IPL_VM is the highest interrupt priority where alldevs is read/written, and acquiring alldevs_mtx already blocks those interrupts, so delete the splhigh()/splx() in config_alldevs_lock()/_unlock(). Release alldevs_mtx while freeing memory with kmem_free(9); according to new documentation, kmem_free(9) can sleep! :-) Thanks to rmind@ for the tip. Next step: use finer-grained locking, probably by adding a mutex to cfdriver_t. And after that: make sure that all threads of execution are out of the device_t and/or softc before releasing their memory. To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 src/sys/kern/subr_autoconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.205 src/sys/kern/subr_autoconf.c:1.206 --- src/sys/kern/subr_autoconf.c:1.205 Mon Apr 19 11:20:56 2010 +++ src/sys/kern/subr_autoconf.c Fri Apr 30 21:17:22 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.205 2010/04/19 11:20:56 jruoho Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.206 2010/04/30 21:17:22 dyoung Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.205 2010/04/19 11:20:56 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.206 2010/04/30 21:17:22 dyoung Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1118,7 +1118,9 @@ * not hold alldevs_mtx, try again. */ if (cd->cd_devs != osp) { + mutex_exit(&alldevs_mtx); kmem_free(nsp, sizeof(device_t[new])); + mutex_enter(&alldevs_mtx); continue; } @@ -1128,8 +1130,11 @@ cd->cd_ndevs = new; cd->cd_devs = nsp; - if (old != 0) + if (old != 0) { + mutex_exit(&alldevs_mtx); kmem_free(osp, sizeof(device_t[old])); + mutex_enter(&alldevs_mtx); + } } alldevs_nwrite--; } @@ -2005,11 +2010,8 @@ static int config_alldevs_lock(void) { - int s; - - s = splhigh(); mutex_enter(&alldevs_mtx); - return s; + return 0; } static void @@ -2027,11 +2029,11 @@ config_dump_garbage(&af->af_garbage); } +/*ARGSUSED*/ static void config_alldevs_unlock(int s) { mutex_exit(&alldevs_mtx); - splx(s); } /*