From: Matthew Dillon Date: Fri, 28 Oct 2011 16:27:20 +0000 (-0700) Subject: kernel - add lwkt_set_interrupt_support_thread() API X-Git-Url: https://gitweb.dragonflybsd.org/~lentferj/dragonfly.git/commitdiff_plain/e6546af9e0ddd006849722f5ea6b457fdf1771f5 kernel - add lwkt_set_interrupt_support_thread() API * Add a new API that may be used by a device driver's support thread to run the thread at a higher (near interrupt) priority and allow it to preempt normal threads. * Adjust the AHCI driver's helper threads to use the new API. --- diff --git a/sys/dev/disk/ahci/ahci_dragonfly.c b/sys/dev/disk/ahci/ahci_dragonfly.c index 55d524bb90..a550644db6 100644 --- a/sys/dev/disk/ahci/ahci_dragonfly.c +++ b/sys/dev/disk/ahci/ahci_dragonfly.c @@ -367,6 +367,12 @@ ahci_port_thread(void *arg) struct ahci_port *ap = arg; int mask; + /* + * Sets us up as an interrupt support thread, meaning we are + * given a higher priority and we can preempt normal threads. + */ + lwkt_set_interrupt_support_thread(); + /* * The helper thread is responsible for the initial port init, * so all the ports can be inited in parallel. diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c index e3dd7705ce..c55ebdd827 100644 --- a/sys/kern/lwkt_thread.c +++ b/sys/kern/lwkt_thread.c @@ -1117,12 +1117,6 @@ lwkt_preempt(thread_t ntd, int critcount) KKASSERT(ntd->td_preempted && (td->td_flags & TDF_PREEMPT_DONE)); ntd->td_preempted = NULL; td->td_flags &= ~(TDF_PREEMPT_LOCK|TDF_PREEMPT_DONE); -#if 1 - /* - * catch-all - */ - splz_check(); -#endif } /* @@ -1166,6 +1160,22 @@ lwkt_maybe_splz(thread_t td) } } +/* + * Drivers which set up processing co-threads can call this function to + * run the co-thread at a higher priority and to allow it to preempt + * normal threads. + */ +void +lwkt_set_interrupt_support_thread(void) +{ + thread_t td = curthread; + + lwkt_setpri_self(TDPRI_INT_SUPPORT); + td->td_flags |= TDF_INTTHREAD; + td->td_preemptable = lwkt_preempt; +} + + /* * This function is used to negotiate a passive release of the current * process/lwp designation with the user scheduler, allowing the user diff --git a/sys/sys/thread.h b/sys/sys/thread.h index 9e1baadbb0..0f2259516a 100644 --- a/sys/sys/thread.h +++ b/sys/sys/thread.h @@ -405,6 +405,7 @@ extern void lwkt_init(void); extern struct thread *lwkt_alloc_thread(struct thread *, int, int, int); extern void lwkt_init_thread(struct thread *, void *, int, int, struct globaldata *); +extern void lwkt_set_interrupt_support_thread(void); extern void lwkt_set_comm(thread_t, const char *, ...) __printflike(2, 3); extern void lwkt_wait_free(struct thread *); extern void lwkt_free_thread(struct thread *);