kern_softint.c revision 1.1.2.14 1 /* $NetBSD: kern_softint.c,v 1.1.2.14 2007/09/01 15:23:58 yamt Exp $ */
2
3 /*-
4 * Copyright (c) 2007 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Generic software interrupt framework.
41 *
42 * Overview
43 *
44 * The soft interrupt framework provides a mechanism to schedule a
45 * low priority callback that runs with thread context. It allows
46 * for dynamic registration of software interrupts, and for fair
47 * queueing and prioritization of those interrupts. The callbacks
48 * can be scheduled to run from nearly any point in the kernel: by
49 * code running with thread context, by code running from a
50 * hardware interrupt handler, and at any interrupt priority
51 * level.
52 *
53 * Priority levels
54 *
55 * Since soft interrupt dispatch can be tied to the underlying
56 * architecture's interrupt dispatch code, it can be limited
57 * both by the capabilities of the hardware and the capabilities
58 * of the interrupt dispatch code itself. The number of priority
59 * levels is restricted to four. In order of priority (lowest to
60 * highest) the levels are: clock, bio, net, serial.
61 *
62 * The names are symbolic and in isolation do not have any direct
63 * connection with a particular kind of device activity: they are
64 * only meant as a guide.
65 *
66 * The four priority levels map directly to scheduler priority
67 * levels, and where the architecture implements 'fast' software
68 * interrupts, they also map onto interrupt priorities. The
69 * interrupt priorities are intended to be hidden from machine
70 * independent code, which should use thread-safe mechanisms to
71 * synchronize with software interrupts (for example: mutexes).
72 *
73 * Capabilities
74 *
75 * Software interrupts run with limited machine context. In
76 * particular, they do not posess any address space context. They
77 * should not try to operate on user space addresses, or to use
78 * virtual memory facilities other than those noted as interrupt
79 * safe.
80 *
81 * Unlike hardware interrupts, software interrupts do have thread
82 * context. They may block on synchronization objects, sleep, and
83 * resume execution at a later time.
84 *
85 * Since software interrupts are a limited resource and run with
86 * higher priority than most other LWPs in the system, all
87 * block-and-resume activity by a software interrupt must be kept
88 * short to allow futher processing at that level to continue. By
89 * extension, code running in the bottom half of the kernel must
90 * take care to ensure that any lock that may be taken from a
91 * software interrupt can not be held for more than a short period
92 * of time.
93 *
94 * The kernel does not allow software interrupts to use facilities
95 * or perform actions that may block for a significant amount of
96 * time. This means that it's not valid for a software interrupt
97 * to: sleep on condition variables, use the lockmgr() facility,
98 * or wait for resources to become available (for example,
99 * memory).
100 *
101 * Per-CPU operation
102 *
103 * If a soft interrupt is triggered on a CPU, it can only be
104 * dispatched on the same CPU. Each LWP dedicated to handling a
105 * soft interrupt is bound to its home CPU, so if the LWP blocks
106 * and needs to run again, it can only run there. Nearly all data
107 * structures used to manage software interrupts are per-CPU.
108 *
109 * The per-CPU requirement is intended to reduce "ping-pong" of
110 * cache lines between CPUs: lines occupied by data structures
111 * used to manage the soft interrupts, and lines occupied by data
112 * items being passed down to the soft interrupt. As a positive
113 * side effect, this also means that the soft interrupt dispatch
114 * code does not need to to use spinlocks to synchronize with the
115 * upper half.
116 *
117 * Generic implementation
118 *
119 * A generic, low performance implementation is provided that
120 * works across all architectures, with no machine-dependent
121 * modifications needed. This implementation uses the scheduler,
122 * and so has a number of restrictions:
123 *
124 * 1) Since software interrupts can be triggered from any priority
125 * level, on architectures where the generic implementation is
126 * used IPL_SCHED must be equal to IPL_HIGH (it must block all
127 * interrupts).
128 *
129 * 2) The software interrupts are not currently preemptive, so
130 * must wait for the currently executing LWP to yield the CPU.
131 * This can introduce latency.
132 *
133 * 3) A context switch is required for each soft interrupt to be
134 * handled, which can be quite expensive.
135 *
136 * 'Fast' software interrupts
137 *
138 * If an architectures defines __HAVE_FAST_SOFTINTS, it implements
139 * the fast mechanism. Threads running either in the kernel or in
140 * userspace will be interrupted, but will not be preempted. When
141 * the soft interrupt completes execution, the interrupted LWP
142 * is resumed. Interrupt dispatch code must provide the minimum
143 * level of context necessary for the soft interrupt to block and
144 * be resumed at a later time. The machine-dependent dispatch
145 * path looks something like the following:
146 *
147 * softintr()
148 * {
149 * go to IPL_HIGH if necessary for switch;
150 * save any necessary registers in a format that can be
151 * restored by cpu_switchto if the softint blocks;
152 * arrange for cpu_switchto() to restore into the
153 * trampoline function;
154 * identify LWP to handle this interrupt;
155 * switch to the LWP's stack;
156 * switch register stacks, if necessary;
157 * assign new value of curlwp;
158 * call MI softint_dispatch, passing old curlwp and IPL
159 * to execute interrupt at;
160 * switch back to old stack;
161 * switch back to old register stack, if necessary;
162 * restore curlwp;
163 * return to interrupted LWP;
164 * }
165 *
166 * If the soft interrupt blocks, a trampoline function is returned
167 * to in the context of the interrupted LWP, as arranged for by
168 * softint():
169 *
170 * softint_ret()
171 * {
172 * unlock soft interrupt LWP;
173 * resume interrupt processing, likely returning to
174 * interrupted LWP or dispatching another, different
175 * interrupt;
176 * }
177 *
178 * Once the soft interrupt has fired (and even if it has blocked),
179 * no further soft interrupts at that level will be triggered by
180 * MI code until the soft interrupt handler has ceased execution.
181 * If a soft interrupt handler blocks and is resumed, it resumes
182 * execution as a normal LWP (kthread) and gains VM context. Only
183 * when it has completed and is ready to fire again will it
184 * interrupt other threads.
185 */
186
187 #include <sys/cdefs.h>
188 __KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.1.2.14 2007/09/01 15:23:58 yamt Exp $");
189
190 #include <sys/param.h>
191 #include <sys/malloc.h>
192 #include <sys/proc.h>
193 #include <sys/intr.h>
194 #include <sys/mutex.h>
195 #include <sys/kthread.h>
196 #include <sys/evcnt.h>
197 #include <sys/cpu.h>
198
199 #include <net/netisr.h>
200
201 #include <uvm/uvm_extern.h>
202
203 #define PRI_SOFTSERIAL (PRI_COUNT - 1)
204 #define PRI_SOFTNET (PRI_SOFTSERIAL - schedppq * 1)
205 #define PRI_SOFTBIO (PRI_SOFTSERIAL - schedppq * 2)
206 #define PRI_SOFTCLOCK (PRI_SOFTSERIAL - schedppq * 3)
207
208 /* This could overlap with signal info in struct lwp. */
209 typedef struct softint {
210 SIMPLEQ_HEAD(, softhand) si_q;
211 struct lwp *si_lwp;
212 struct cpu_info *si_cpu;
213 uintptr_t si_machdep;
214 struct evcnt si_evcnt;
215 struct evcnt si_evcnt_block;
216 int si_active;
217 char si_name[8];
218 char si_name_block[8+6];
219 } softint_t;
220
221 typedef struct softhand {
222 SIMPLEQ_ENTRY(softhand) sh_q;
223 void (*sh_func)(void *);
224 void *sh_arg;
225 softint_t *sh_isr;
226 u_int sh_pending;
227 u_int sh_flags;
228 } softhand_t;
229
230 typedef struct softcpu {
231 struct cpu_info *sc_cpu;
232 softint_t sc_int[SOFTINT_COUNT];
233 softhand_t sc_hand[1];
234 } softcpu_t;
235
236 static void softint_thread(void *);
237 static void softint_netisr(void *);
238
239 u_int softint_bytes = 8192;
240 u_int softint_timing;
241 static u_int softint_max;
242 static kmutex_t softint_lock;
243 static void *softint_netisr_sih;
244
245 /*
246 * softint_init_isr:
247 *
248 * Initialize a single interrupt level for a single CPU.
249 */
250 static void
251 softint_init_isr(softcpu_t *sc, const char *desc, pri_t pri, u_int level)
252 {
253 struct cpu_info *ci;
254 softint_t *si;
255 int error;
256
257 si = &sc->sc_int[level];
258 ci = sc->sc_cpu;
259 si->si_cpu = ci;
260
261 SIMPLEQ_INIT(&si->si_q);
262
263 error = kthread_create(pri, KTHREAD_MPSAFE | KTHREAD_INTR |
264 KTHREAD_IDLE, ci, softint_thread, si, &si->si_lwp,
265 "soft%s/%d", desc, (int)ci->ci_cpuid);
266 if (error != 0)
267 panic("softint_init_isr: error %d", error);
268
269 snprintf(si->si_name, sizeof(si->si_name), "%s/%d", desc,
270 (int)ci->ci_cpuid);
271 evcnt_attach_dynamic(&si->si_evcnt, EVCNT_TYPE_INTR, NULL,
272 "softint", si->si_name);
273 snprintf(si->si_name_block, sizeof(si->si_name_block), "%s block/%d",
274 desc, (int)ci->ci_cpuid);
275 evcnt_attach_dynamic(&si->si_evcnt_block, EVCNT_TYPE_INTR, NULL,
276 "softint", si->si_name_block);
277
278 si->si_lwp->l_private = si;
279 softint_init_md(si->si_lwp, level, &si->si_machdep);
280 #ifdef __HAVE_FAST_SOFTINTS
281 si->si_lwp->l_mutex = &ci->ci_schedstate.spc_lwplock;
282 #endif
283 }
284 /*
285 * softint_init:
286 *
287 * Initialize per-CPU data structures. Called from mi_cpu_attach().
288 */
289 void
290 softint_init(struct cpu_info *ci)
291 {
292 static struct cpu_info *first;
293 softcpu_t *sc, *scfirst;
294 softhand_t *sh, *shmax;
295
296 if (first == NULL) {
297 /* Boot CPU. */
298 first = ci;
299 mutex_init(&softint_lock, MUTEX_DEFAULT, IPL_NONE);
300 softint_bytes = round_page(softint_bytes);
301 softint_max = (softint_bytes - sizeof(softcpu_t)) /
302 sizeof(softhand_t);
303 }
304
305 sc = (softcpu_t *)uvm_km_alloc(kernel_map, softint_bytes, 0,
306 UVM_KMF_WIRED | UVM_KMF_ZERO);
307 if (sc == NULL)
308 panic("softint_init_cpu: cannot allocate memory");
309
310 ci->ci_data.cpu_softcpu = sc;
311 sc->sc_cpu = ci;
312
313 softint_init_isr(sc, "net", PRI_SOFTNET, SOFTINT_NET);
314 softint_init_isr(sc, "bio", PRI_SOFTBIO, SOFTINT_BIO);
315 softint_init_isr(sc, "clk", PRI_SOFTCLOCK, SOFTINT_CLOCK);
316 softint_init_isr(sc, "ser", PRI_SOFTSERIAL, SOFTINT_SERIAL);
317
318 if (first != ci) {
319 /* Don't lock -- autoconfiguration will prevent reentry. */
320 scfirst = first->ci_data.cpu_softcpu;
321 sh = sc->sc_hand;
322 memcpy(sh, scfirst->sc_hand, sizeof(*sh) * softint_max);
323
324 /* Update pointers for this CPU. */
325 for (shmax = sh + softint_max; sh < shmax; sh++) {
326 if (sh->sh_func == NULL)
327 continue;
328 sh->sh_isr =
329 &sc->sc_int[sh->sh_flags & SOFTINT_LVLMASK];
330 }
331 } else {
332 /* Establish a handler for legacy net interrupts. */
333 softint_netisr_sih = softint_establish(SOFTINT_NET,
334 softint_netisr, NULL);
335 KASSERT(softint_netisr_sih != NULL);
336 }
337 }
338
339 /*
340 * softint_establish:
341 *
342 * Register a software interrupt handler.
343 */
344 void *
345 softint_establish(u_int flags, void (*func)(void *), void *arg)
346 {
347 CPU_INFO_ITERATOR cii;
348 struct cpu_info *ci;
349 softcpu_t *sc;
350 softhand_t *sh;
351 u_int level, index;
352
353 level = (flags & SOFTINT_LVLMASK);
354 KASSERT(level < SOFTINT_COUNT);
355
356 mutex_enter(&softint_lock);
357
358 /* Find a free slot. */
359 sc = curcpu()->ci_data.cpu_softcpu;
360 for (index = 1; index < softint_max; index++)
361 if (sc->sc_hand[index].sh_func == NULL)
362 break;
363 if (index == softint_max) {
364 mutex_exit(&softint_lock);
365 printf("WARNING: softint_establish: table full, "
366 "increase softint_bytes\n");
367 return NULL;
368 }
369
370 /* Set up the handler on each CPU. */
371 for (CPU_INFO_FOREACH(cii, ci)) {
372 sc = ci->ci_data.cpu_softcpu;
373 sh = &sc->sc_hand[index];
374
375 sh->sh_isr = &sc->sc_int[level];
376 sh->sh_func = func;
377 sh->sh_arg = arg;
378 sh->sh_flags = flags;
379 sh->sh_pending = 0;
380 }
381
382 mutex_exit(&softint_lock);
383
384 return (void *)((uint8_t *)&sc->sc_hand[index] - (uint8_t *)sc);
385 }
386
387 /*
388 * softint_disestablish:
389 *
390 * Unregister a software interrupt handler.
391 */
392 void
393 softint_disestablish(void *arg)
394 {
395 CPU_INFO_ITERATOR cii;
396 struct cpu_info *ci;
397 softcpu_t *sc;
398 softhand_t *sh;
399 uintptr_t offset;
400
401 offset = (uintptr_t)arg;
402 KASSERT(offset != 0 && offset < softint_bytes);
403
404 mutex_enter(&softint_lock);
405
406 /* Set up the handler on each CPU. */
407 for (CPU_INFO_FOREACH(cii, ci)) {
408 sc = ci->ci_data.cpu_softcpu;
409 sh = (softhand_t *)((uint8_t *)sc + offset);
410 KASSERT(sh->sh_func != NULL);
411 KASSERT(sh->sh_pending == 0);
412 sh->sh_func = NULL;
413 }
414
415 mutex_exit(&softint_lock);
416 }
417
418 /*
419 * softint_schedule:
420 *
421 * Trigger a software interrupt. Must be called from a hardware
422 * interrupt handler, or with preemption disabled (since we are
423 * using the value of curcpu()).
424 */
425 void
426 softint_schedule(void *arg)
427 {
428 softhand_t *sh;
429 softint_t *si;
430 uintptr_t offset;
431 int s;
432
433 /* Find the handler record for this CPU. */
434 offset = (uintptr_t)arg;
435 KASSERT(offset != 0 && offset < softint_bytes);
436 sh = (softhand_t *)((uint8_t *)curcpu()->ci_data.cpu_softcpu + offset);
437
438 /* If it's already pending there's nothing to do. */
439 if (sh->sh_pending)
440 return;
441
442 /*
443 * Enqueue the handler into the LWP's pending list.
444 * If the LWP is completely idle, then make it run.
445 */
446 s = splhigh();
447 if (!sh->sh_pending) {
448 si = sh->sh_isr;
449 sh->sh_pending = 1;
450 SIMPLEQ_INSERT_TAIL(&si->si_q, sh, sh_q);
451 if (si->si_active == 0) {
452 si->si_active = 1;
453 softint_trigger(si->si_machdep);
454 }
455 }
456 splx(s);
457 }
458
459 /*
460 * softint_execute:
461 *
462 * Invoke handlers for the specified soft interrupt.
463 * Must be entered at splhigh. Will drop the priority
464 * to the level specified, but returns back at splhigh.
465 */
466 static inline void
467 softint_execute(softint_t *si, lwp_t *l, int s)
468 {
469 softhand_t *sh;
470 bool havelock;
471
472 KASSERT(si->si_lwp == curlwp);
473 KASSERT(si->si_cpu == curcpu());
474 KASSERT(si->si_lwp->l_wchan == NULL);
475 KASSERT(si->si_active);
476
477 havelock = false;
478
479 /*
480 * Note: due to priority inheritance we may have interrupted a
481 * higher priority LWP. Since the soft interrupt must be quick
482 * and is non-preemptable, we don't bother yielding.
483 */
484
485 while (!SIMPLEQ_EMPTY(&si->si_q)) {
486 /*
487 * Pick the longest waiting handler to run. We block
488 * interrupts but do not lock in order to do this, as
489 * we are protecting against the local CPU only.
490 */
491 sh = SIMPLEQ_FIRST(&si->si_q);
492 SIMPLEQ_REMOVE_HEAD(&si->si_q, sh_q);
493 sh->sh_pending = 0;
494 splx(s);
495
496 /* Run the handler. */
497 if ((sh->sh_flags & SOFTINT_MPSAFE) == 0 && !havelock) {
498 KERNEL_LOCK(1, l);
499 havelock = true;
500 }
501 (*sh->sh_func)(sh->sh_arg);
502
503 (void)splhigh();
504 }
505
506 if (havelock) {
507 KERNEL_UNLOCK_ONE(l);
508 }
509
510 /*
511 * Unlocked, but only for statistics.
512 * Should be per-CPU to prevent cache ping-pong.
513 */
514 uvmexp.softs++;
515
516 si->si_evcnt.ev_count++;
517 si->si_active = 0;
518 }
519
520 /*
521 * schednetisr:
522 *
523 * Trigger a legacy network interrupt. XXX Needs to go away.
524 */
525 void
526 schednetisr(int isr)
527 {
528 int s;
529
530 s = splhigh();
531 curcpu()->ci_data.cpu_netisrs |= (1 << isr);
532 softint_schedule(softint_netisr_sih);
533 splx(s);
534 }
535
536 /*
537 * softintr_netisr:
538 *
539 * Dispatch legacy network interrupts. XXX Needs to go away.
540 */
541 static void
542 softint_netisr(void *cookie)
543 {
544 struct cpu_info *ci;
545 int s, bits;
546
547 ci = curcpu();
548
549 s = splhigh();
550 bits = ci->ci_data.cpu_netisrs;
551 ci->ci_data.cpu_netisrs = 0;
552 splx(s);
553
554 #define DONETISR(which, func) \
555 do { \
556 void func(void); \
557 if ((bits & (1 << which)) != 0) \
558 func(); \
559 } while(0);
560 #include <net/netisr_dispatch.h>
561 #undef DONETISR
562 }
563
564 #ifndef __HAVE_FAST_SOFTINTS
565
566 /*
567 * softint_init_md:
568 *
569 * Perform machine-dependent initialization.
570 */
571 void
572 softint_init_md(lwp_t *l, u_int level, uintptr_t *machdep)
573 {
574 softint_t *si;
575
576 *machdep = (uintptr_t)l;
577 si = l->l_private;
578
579 lwp_lock(l);
580 /* Cheat and make the KASSERT in softint_thread() happy. */
581 si->si_active = 1;
582 l->l_stat = LSRUN;
583 sched_enqueue(l, false);
584 lwp_unlock(l);
585 }
586
587 /*
588 * softint_trigger:
589 *
590 * Cause a soft interrupt handler to begin executing.
591 */
592 void
593 softint_trigger(uintptr_t machdep)
594 {
595 struct cpu_info *ci;
596 lwp_t *l;
597
598 l = (lwp_t *)machdep;
599 ci = l->l_cpu;
600
601 spc_lock(ci);
602 l->l_mutex = ci->ci_schedstate.spc_mutex;
603 l->l_stat = LSRUN;
604 sched_enqueue(l, false);
605 cpu_need_resched(ci, RESCHED_IMMED);
606 spc_unlock(ci);
607 }
608
609 /*
610 * softint_thread:
611 *
612 * Slow path MI software interrupt dispatch.
613 */
614 void
615 softint_thread(void *cookie)
616 {
617 softint_t *si;
618 lwp_t *l;
619 int s;
620
621 l = curlwp;
622 si = l->l_private;
623 s = splhigh();
624
625 for (;;) {
626 softint_execute(si, l, s);
627
628 lwp_lock(l);
629 l->l_stat = LSIDL;
630 mi_switch(l);
631 }
632 }
633
634 #else /* !__HAVE_FAST_SOFTINTS */
635
636 /*
637 * softint_thread:
638 *
639 * In the __HAVE_FAST_SOFTINTS case, the LWP is switched to without
640 * restoring any state, so we should not arrive here - there is a
641 * direct handoff between the interrupt stub and softint_dispatch().
642 */
643 void
644 softint_thread(void *cookie)
645 {
646
647 panic("softint_thread");
648 }
649
650 /*
651 * softint_dispatch:
652 *
653 * Entry point from machine-dependent code.
654 */
655 void
656 softint_dispatch(lwp_t *pinned, int s)
657 {
658 struct timeval now;
659 softint_t *si;
660 u_int timing;
661 lwp_t *l;
662
663 l = curlwp;
664 si = l->l_private;
665
666 /*
667 * Note the interrupted LWP, and mark the current LWP as running
668 * before proceeding. Although this must as a rule be done with
669 * the LWP locked, at this point no external agents will want to
670 * modify the interrupt LWP's state.
671 */
672 timing = (softint_timing ? LW_TIMEINTR : 0);
673 l->l_switchto = pinned;
674 l->l_stat = LSONPROC;
675 l->l_flag |= (LW_RUNNING | timing);
676
677 /*
678 * Dispatch the interrupt. If softints are being timed, charge
679 * for it.
680 */
681 if (timing)
682 microtime(&l->l_stime);
683 softint_execute(si, l, s);
684 if (timing) {
685 microtime(&now);
686 updatertime(l, &now);
687 l->l_flag &= ~LW_TIMEINTR;
688 }
689
690 /*
691 * If we blocked while handling the interrupt, the pinned LWP is
692 * gone so switch to the idle LWP. It will select a new LWP to
693 * run.
694 *
695 * We must drop the priority level as switching at IPL_HIGH could
696 * deadlock the system. We have already set si->si_active = 0,
697 * which means another interrupt at this level can be triggered.
698 * That's not be a problem: we are lowering to level 's' which will
699 * prevent softint_dispatch() from being reentered at level 's',
700 * until the priority is finally dropped to IPL_NONE on entry to
701 * the idle loop.
702 */
703 l->l_stat = LSIDL;
704 if (l->l_switchto == NULL) {
705 splx(s);
706 pmap_deactivate(l);
707 lwp_exit_switchaway(l);
708 /* NOTREACHED */
709 }
710 l->l_switchto = NULL;
711 l->l_flag &= ~LW_RUNNING;
712 }
713
714 #endif /* !__HAVE_FAST_SOFTINTS */
715
716 /*
717 * softint_block:
718 *
719 * Update statistics when the soft interrupt blocks.
720 */
721 void
722 softint_block(lwp_t *l)
723 {
724 softint_t *si = l->l_private;
725
726 KASSERT((l->l_flag & LW_INTR) != 0);
727 si->si_evcnt_block.ev_count++;
728 }
729