Subject: sysmon vs mutexes
To: None <>
From: Juan RP <>
List: tech-kern
Date: 02/19/2007 19:38:52

as you might know, two days ago I sent patches to Andrew Doran
to convert simple_locks/lockmgr and ltsleep/wakeup pairs in parts of
the sysmon code. I thought that was ok because I was using a kernel
without LOCKDEBUG enabled... sigh.

After booting a kernel with LOCKDEBUG, there were uninitialized locks
somewhere in the code... so we did start searching what was wrong,
and we know what was the problem:

* Drivers using the envsys framework usually are using
* dev/acpi/acpi_apm uses sysmonioctl_envsys() directly.
* Any code in the kernel might call sysmon_envsys_find().

My original patches were initializing the mutexes in
sysmon_envsys_register() (I didn't know that acpi_apm.c use
sysmonioctl_envsys() directly), so every time that apmd was about to
run, BOOM.

So how we did not find any easy solution and the changes were reverted.

This morning I have found a way to make this work, and now I'm
running a kernel with sysmon_envsys.c converted, the patch is at:

But this way seems not the correct way to initialize the mutexes,
because right now I'm using a function for initialization and I run
it in the functions that were having errors.

I would like to know if there's a better way to make them work
correctly... do you have any suggestion or comment?


Juan RP's blog - NetBSD/pkgsrc news in Spanish