2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
35 #include <sys/rtprio.h>
36 #include <sys/systm.h>
37 #include <sys/interrupt.h>
38 #include <sys/kernel.h>
39 #include <sys/kthread.h>
41 #include <sys/limits.h>
43 #include <sys/malloc.h>
44 #include <sys/mutex.h>
46 #include <sys/random.h>
47 #include <sys/resourcevar.h>
48 #include <sys/sched.h>
49 #include <sys/sysctl.h>
50 #include <sys/unistd.h>
51 #include <sys/vmmeter.h>
52 #include <machine/atomic.h>
53 #include <machine/cpu.h>
54 #include <machine/md_var.h>
55 #include <machine/stdarg.h>
58 #include <ddb/db_sym.h>
62 * Describe an interrupt thread. There is one of these per interrupt event.
65 struct intr_event *it_event;
66 struct thread *it_thread; /* Kernel thread. */
67 int it_flags; /* (j) IT_* flags. */
68 int it_need; /* Needs service. */
71 /* Interrupt thread flags kept in it_flags */
72 #define IT_DEAD 0x000001 /* Thread is waiting to exit. */
79 struct intr_event *clk_intr_event;
80 struct intr_event *tty_intr_event;
84 static MALLOC_DEFINE(M_ITHREAD, "ithread", "Interrupt Threads");
86 static int intr_storm_threshold = 500;
87 TUNABLE_INT("hw.intr_storm_threshold", &intr_storm_threshold);
88 SYSCTL_INT(_hw, OID_AUTO, intr_storm_threshold, CTLFLAG_RW,
89 &intr_storm_threshold, 0,
90 "Number of consecutive interrupts before storm protection is enabled");
91 static TAILQ_HEAD(, intr_event) event_list =
92 TAILQ_HEAD_INITIALIZER(event_list);
94 static void intr_event_update(struct intr_event *ie);
95 static struct intr_thread *ithread_create(const char *name);
96 static void ithread_destroy(struct intr_thread *ithread);
97 static void ithread_execute_handlers(struct proc *p, struct intr_event *ie);
98 static void ithread_loop(void *);
99 static void ithread_update(struct intr_thread *ithd);
100 static void start_softintr(void *);
102 /* Map an interrupt type to an ithread priority. */
104 intr_priority(enum intr_type flags)
108 flags &= (INTR_TYPE_TTY | INTR_TYPE_BIO | INTR_TYPE_NET |
109 INTR_TYPE_CAM | INTR_TYPE_MISC | INTR_TYPE_CLK | INTR_TYPE_AV);
116 * XXX We need to refine this. BSD/OS distinguishes
117 * between tape and disk priorities.
125 pri = PI_DISK; /* XXX or PI_CAM? */
127 case INTR_TYPE_AV: /* Audio/video */
134 pri = PI_DULL; /* don't care */
137 /* We didn't specify an interrupt level. */
138 panic("intr_priority: no interrupt type in flags");
145 * Update an ithread based on the associated intr_event.
148 ithread_update(struct intr_thread *ithd)
150 struct intr_event *ie;
155 td = ithd->it_thread;
157 /* Determine the overall priority of this event. */
158 if (TAILQ_EMPTY(&ie->ie_handlers))
161 pri = TAILQ_FIRST(&ie->ie_handlers)->ih_pri;
163 /* Update name and priority. */
164 strlcpy(td->td_proc->p_comm, ie->ie_fullname,
165 sizeof(td->td_proc->p_comm));
166 mtx_lock_spin(&sched_lock);
168 mtx_unlock_spin(&sched_lock);
172 * Regenerate the full name of an interrupt event and update its priority.
175 intr_event_update(struct intr_event *ie)
177 struct intr_handler *ih;
181 /* Start off with no entropy and just the name of the event. */
182 mtx_assert(&ie->ie_lock, MA_OWNED);
183 strlcpy(ie->ie_fullname, ie->ie_name, sizeof(ie->ie_fullname));
184 ie->ie_flags &= ~IE_ENTROPY;
188 /* Run through all the handlers updating values. */
189 TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
190 if (strlen(ie->ie_fullname) + strlen(ih->ih_name) + 1 <
191 sizeof(ie->ie_fullname)) {
192 strcat(ie->ie_fullname, " ");
193 strcat(ie->ie_fullname, ih->ih_name);
197 if (ih->ih_flags & IH_ENTROPY)
198 ie->ie_flags |= IE_ENTROPY;
202 * If the handler names were too long, add +'s to indicate missing
203 * names. If we run out of room and still have +'s to add, change
204 * the last character from a + to a *.
206 last = &ie->ie_fullname[sizeof(ie->ie_fullname) - 2];
207 while (missed-- > 0) {
208 if (strlen(ie->ie_fullname) + 1 == sizeof(ie->ie_fullname)) {
215 strcat(ie->ie_fullname, " +");
218 strcat(ie->ie_fullname, "+");
222 * If this event has an ithread, update it's priority and
225 if (ie->ie_thread != NULL)
226 ithread_update(ie->ie_thread);
227 CTR2(KTR_INTR, "%s: updated %s", __func__, ie->ie_fullname);
231 intr_event_create(struct intr_event **event, void *source, int flags,
232 void (*enable)(void *), const char *fmt, ...)
234 struct intr_event *ie;
237 /* The only valid flag during creation is IE_SOFT. */
238 if ((flags & ~IE_SOFT) != 0)
240 ie = malloc(sizeof(struct intr_event), M_ITHREAD, M_WAITOK | M_ZERO);
241 ie->ie_source = source;
242 ie->ie_enable = enable;
243 ie->ie_flags = flags;
244 TAILQ_INIT(&ie->ie_handlers);
245 mtx_init(&ie->ie_lock, "intr event", NULL, MTX_DEF);
248 vsnprintf(ie->ie_name, sizeof(ie->ie_name), fmt, ap);
250 strlcpy(ie->ie_fullname, ie->ie_name, sizeof(ie->ie_fullname));
251 mtx_pool_lock(mtxpool_sleep, &event_list);
252 TAILQ_INSERT_TAIL(&event_list, ie, ie_list);
253 mtx_pool_unlock(mtxpool_sleep, &event_list);
256 CTR2(KTR_INTR, "%s: created %s", __func__, ie->ie_name);
261 intr_event_destroy(struct intr_event *ie)
264 mtx_lock(&ie->ie_lock);
265 if (!TAILQ_EMPTY(&ie->ie_handlers)) {
266 mtx_unlock(&ie->ie_lock);
269 mtx_pool_lock(mtxpool_sleep, &event_list);
270 TAILQ_REMOVE(&event_list, ie, ie_list);
271 mtx_pool_unlock(mtxpool_sleep, &event_list);
273 if (ie->ie_thread != NULL) {
274 ithread_destroy(ie->ie_thread);
275 ie->ie_thread = NULL;
278 mtx_unlock(&ie->ie_lock);
279 mtx_destroy(&ie->ie_lock);
284 static struct intr_thread *
285 ithread_create(const char *name)
287 struct intr_thread *ithd;
292 ithd = malloc(sizeof(struct intr_thread), M_ITHREAD, M_WAITOK | M_ZERO);
294 error = kthread_create(ithread_loop, ithd, &p, RFSTOPPED | RFHIGHPID,
297 panic("kthread_create() failed with %d", error);
298 td = FIRST_THREAD_IN_PROC(p); /* XXXKSE */
299 mtx_lock_spin(&sched_lock);
300 sched_class(td, PRI_ITHD);
302 mtx_unlock_spin(&sched_lock);
303 td->td_pflags |= TDP_ITHREAD;
304 ithd->it_thread = td;
305 CTR2(KTR_INTR, "%s: created %s", __func__, name);
310 ithread_destroy(struct intr_thread *ithread)
314 CTR2(KTR_INTR, "%s: killing %s", __func__, ithread->it_event->ie_name);
315 td = ithread->it_thread;
316 mtx_lock_spin(&sched_lock);
317 ithread->it_flags |= IT_DEAD;
318 if (TD_AWAITING_INTR(td)) {
320 sched_add(td, SRQ_INTR);
322 mtx_unlock_spin(&sched_lock);
326 intr_event_add_handler(struct intr_event *ie, const char *name,
327 driver_intr_t handler, void *arg, u_char pri, enum intr_type flags,
330 struct intr_handler *ih, *temp_ih;
331 struct intr_thread *it;
333 if (ie == NULL || name == NULL || handler == NULL)
336 /* Allocate and populate an interrupt handler structure. */
337 ih = malloc(sizeof(struct intr_handler), M_ITHREAD, M_WAITOK | M_ZERO);
338 ih->ih_handler = handler;
339 ih->ih_argument = arg;
343 if (flags & INTR_FAST)
344 ih->ih_flags = IH_FAST;
345 else if (flags & INTR_EXCL)
346 ih->ih_flags = IH_EXCLUSIVE;
347 if (flags & INTR_MPSAFE)
348 ih->ih_flags |= IH_MPSAFE;
349 if (flags & INTR_ENTROPY)
350 ih->ih_flags |= IH_ENTROPY;
352 /* We can only have one exclusive handler in a event. */
353 mtx_lock(&ie->ie_lock);
354 if (!TAILQ_EMPTY(&ie->ie_handlers)) {
355 if ((flags & INTR_EXCL) ||
356 (TAILQ_FIRST(&ie->ie_handlers)->ih_flags & IH_EXCLUSIVE)) {
357 mtx_unlock(&ie->ie_lock);
363 /* Add the new handler to the event in priority order. */
364 TAILQ_FOREACH(temp_ih, &ie->ie_handlers, ih_next) {
365 if (temp_ih->ih_pri > ih->ih_pri)
369 TAILQ_INSERT_TAIL(&ie->ie_handlers, ih, ih_next);
371 TAILQ_INSERT_BEFORE(temp_ih, ih, ih_next);
372 intr_event_update(ie);
374 /* Create a thread if we need one. */
375 while (ie->ie_thread == NULL && !(flags & INTR_FAST)) {
376 if (ie->ie_flags & IE_ADDING_THREAD)
377 msleep(ie, &ie->ie_lock, 0, "ithread", 0);
379 ie->ie_flags |= IE_ADDING_THREAD;
380 mtx_unlock(&ie->ie_lock);
381 it = ithread_create("intr: newborn");
382 mtx_lock(&ie->ie_lock);
383 ie->ie_flags &= ~IE_ADDING_THREAD;
390 CTR3(KTR_INTR, "%s: added %s to %s", __func__, ih->ih_name,
392 mtx_unlock(&ie->ie_lock);
400 * Return the ie_source field from the intr_event an intr_handler is
404 intr_handler_source(void *cookie)
406 struct intr_handler *ih;
407 struct intr_event *ie;
409 ih = (struct intr_handler *)cookie;
414 ("interrupt handler \"%s\" has a NULL interrupt event",
416 return (ie->ie_source);
420 intr_event_remove_handler(void *cookie)
422 struct intr_handler *handler = (struct intr_handler *)cookie;
423 struct intr_event *ie;
425 struct intr_handler *ih;
433 ie = handler->ih_event;
435 ("interrupt handler \"%s\" has a NULL interrupt event",
437 mtx_lock(&ie->ie_lock);
438 CTR3(KTR_INTR, "%s: removing %s from %s", __func__, handler->ih_name,
441 TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next)
444 mtx_unlock(&ie->ie_lock);
445 panic("interrupt handler \"%s\" not found in interrupt event \"%s\"",
446 ih->ih_name, ie->ie_name);
450 * If there is no ithread, then just remove the handler and return.
451 * XXX: Note that an INTR_FAST handler might be running on another
454 if (ie->ie_thread == NULL) {
455 TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
456 mtx_unlock(&ie->ie_lock);
457 free(handler, M_ITHREAD);
462 * If the interrupt thread is already running, then just mark this
463 * handler as being dead and let the ithread do the actual removal.
465 * During a cold boot while cold is set, msleep() does not sleep,
466 * so we have to remove the handler here rather than letting the
469 mtx_lock_spin(&sched_lock);
470 if (!TD_AWAITING_INTR(ie->ie_thread->it_thread) && !cold) {
471 handler->ih_flags |= IH_DEAD;
474 * Ensure that the thread will process the handler list
475 * again and remove this handler if it has already passed
478 ie->ie_thread->it_need = 1;
480 TAILQ_REMOVE(&ie->ie_handlers, handler, ih_next);
481 mtx_unlock_spin(&sched_lock);
482 while (handler->ih_flags & IH_DEAD)
483 msleep(handler, &ie->ie_lock, 0, "iev_rmh", 0);
484 intr_event_update(ie);
487 * XXX: This could be bad in the case of ppbus(8). Also, I think
488 * this could lead to races of stale data when servicing an
492 TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
493 if (!(ih->ih_flags & IH_FAST)) {
499 ithread_destroy(ie->ie_thread);
500 ie->ie_thread = NULL;
503 mtx_unlock(&ie->ie_lock);
504 free(handler, M_ITHREAD);
509 intr_event_schedule_thread(struct intr_event *ie)
511 struct intr_entropy entropy;
512 struct intr_thread *it;
518 * If no ithread or no handlers, then we have a stray interrupt.
520 if (ie == NULL || TAILQ_EMPTY(&ie->ie_handlers) ||
521 ie->ie_thread == NULL)
530 * If any of the handlers for this ithread claim to be good
531 * sources of entropy, then gather some.
533 if (harvest.interrupt && ie->ie_flags & IE_ENTROPY) {
534 CTR3(KTR_INTR, "%s: pid %d (%s) gathering entropy", __func__,
535 p->p_pid, p->p_comm);
536 entropy.event = (uintptr_t)ie;
538 random_harvest(&entropy, sizeof(entropy), 2, 0,
542 KASSERT(p != NULL, ("ithread %s has no process", ie->ie_name));
545 * Set it_need to tell the thread to keep running if it is already
546 * running. Then, grab sched_lock and see if we actually need to
547 * put this thread on the runqueue.
550 mtx_lock_spin(&sched_lock);
551 if (TD_AWAITING_INTR(td)) {
552 CTR3(KTR_INTR, "%s: schedule pid %d (%s)", __func__, p->p_pid,
555 sched_add(td, SRQ_INTR);
557 CTR5(KTR_INTR, "%s: pid %d (%s): it_need %d, state %d",
558 __func__, p->p_pid, p->p_comm, it->it_need, td->td_state);
560 mtx_unlock_spin(&sched_lock);
566 * Add a software interrupt handler to a specified event. If a given event
567 * is not specified, then a new event is created.
570 swi_add(struct intr_event **eventp, const char *name, driver_intr_t handler,
571 void *arg, int pri, enum intr_type flags, void **cookiep)
573 struct intr_event *ie;
576 if (flags & (INTR_FAST | INTR_ENTROPY))
579 ie = (eventp != NULL) ? *eventp : NULL;
582 if (!(ie->ie_flags & IE_SOFT))
585 error = intr_event_create(&ie, NULL, IE_SOFT, NULL,
592 return (intr_event_add_handler(ie, name, handler, arg,
593 (pri * RQ_PPQ) + PI_SOFT, flags, cookiep));
594 /* XXKSE.. think of a better way to get separate queues */
598 * Schedule a software interrupt thread.
601 swi_sched(void *cookie, int flags)
603 struct intr_handler *ih = (struct intr_handler *)cookie;
604 struct intr_event *ie = ih->ih_event;
607 CTR3(KTR_INTR, "swi_sched: %s %s need=%d", ie->ie_name, ih->ih_name,
611 * Set ih_need for this handler so that if the ithread is already
612 * running it will execute this handler on the next pass. Otherwise,
613 * it will execute it the next time it runs.
615 atomic_store_rel_int(&ih->ih_need, 1);
617 if (!(flags & SWI_DELAY)) {
618 PCPU_LAZY_INC(cnt.v_soft);
619 error = intr_event_schedule_thread(ie);
620 KASSERT(error == 0, ("stray software interrupt"));
625 * Remove a software interrupt handler. Currently this code does not
626 * remove the associated interrupt event if it becomes empty. Calling code
627 * may do so manually via intr_event_destroy(), but that's not really
628 * an optimal interface.
631 swi_remove(void *cookie)
634 return (intr_event_remove_handler(cookie));
638 ithread_execute_handlers(struct proc *p, struct intr_event *ie)
640 struct intr_handler *ih, *ihn;
642 /* Interrupt handlers should not sleep. */
643 if (!(ie->ie_flags & IE_SOFT))
644 THREAD_NO_SLEEPING();
645 TAILQ_FOREACH_SAFE(ih, &ie->ie_handlers, ih_next, ihn) {
648 * If this handler is marked for death, remove it from
649 * the list of handlers and wake up the sleeper.
651 if (ih->ih_flags & IH_DEAD) {
652 mtx_lock(&ie->ie_lock);
653 TAILQ_REMOVE(&ie->ie_handlers, ih, ih_next);
654 ih->ih_flags &= ~IH_DEAD;
656 mtx_unlock(&ie->ie_lock);
661 * For software interrupt threads, we only execute
662 * handlers that have their need flag set. Hardware
663 * interrupt threads always invoke all of their handlers.
665 if (ie->ie_flags & IE_SOFT) {
669 atomic_store_rel_int(&ih->ih_need, 0);
672 /* Fast handlers are handled in primary interrupt context. */
673 if (ih->ih_flags & IH_FAST)
676 /* Execute this handler. */
677 CTR6(KTR_INTR, "%s: pid %d exec %p(%p) for %s flg=%x",
678 __func__, p->p_pid, (void *)ih->ih_handler, ih->ih_argument,
679 ih->ih_name, ih->ih_flags);
681 if (!(ih->ih_flags & IH_MPSAFE))
683 ih->ih_handler(ih->ih_argument);
684 if (!(ih->ih_flags & IH_MPSAFE))
687 if (!(ie->ie_flags & IE_SOFT))
688 THREAD_SLEEPING_OK();
691 * Interrupt storm handling:
693 * If this interrupt source is currently storming, then throttle
694 * it to only fire the handler once per clock tick.
696 * If this interrupt source is not currently storming, but the
697 * number of back to back interrupts exceeds the storm threshold,
698 * then enter storming mode.
700 if (intr_storm_threshold != 0 && ie->ie_count >= intr_storm_threshold) {
701 if (ie->ie_warned == 0) {
703 "Interrupt storm detected on \"%s\"; throttling interrupt source\n",
707 tsleep(&ie->ie_count, 0, "istorm", 1);
712 * Now that all the handlers have had a chance to run, reenable
713 * the interrupt source.
715 if (ie->ie_enable != NULL)
716 ie->ie_enable(ie->ie_source);
720 * This is the main code for interrupt threads.
723 ithread_loop(void *arg)
725 struct intr_thread *ithd;
726 struct intr_event *ie;
732 ithd = (struct intr_thread *)arg;
733 KASSERT(ithd->it_thread == td,
734 ("%s: ithread and proc linkage out of sync", __func__));
739 * As long as we have interrupts outstanding, go through the
740 * list of handlers, giving each one a go at it.
744 * If we are an orphaned thread, then just die.
746 if (ithd->it_flags & IT_DEAD) {
747 CTR3(KTR_INTR, "%s: pid %d (%s) exiting", __func__,
748 p->p_pid, p->p_comm);
749 free(ithd, M_ITHREAD);
754 * Service interrupts. If another interrupt arrives while
755 * we are running, it will set it_need to note that we
756 * should make another pass.
758 while (ithd->it_need) {
760 * This might need a full read and write barrier
761 * to make sure that this write posts before any
762 * of the memory or device accesses in the
765 atomic_store_rel_int(&ithd->it_need, 0);
766 ithread_execute_handlers(p, ie);
768 WITNESS_WARN(WARN_PANIC, NULL, "suspending ithread");
769 mtx_assert(&Giant, MA_NOTOWNED);
772 * Processed all our interrupts. Now get the sched
773 * lock. This may take a while and it_need may get
774 * set again, so we have to check it again.
776 mtx_lock_spin(&sched_lock);
777 if (!ithd->it_need && !(ithd->it_flags & IT_DEAD)) {
780 mi_switch(SW_VOL, NULL);
782 mtx_unlock_spin(&sched_lock);
788 * Dump details about an interrupt handler
791 db_dump_intrhand(struct intr_handler *ih)
795 db_printf("\t%-10s ", ih->ih_name);
796 switch (ih->ih_pri) {
821 if (ih->ih_pri >= PI_SOFT)
824 db_printf("%4u", ih->ih_pri);
828 db_printsym((uintptr_t)ih->ih_handler, DB_STGY_PROC);
829 db_printf("(%p)", ih->ih_argument);
831 (ih->ih_flags & (IH_FAST | IH_EXCLUSIVE | IH_ENTROPY | IH_DEAD |
835 if (ih->ih_flags & IH_FAST) {
839 if (ih->ih_flags & IH_EXCLUSIVE) {
845 if (ih->ih_flags & IH_ENTROPY) {
848 db_printf("ENTROPY");
851 if (ih->ih_flags & IH_DEAD) {
857 if (ih->ih_flags & IH_MPSAFE) {
874 * Dump details about a event.
877 db_dump_intr_event(struct intr_event *ie, int handlers)
879 struct intr_handler *ih;
880 struct intr_thread *it;
883 db_printf("%s ", ie->ie_fullname);
886 db_printf("(pid %d)", it->it_thread->td_proc->p_pid);
888 db_printf("(no thread)");
889 if ((ie->ie_flags & (IE_SOFT | IE_ENTROPY | IE_ADDING_THREAD)) != 0 ||
890 (it != NULL && it->it_need)) {
893 if (ie->ie_flags & IE_SOFT) {
897 if (ie->ie_flags & IE_ENTROPY) {
900 db_printf("ENTROPY");
903 if (ie->ie_flags & IE_ADDING_THREAD) {
906 db_printf("ADDING_THREAD");
909 if (it != NULL && it->it_need) {
919 TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next)
920 db_dump_intrhand(ih);
924 * Dump data about interrupt handlers
926 DB_SHOW_COMMAND(intr, db_show_intr)
928 struct intr_event *ie;
931 verbose = index(modif, 'v') != NULL;
932 all = index(modif, 'a') != NULL;
933 TAILQ_FOREACH(ie, &event_list, ie_list) {
934 if (!all && TAILQ_EMPTY(&ie->ie_handlers))
936 db_dump_intr_event(ie, verbose);
944 * Start standard software interrupt threads
947 start_softintr(void *dummy)
951 if (swi_add(&clk_intr_event, "clock", softclock, NULL, SWI_CLOCK,
952 INTR_MPSAFE, &softclock_ih) ||
953 swi_add(NULL, "vm", swi_vm, NULL, SWI_VM, INTR_MPSAFE, &vm_ih))
954 panic("died while creating standard software ithreads");
956 p = clk_intr_event->ie_thread->it_thread->td_proc;
958 p->p_flag |= P_NOLOAD;
961 SYSINIT(start_softintr, SI_SUB_SOFTINTR, SI_ORDER_FIRST, start_softintr, NULL)
964 * Sysctls used by systat and others: hw.intrnames and hw.intrcnt.
965 * The data for this machine dependent, and the declarations are in machine
966 * dependent code. The layout of intrnames and intrcnt however is machine
969 * We do not know the length of intrcnt and intrnames at compile time, so
970 * calculate things at run time.
973 sysctl_intrnames(SYSCTL_HANDLER_ARGS)
975 return (sysctl_handle_opaque(oidp, intrnames, eintrnames - intrnames,
979 SYSCTL_PROC(_hw, OID_AUTO, intrnames, CTLTYPE_OPAQUE | CTLFLAG_RD,
980 NULL, 0, sysctl_intrnames, "", "Interrupt Names");
983 sysctl_intrcnt(SYSCTL_HANDLER_ARGS)
985 return (sysctl_handle_opaque(oidp, intrcnt,
986 (char *)eintrcnt - (char *)intrcnt, req));
989 SYSCTL_PROC(_hw, OID_AUTO, intrcnt, CTLTYPE_OPAQUE | CTLFLAG_RD,
990 NULL, 0, sysctl_intrcnt, "", "Interrupt Counts");
994 * DDB command to dump the interrupt statistics.
996 DB_SHOW_COMMAND(intrcnt, db_show_intrcnt)
1002 for (i = intrcnt; i != eintrcnt && !db_pager_quit; i++) {
1006 db_printf("%s\t%lu\n", cp, *i);
1007 cp += strlen(cp) + 1;