From 3fc0f8b973fdc2f392a3234d653e09d71e2aab98 Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 17 Sep 2007 05:31:39 +0000 Subject: - Move all of the PS_ flags into either p_flag or td_flags. - p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or previously the sched_lock. These bugs have existed for some time. - Allow swapout to try each thread in a process individually and then swapin the whole process if any of these fail. This allows us to move most scheduler related swap flags into td_flags. - Keep ki_sflag for backwards compat but change all in source tools to use the new and more correct location of P_INMEM. Reported by: pho Reviewed by: attilio, kib Approved by: re (kensmith) --- sys/kern/sched_4bsd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sys/kern/sched_4bsd.c') diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index d96c27e..3692f0f 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1086,8 +1086,8 @@ sched_add(struct thread *td, int flags) ("sched_add: trying to run inhibited thread")); KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)), ("sched_add: bad thread state")); - KASSERT(td->td_proc->p_sflag & PS_INMEM, - ("sched_add: process swapped out")); + KASSERT(td->td_flags & TDF_INMEM, + ("sched_add: thread swapped out")); CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", td, td->td_proc->p_comm, td->td_priority, curthread, curthread->td_proc->p_comm); @@ -1155,8 +1155,8 @@ sched_add(struct thread *td, int flags) ("sched_add: trying to run inhibited thread")); KASSERT((TD_CAN_RUN(td) || TD_IS_RUNNING(td)), ("sched_add: bad thread state")); - KASSERT(td->td_proc->p_sflag & PS_INMEM, - ("sched_add: process swapped out")); + KASSERT(td->td_flags & TDF_INMEM, + ("sched_add: thread swapped out")); CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)", td, td->td_proc->p_comm, td->td_priority, curthread, curthread->td_proc->p_comm); @@ -1200,8 +1200,8 @@ sched_rem(struct thread *td) struct td_sched *ts; ts = td->td_sched; - KASSERT(td->td_proc->p_sflag & PS_INMEM, - ("sched_rem: process swapped out")); + KASSERT(td->td_flags & TDF_INMEM, + ("sched_rem: thread swapped out")); KASSERT(TD_ON_RUNQ(td), ("sched_rem: thread not on run queue")); mtx_assert(&sched_lock, MA_OWNED); @@ -1253,8 +1253,8 @@ sched_choose(void) runq_remove(rq, ts); ts->ts_flags |= TSF_DIDRUN; - KASSERT(ts->ts_thread->td_proc->p_sflag & PS_INMEM, - ("sched_choose: process swapped out")); + KASSERT(ts->ts_thread->td_flags & TDF_INMEM, + ("sched_choose: thread swapped out")); return (ts->ts_thread); } return (PCPU_GET(idlethread)); -- cgit v1.1