svn commit: r220454 - in head: share/man/man4 sys/cam/ata sys/conf

Jaakko Heinonen jh at FreeBSD.org
Wed Apr 13 14:33:52 UTC 2011


On 2011-04-08, Alexander Motin wrote:
>   - Add kern.cam.ada.X.write_cache tunables/sysctls to control write caching
>   on per-device basis.

> --- head/sys/cam/ata/ata_da.c	Fri Apr  8 14:39:41 2011	(r220453)
> +++ head/sys/cam/ata/ata_da.c	Fri Apr  8 14:42:29 2011	(r220454)
> @@ -738,6 +773,10 @@ adaregister(struct cam_periph *periph, v
>  		softc->quirks = ((struct ada_quirk_entry *)match)->quirks;
>  	else
>  		softc->quirks = ADA_Q_NONE;
> +	softc->write_cache = -1;
> +	snprintf(announce_buf, sizeof(announce_buf),
> +	    "kern.cam.ada.%d.writa_cache", periph->unit_number);
                                ^^^
Typo.

> +	TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);

TUNABLE_INT_FETCH() uses getenv() which may sleep (due to M_WAITOK
allocation). You will get a witness warning (see below) on a WITNESS
enabled kernel because the sim mutex is held in adaregister(). The
tunable must exist, otherwise getenv() doesn't allocate memory.

cd(4) has the same problem for kern.cam.cd.%d.minimum_cmd_size tunable
and da(4) for kern.cam.da.%d.minimum_cmd_size tunable.

I am considering adding WITNESS_WARN() to getenv() to expose these bugs
early.

uma_zalloc_arg: zone "16" with the following non-sleepable locks held:
exclusive sleep mutex ATA state lock (ATA state lock) r = 0 (0xc42e0174) locked @ /home/jaakko/src/head/sys/cam/cam_xpt.c:1991
KDB: stack backtrace:
db_trace_self_wrapper(c0cccf87,c0cca676,192,0,0,...) at db_trace_self_wrapper+0x26
kdb_backtrace(7c7,0,ffffffff,c0f8d60c,d8cc8cfc,...) at kdb_backtrace+0x2a
_witness_debugger(c0ccfeaa,d8cc8d10,4,1,0,...) at _witness_debugger+0x25
witness_warn(5,0,c0d0361e,c0c81bfe,c0cbef65,...) at witness_warn+0x1fe
uma_zalloc_arg(c15b99c0,0,2,2,0,...) at uma_zalloc_arg+0x34
malloc(2,c0dd29f0,2,156,310000,...) at malloc+0x113
getenv(d8cc90b8,d8cc8ec4,a,d8cc8efc,d8cc90b8,...) at getenv+0xea
getenv_quad(d8cc90b8,d8cc8ee0,d8cc8efc,d8cc8efc,d8cc9118,...) at getenv_quad+0x1a
getenv_int(d8cc90b8,c456b044,c0c2a8fe,0,c048d560,...) at getenv_int+0x18
adaregister(c4219080,d8cc9694,d8cc9170,0,0,...) at adaregister+0x1ef

-- 
Jaakko


More information about the svn-src-all mailing list