Final version with thread locking.
authorAnton Eisenbraun <anton@localhost.localdomain>
Mon, 27 Jan 2014 15:42:19 +0000 (16:42 +0100)
committerAnton Eisenbraun <anton@localhost.localdomain>
Mon, 27 Jan 2014 15:42:19 +0000 (16:42 +0100)
17 files changed:
sys/geom/geom_kern.c
sys/kern/init_main.c
sys/kern/kern_clock.c
sys/kern/kern_cpuset.c
sys/kern/kern_fork.c
sys/kern/kern_idle.c
sys/kern/kern_intr.c
sys/kern/kern_kthread.c
sys/kern/kern_resource.c
sys/kern/kern_switch.c
sys/kern/kern_synch.c
sys/kern/kern_umtx.c
sys/kern/subr_sleepqueue.c
sys/kern/subr_taskqueue.c
sys/kern/subr_trap.c
sys/kern/vfs_subr.c
sys/vm/vm_zeroidle.c

index 68269f5..4d76d29 100644 (file)
@@ -90,14 +90,14 @@ g_up_procbody(void *arg)
 {
 
        mtx_assert(&Giant, MA_NOTOWNED);
-//     thread_lock(g_up_td);
-#warning "g_up_procbody lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(g_up_td);
+//#warning "g_up_procbody lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_prio(g_up_td, PRIBIO);
-//     thread_unlock(g_up_td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(g_up_td);
+//     intr_restore(rflags);
+//     enable_intr();
        for(;;) {
                g_io_schedule_up(g_up_td);
        }
@@ -108,14 +108,14 @@ g_down_procbody(void *arg)
 {
 
        mtx_assert(&Giant, MA_NOTOWNED);
-//     thread_lock(g_down_td);
-#warning "g_down_procbody lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(g_down_td);
+//#warning "g_down_procbody lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_prio(g_down_td, PRIBIO);
-//     thread_unlock(g_down_td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(g_down_td);
+//     intr_restore(rflags);
+//     enable_intr();
        for(;;) {
                g_io_schedule_down(g_down_td);
        }
@@ -126,14 +126,14 @@ g_event_procbody(void *arg)
 {
 
        mtx_assert(&Giant, MA_NOTOWNED);
-//     thread_lock(g_event_td);
-#warning "g_event_procbody lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(g_event_td);
+//#warning "g_event_procbody lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_prio(g_event_td, PRIBIO);
-//     thread_unlock(g_event_td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(g_event_td);
+//     intr_restore(rflags);
+//     enable_intr();
        g_run_events();
        /* NOTREACHED */
 }
index 62f825b..0283147 100644 (file)
@@ -272,8 +272,7 @@ restart:
                                    (*sipp)->udata);
                }
 #endif
-               if (last == 0xa800000)
-                       printf("0xa800000 done\n");
+
                /* Call function */
                (*((*sipp)->func))((*sipp)->udata);
 
@@ -847,14 +846,14 @@ kick_init(const void *udata __unused)
        struct thread *td;
 
        td = FIRST_THREAD_IN_PROC(initproc);
-//     thread_lock(td);
-#warning "ruxagg lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "ruxagg lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        TD_SET_CAN_RUN(td);
        sched_add(td, SRQ_BORING);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 }
 SYSINIT(kickinit, SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kick_init, NULL);
index 220f453..2a0841c 100644 (file)
@@ -537,15 +537,15 @@ hardclock_cnt(int cnt, int usermode)
                        flags |= TDF_PROFPEND | TDF_ASTPENDING;
                PROC_SUNLOCK(p);
        }
-//     thread_lock(td);
-#warning "hardclock_cnt lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "hardclock_cnt lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_tick(cnt);
        td->td_flags |= flags;
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 
 #ifdef HWPMC_HOOKS
        if (PMC_CPU_HAS_SAMPLES(PCPU_GET(cpuid)))
@@ -770,15 +770,15 @@ statclock_cnt(int cnt, int usermode)
        KTR_POINT2(KTR_SCHED, "thread", sched_tdname(td), "statclock",
            "prio:%d", td->td_priority, "stathz:%d", (stathz)?stathz:hz);
        SDT_PROBE2(sched, , , tick, td, td->td_proc);
-//     thread_lock_flags(td, MTX_QUIET);
-#warning "statclock_cnt lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock_flags(td, MTX_QUIET);
+//#warning "statclock_cnt lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        for ( ; cnt > 0; cnt--)
                sched_clock(td);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 #ifdef HWPMC_HOOKS
        if (td->td_intr_frame != NULL)
                PMC_SOFT_CALL_TF( , , clock, stat, td->td_intr_frame);
index 07db2b8..a770736 100644 (file)
@@ -714,10 +714,10 @@ cpuset_setthread(lwpid_t id, cpuset_t *mask)
        if (error)
                goto out;
        set = NULL;
-//     thread_lock(td);
-#warning "cpuset_setthread lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "cpuset_setthread lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        error = cpuset_shadow(td->td_cpuset, nset, mask);
        if (error == 0) {
                set = td->td_cpuset;
@@ -725,9 +725,9 @@ cpuset_setthread(lwpid_t id, cpuset_t *mask)
                sched_affinity(td);
                nset = NULL;
        }
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
        PROC_UNLOCK(p);
        if (set)
                cpuset_rel(set);
index fc5505f..765e55e 100644 (file)
@@ -487,14 +487,14 @@ do_fork(struct thread *td, int flags, struct proc *p2, struct thread *td2,
        /*
         * Allow the scheduler to initialize the child.
         */
-//     thread_lock(td);
-#warning "do_fork lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "do_fork lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_fork(td, td2);
-       intr_restore(rflags);
-       enable_intr();
-//     thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
+       thread_unlock(td);
        /*
         * Duplicate sub-structures as needed.
         * Increase reference counts on shared objects.
@@ -722,15 +722,15 @@ do_fork(struct thread *td, int flags, struct proc *p2, struct thread *td2,
                 * If RFSTOPPED not requested, make child runnable and
                 * add to run queue.
                 */
-//             thread_lock(td2);
-#warning "do_fork lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td2);
+//#warning "do_fork lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                TD_SET_CAN_RUN(td2);
                sched_add(td2, SRQ_BORING);
-//             thread_unlock(td2);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td2);
+//             intr_restore(rflags);
+//             enable_intr();
        }
 
        /*
@@ -993,12 +993,12 @@ fork_exit(void (*callout)(void *, struct trapframe *), void *arg,
                PCPU_SET(deadthread, NULL);
                thread_stash(dtd);
        }
-#warning "fork_exit unlock removed"
-//     thread_unlock(td);
+//#warning "fork_exit unlock removed"
+       thread_unlock(td);
 //     register_t rflags;
 //     rflags = intr_disable();
 //     intr_restore(rflags);
-       enable_intr();
+//     enable_intr();
 
        printf("fork_exit thread %s\n", td->td_name);
 
index 02df4b5..95846c2 100644 (file)
@@ -74,17 +74,17 @@ idle_setup(void *dummy)
                if (error)
                        panic("idle_setup: kproc_create error %d\n", error);
 
-//             thread_lock(td);
-#warning "idle_setup lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td);
+//#warning "idle_setup lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                TD_SET_CAN_RUN(td);
                td->td_flags |= TDF_IDLETD | TDF_NOLOAD;
                sched_class(td, PRI_IDLE);
                sched_prio(td, PRI_MAX_IDLE);
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
 #ifdef SMP
        }
 #endif
index 610cb79..f96a928 100644 (file)
@@ -183,14 +183,14 @@ ithread_update(struct intr_thread *ithd)
 #ifdef KTR
        sched_clear_tdname(td);
 #endif
-//     thread_lock(td);
-#warning "ithread_update lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "ithread_update lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_prio(td, pri);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 }
 
 /*
@@ -461,15 +461,15 @@ ithread_create(const char *name)
                    0, "intr", "%s", name);
        if (error)
                panic("kproc_create() failed with %d", error);
-//     thread_lock(td);
-#warning "ithread_create lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "ithread_create lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_class(td, PRI_ITHD);
        TD_SET_IWAIT(td);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
        td->td_pflags |= TDP_ITHREAD;
        ithd->it_thread = td;
        CTR2(KTR_INTR, "%s: created %s", __func__, name);
@@ -924,10 +924,10 @@ intr_event_schedule_thread(struct intr_event *ie)
         * put it on the runqueue.
         */
        it->it_need = 1;
-//     thread_lock(td);
-#warning "intr_event_schedule_thread lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "intr_event_schedule_thread lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        if (TD_AWAITING_INTR(td)) {
                CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
                    td->td_name);
@@ -937,9 +937,9 @@ intr_event_schedule_thread(struct intr_event *ie)
                CTR5(KTR_INTR, "%s: pid %d (%s): it_need %d, state %d",
                    __func__, p->p_pid, td->td_name, it->it_need, td->td_state);
        }
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 
        return (0);
 }
@@ -1145,14 +1145,14 @@ swi_add(struct intr_event **eventp, const char *name, driver_intr_t handler,
                return (error);
        if (pri == SWI_CLOCK) {
                td = ie->ie_thread->it_thread;
-//             thread_lock(td);
-#warning "swi_add lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td);
+//#warning "swi_add lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                td->td_flags |= TDF_NOLOAD;
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
        }
        return (0);
 }
@@ -1387,10 +1387,10 @@ ithread_loop(void *arg)
                 * lock.  This may take a while and it_need may get
                 * set again, so we have to check it again.
                 */
-//             thread_lock(td);
-#warning "ithread_loop lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td);
+//#warning "ithread_loop lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
 
                if (!ithd->it_need && !(ithd->it_flags & (IT_DEAD | IT_WAIT))) {
                        TD_SET_IWAIT(td);
@@ -1401,9 +1401,9 @@ ithread_loop(void *arg)
                        wake = 1;
                        ithd->it_flags &= ~IT_WAIT;
                }
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
 
                if (wake) {
                        wakeup(ithd);
index 4e2a7a9..8fa2bfe 100644 (file)
@@ -123,19 +123,19 @@ kproc_create(void (*func)(void *), void *arg,
        cpu_set_fork_handler(td, func, arg);
        /* Avoid inheriting affinity from a random parent. */
        cpuset_setthread(td->td_tid, cpuset_root);
-//     thread_lock(td);
-#warning "kproc_create lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "kproc_create lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        TD_SET_CAN_RUN(td);
        sched_prio(td, PVM);
        sched_user_prio(td, PUSER);
        /* Delay putting it on the run queue until now. */
        if (!(flags & RFSTOPPED))
                sched_add(td, SRQ_BORING); 
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 
        return 0;
 }
@@ -300,16 +300,16 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
        p->p_flag |= P_HADTHREADS;
        newtd->td_sigmask = oldtd->td_sigmask; /* XXX dubious */
        thread_link(newtd, p);
-//     thread_lock(oldtd);
-#warning "kthread_add lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(oldtd);
+//#warning "kthread_add lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        /* let the scheduler know about these things. */
        sched_fork_thread(oldtd, newtd);
        TD_SET_CAN_RUN(newtd);
-//     thread_unlock(oldtd);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(oldtd);
+//     intr_restore(rflags);
+//     enable_intr();
        PROC_UNLOCK(p);
 
        tidhash_add(newtd);
@@ -319,14 +319,14 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
 
        /* Delay putting it on the run queue until now. */
        if (!(flags & RFSTOPPED)) {
-//             thread_lock(newtd);
-#warning "kthread_add lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(newtd);
+//#warning "kthread_add lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                sched_add(newtd, SRQ_BORING); 
-//             thread_unlock(newtd);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(newtd);
+//             intr_restore(rflags);
+//             enable_intr();
        }
        if (newtdp)
                *newtdp = newtd;
index c7b2d9e..4798260 100644 (file)
@@ -1058,19 +1058,19 @@ void
 ruxagg(struct proc *p, struct thread *td)
 {
 
-//     thread_lock(td);
-#warning "ruxagg lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "ruxagg lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        ruxagg_locked(&p->p_rux, td);
        ruxagg_locked(&td->td_rux, td);
        td->td_incruntime = 0;
        td->td_uticks = 0;
        td->td_iticks = 0;
        td->td_sticks = 0;
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 }
 
 /*
index f36d4a1..1841d34 100644 (file)
@@ -202,10 +202,10 @@ critical_exit(void)
                td->td_critnest = 0;
                if (td->td_owepreempt && !kdb_active) {
                        td->td_critnest = 1;
-//                     thread_lock(td);
-#warning "critical_exit lock removed"
-                       register_t rflags;
-                       rflags = intr_disable();
+                       thread_lock(td);
+//#warning "critical_exit lock removed"
+//                     register_t rflags;
+//                     rflags = intr_disable();
                        td->td_critnest--;
                        flags = SW_INVOL | SW_PREEMPT;
                        if (TD_IS_IDLETHREAD(td))
@@ -213,9 +213,9 @@ critical_exit(void)
                        else
                                flags |= SWT_OWEPREEMPT;
                        mi_switch(flags, NULL);
-//                     thread_unlock(td);
-                       intr_restore(rflags);
-                       enable_intr();
+                       thread_unlock(td);
+//                     intr_restore(rflags);
+//                     enable_intr();
                }
        } else
                td->td_critnest--;
index 8aa208e..3406684 100644 (file)
@@ -603,18 +603,18 @@ kern_yield(int prio)
 
        td = curthread;
        DROP_GIANT();
-//     thread_lock(td);
-#warning "kern_yield lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "kern_yield lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        if (prio == PRI_USER)
                prio = td->td_user_pri;
        if (prio >= 0)
                sched_prio(td, prio);
        mi_switch(SW_VOL | SWT_RELINQUISH, NULL);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
        PICKUP_GIANT();
 }
 
index 4c47084..66515a9 100644 (file)
@@ -3685,12 +3685,12 @@ umtx_thread_cleanup(struct thread *td)
                TAILQ_REMOVE(&uq->uq_pi_contested, pi, pi_link);
        }
        mtx_unlock_spin(&umtx_lock);
-//     thread_lock(td);
-#warning "umtx_thread_cleanup lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "umtx_thread_cleanup lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sched_lend_user_prio(td, PRI_MAX);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 }
index 04aee49..d4350cb 100644 (file)
@@ -341,10 +341,10 @@ sleepq_add(void *wchan, struct lock_object *lock, const char *wmesg, int flags,
                MPASS((flags & SLEEPQ_TYPE) == sq->sq_type);
                LIST_INSERT_HEAD(&sq->sq_free, td->td_sleepqueue, sq_hash);
        }
-#warning "sleepq_add lock removed"
-       register_t rflags;
-       rflags = intr_disable();
-//     thread_lock(td);
+//#warning "sleepq_add lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
+       thread_lock(td);
        TAILQ_INSERT_TAIL(&sq->sq_blocked[queue], td, td_slpq);
        sq->sq_blockedcnt[queue]++;
        td->td_sleepqueue = NULL;
@@ -357,9 +357,9 @@ sleepq_add(void *wchan, struct lock_object *lock, const char *wmesg, int flags,
                if (flags & SLEEPQ_STOP_ON_BDRY)
                        td->td_flags |= TDF_SBDRY;
        }
-       intr_restore(rflags);
-       enable_intr();
-//     thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
+       thread_unlock(td);
 }
 
 /*
@@ -431,10 +431,10 @@ sleepq_catch_signals(void *wchan, int pri)
         * directly.
         */
 
-//     thread_lock(td);
-#warning "sleepq_catch_signals lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "sleepq_catch_signals lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        if ((td->td_flags & (TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK)) == 0) {
                sleepq_switch(wchan, pri);
                return (0);
@@ -469,8 +469,8 @@ sleepq_catch_signals(void *wchan, int pri)
        mtx_lock_spin(&sc->sc_lock);
        PROC_UNLOCK(p);
        thread_lock(td);
-       intr_restore(rflags);
-       enable_intr();
+//     intr_restore(rflags);
+//     enable_intr();
 
        PROC_SUNLOCK(p);
        if (ret == 0) {
@@ -552,8 +552,8 @@ sleepq_switch(void *wchan, int pri)
 #endif
        MPASS(td->td_sleepqueue == NULL);
        sched_sleep(td, pri);
-#warning "sleepq_switch lock removed"
-//     thread_lock_set(td, &sc->sc_lock);
+//#warning "sleepq_switch lock removed"
+       thread_lock_set(td, &sc->sc_lock);
        SDT_PROBE0(sched, , , sleep);
        TD_SET_SLEEPING(td);
        mi_switch(SW_VOL | SWT_SLEEPQ, NULL);
@@ -634,14 +634,14 @@ sleepq_wait(void *wchan, int pri)
 
        td = curthread;
        MPASS(!(td->td_flags & TDF_SINTR));
-//     thread_lock(td);
-#warning "sleepq_wait lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "sleepq_wait lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sleepq_switch(wchan, pri);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 }
 
 /*
@@ -656,11 +656,11 @@ sleepq_wait_sig(void *wchan, int pri)
 
        rcatch = sleepq_catch_signals(wchan, pri);
        rval = sleepq_check_signals();
-//     thread_unlock(curthread);
-#warning "sleepq_wait_sig unlock removed"
-       register_t rflags;
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(curthread);
+//#warning "sleepq_wait_sig unlock removed"
+//     register_t rflags;
+//     intr_restore(rflags);
+//     enable_intr();
        if (rcatch)
                return (rcatch);
        return (rval);
@@ -678,15 +678,15 @@ sleepq_timedwait(void *wchan, int pri)
 
        td = curthread;
        MPASS(!(td->td_flags & TDF_SINTR));
-//     thread_lock(td);
-#warning "sleepq_timedwait lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "sleepq_timedwait lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        sleepq_switch(wchan, pri);
        rval = sleepq_check_timeout();
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 
        return (rval);
 }
@@ -868,14 +868,14 @@ sleepq_signal(void *wchan, int flags, int pri, int queue)
                        besttd = td;
        }
        MPASS(besttd != NULL);
-//     thread_lock(besttd);
-#warning "sleepq_signal lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(besttd);
+//#warning "sleepq_signal lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        wakeup_swapper = sleepq_resume_thread(sq, besttd, pri);
-//     thread_unlock(besttd);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(besttd);
+//     intr_restore(rflags);
+//     enable_intr();
        return (wakeup_swapper);
 }
 
@@ -901,15 +901,15 @@ sleepq_broadcast(void *wchan, int flags, int pri, int queue)
        /* Resume all blocked threads on the sleep queue. */
        wakeup_swapper = 0;
        TAILQ_FOREACH_SAFE(td, &sq->sq_blocked[queue], td_slpq, tdn) {
-//             thread_lock(td);
-#warning "sleepq_broadcast lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td);
+//#warning "sleepq_broadcast lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                if (sleepq_resume_thread(sq, td, pri))
                        wakeup_swapper = 1;
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
        }
        return (wakeup_swapper);
 }
@@ -936,10 +936,10 @@ sleepq_timeout(void *arg)
         * First, see if the thread is asleep and get the wait channel if
         * it is.
         */
-//     thread_lock(td);
-#warning "sleepq_timeout lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "sleepq_timeout lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        if (TD_IS_SLEEPING(td) && TD_ON_SLEEPQ(td)) {
                wchan = td->td_wchan;
                sc = SC_LOOKUP(wchan);
@@ -948,9 +948,9 @@ sleepq_timeout(void *arg)
                MPASS(sq != NULL);
                td->td_flags |= TDF_TIMEOUT;
                wakeup_swapper = sleepq_resume_thread(sq, td, 0);
-               //thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
                if (wakeup_swapper)
                        kick_proc0();
                return;
@@ -964,9 +964,9 @@ sleepq_timeout(void *arg)
         */
        if (TD_ON_SLEEPQ(td)) {
                td->td_flags |= TDF_TIMEOUT;
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
                return;
        }
 
@@ -986,9 +986,9 @@ sleepq_timeout(void *arg)
                wakeup_swapper = setrunnable(td);
        } else
                td->td_flags |= TDF_TIMOFAIL;
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
        if (wakeup_swapper)
                kick_proc0();
 }
@@ -1022,17 +1022,17 @@ sleepq_remove(struct thread *td, void *wchan)
                return;
        }
        /* Thread is asleep on sleep queue sq, so wake it up. */
-//     thread_lock(td);
-#warning "sleepq_remove lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "sleepq_remove lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
 
        MPASS(sq != NULL);
        MPASS(td->td_wchan == wchan);
        wakeup_swapper = sleepq_resume_thread(sq, td, 0);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
        sleepq_release(wchan);
        if (wakeup_swapper)
                kick_proc0();
index 636f46e..f760212 100644 (file)
@@ -476,15 +476,15 @@ taskqueue_start_threads(struct taskqueue **tqp, int count, int pri,
                if (tq->tq_threads[i] == NULL)
                        continue;
                td = tq->tq_threads[i];
-//             thread_lock(td);
-#warning "taskqueue_start_threads lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td);
+//#warning "taskqueue_start_threads lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                sched_prio(td, pri);
                sched_add(td, SRQ_BORING);
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
        }
 
        return (0);
index 9fe6e24..f7cc1cd 100644 (file)
@@ -183,16 +183,16 @@ ast(struct trapframe *framep)
         * AST's saved in flags, the astpending flag will be set and
         * ast() will be called again.
         */
-//     thread_lock(td);
-#warning "ast lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "ast lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
        flags = td->td_flags;
        td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK | TDF_NEEDSUSPCHK |
            TDF_NEEDRESCHED | TDF_ALRMPEND | TDF_PROFPEND | TDF_MACPEND);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
        PCPU_INC(cnt.v_trap);
 
        if (td->td_ucred != p->p_ucred) 
@@ -226,15 +226,15 @@ ast(struct trapframe *framep)
                if (KTRPOINT(td, KTR_CSW))
                        ktrcsw(1, 1, __func__);
 #endif
-//             thread_lock(td);
-#warning "ast lock removed"
-               register_t rflags;
-               rflags = intr_disable();
+               thread_lock(td);
+//#warning "ast lock removed"
+//             register_t rflags;
+//             rflags = intr_disable();
                sched_prio(td, td->td_user_pri);
                mi_switch(SW_INVOL | SWT_NEEDRESCHED, NULL);
-//             thread_unlock(td);
-               intr_restore(rflags);
-               enable_intr();
+               thread_unlock(td);
+//             intr_restore(rflags);
+//             enable_intr();
 #ifdef KTRACE
                if (KTRPOINT(td, KTR_CSW))
                        ktrcsw(0, 1, __func__);
index a6fabc7..d29c8bf 100644 (file)
@@ -1917,14 +1917,14 @@ sched_sync(void)
                 */
                if (syncer_state != SYNCER_RUNNING ||
                    time_uptime == starttime) {
-//                     thread_lock(td);
-#warning "sched_sync lock removed"
-                       register_t rflags;
-                       rflags = intr_disable();
+                       thread_lock(td);
+//#warning "sched_sync lock removed"
+//                     register_t rflags;
+//                     rflags = intr_disable();
                        sched_prio(td, PPAUSE);
-//                     thread_unlock(td);
-                       intr_restore(rflags);
-                       enable_intr();
+                       thread_unlock(td);
+//                     intr_restore(rflags);
+//                     enable_intr();
                }
                if (syncer_state != SYNCER_RUNNING)
                        cv_timedwait(&sync_wakeup, &sync_mtx,
index f8b53a7..10ee80f 100644 (file)
@@ -154,18 +154,18 @@ pagezero_start(void __unused *arg)
                panic("pagezero_start: error %d\n", error);
        td = FIRST_THREAD_IN_PROC(p);
 
-//     thread_lock(td);
-#warning "pagezero_start lock removed"
-       register_t rflags;
-       rflags = intr_disable();
+       thread_lock(td);
+//#warning "pagezero_start lock removed"
+//     register_t rflags;
+//     rflags = intr_disable();
 
        /* We're an idle task, don't count us in the load. */
        td->td_flags |= TDF_NOLOAD;
        sched_class(td, PRI_IDLE);
        sched_prio(td, PRI_MAX_IDLE);
        sched_add(td, SRQ_BORING);
-//     thread_unlock(td);
-       intr_restore(rflags);
-       enable_intr();
+       thread_unlock(td);
+//     intr_restore(rflags);
+//     enable_intr();
 }
 SYSINIT(pagezero, SI_SUB_KTHREAD_VM, SI_ORDER_ANY, pagezero_start, NULL);