proc lock might become an sx lock?

Pawel Jakub Dawidek pjd at FreeBSD.org
Tue Mar 13 22:00:55 UTC 2007


On Thu, Mar 08, 2007 at 07:18:13PM -0800, Julian Elischer wrote:
> currently the thread list in the process is protected by the sched lock.
> for a process with a lot of threads this is probably not a good idea.
> I experimented with making it protected by the proc loc, but the following sort of thing happens a lot:
> 
>        sx_slock(&allproc_lock);
>        FOREACH_PROC_IN_SYSTEM(p) {
>                mtx_lock_spin(&sched_lock);
>                FOREACH_THREAD_IN_PROC(p, td) {
>                        ...
>                }
>                mtx_unlock_spin(&sched_lock);
> 
> Changing the protection of the thread list to use the proc lock would
> replace the sched_lock with the proc lock, but.....
> this has a problem.. the proc lock is a mutex and can therefore not be inside the
> allproc_lock.

Why not? Acquiring sx lock first and then a mutex is fine. The other way
around is illegal.

> and in fact you get:
> 
> Trying to mount root from ufs:/dev/aacd0s1d
> panic: blockable sleep lock (sleep mutex) process lock @ kern/sched_4bsd.c:383

This is because it's order is hardcoded in subr_witness.c.
Move:

	{ "process lock", &lock_class_mtx_sleep },

a bit up and change lock_class_mtx_sleep to lock_class_sx.

PS. I'm not familiar with schedulers, so I don't know if sched_lock can
be replaced there.

-- 
Pawel Jakub Dawidek                       http://www.wheel.pl
pjd at FreeBSD.org                           http://www.FreeBSD.org
FreeBSD committer                         Am I Evil? Yes, I Am!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070313/3f9ac9a1/attachment.pgp


More information about the freebsd-current mailing list