Re: proc lock might become an sx lock?

From: Pawel Jakub Dawidek <pjd_at_FreeBSD.org>
Date: Tue, 13 Mar 2007 22:43:29 +0100
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 _at_ 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!

Received on Tue Mar 13 2007 - 21:00:55 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:06 UTC