the bitrig haesbaert_schedlock branch has been created by haesbaert.

it is 24 commits behind master, and 1 commit ahead.

commit a1cf85d085f5b69e839f5859e9ca9420486e493e
diff: https://github.com/bitrig/bitrig/commit/a1cf85d
author: Christiano F. Haesbaert <[email protected]>
date: Mon Dec 30 00:39:49 2013 +0100

Rework the SCHED_LOCK vs KERNEL_LOCK dance in mi_switch().

This avoids the lock/relock to fix lock ordering on mi_switch for all
the cases except one.

Before the idea was:
        - mi_switch() releases all kernel locks before context switching.
        - save the count in the stack.
        - context switch with SCHED_LOCK held.
        - wakeup, but to assure lock ordering it needs to:
                - release SCHED_LOCK
                - reacquire KERNEL_LOCK
                - acquire SCHED_LOCK

With this diff, the caller is responsible for doing this, so you can't
enter mi_switch with kernel lock now, you must release/reacquire
yourself, being careful to always grab SCHED_LOCK before releasing the
kernel locks, if not you lose atomicity before you can.

Next step is to make mi_switch() return with SCHED_LOCK unlocked, if
the caller wants it is his job, he _already_ lost atomicity. Most of
the cases mi_switch() relocks SCHED_LOCK only for the caller to unlock
it, which is pretty stupid.

The proc_stop() bits are slightly more tricky as we don't have the
current ipl in that context, I adopted a conservative approach for now.

Conflicts:
        sys/kern/kern_ithread.c
        sys/kern/kern_sched.c
        sys/kern/kern_sig.c
        sys/kern/kern_synch.c
        sys/kern/sched_bsd.c
        sys/sys/systm.h

M       sys/kern/kern_lock.c
M       sys/kern/kern_sched.c
M       sys/kern/kern_sig.c
M       sys/kern/kern_synch.c
M       sys/kern/sched_bsd.c
M       sys/sys/proc.h
M       sys/sys/systm.h

Reply via email to