From b31e373bf75bda53b11e3c55da3efcc34c423af8 Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Thu, 11 Jan 2007 00:17:02 +0000 Subject: [PATCH] - Use the correct test in the ipi bitmask handler for IPI_PREEMPT so that we actually issue preemptions. - Remove the #ifdef IPI_PREEMPTION so it is always compiled in. Leave the option which optionally enables support in sched_4bsd. sched_ule.c will soon use this functionality as a run time rather than compile time option. - Compare against the idlethread rather than the priority. There are some idle prio tasks that we can preempt. Discussed with: ups Tested on: i386, amd64 --- sys/amd64/amd64/mp_machdep.c | 6 ++---- sys/i386/i386/mp_machdep.c | 12 +++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index dbd1e444544..d94cafb78cf 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -948,11 +948,10 @@ ipi_bitmap_handler(struct trapframe frame) ipi_bitmap = atomic_readandclear_int(&cpu_ipi_pending[cpu]); -#ifdef IPI_PREEMPTION - if (ipi_bitmap & IPI_PREEMPT) { + if (ipi_bitmap & (1 << IPI_PREEMPT)) { mtx_lock_spin(&sched_lock); /* Don't preempt the idle thread */ - if (curthread->td_priority < PRI_MIN_IDLE) { + if (curthread != PCPU_GET(idlethread)) { struct thread *running_thread = curthread; if (running_thread->td_critnest > 1) running_thread->td_owepreempt = 1; @@ -961,7 +960,6 @@ ipi_bitmap_handler(struct trapframe frame) } mtx_unlock_spin(&sched_lock); } -#endif /* Nothing to do for AST */ } diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index 1933511b0f6..4cc5b7357cb 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -163,9 +163,7 @@ static void ipi_nmi_selected(u_int32_t cpus); #ifdef COUNT_IPIS /* Interrupt counts. */ -#ifdef IPI_PREEMPTION static u_long *ipi_preempt_counts[MAXCPU]; -#endif static u_long *ipi_ast_counts[MAXCPU]; u_long *ipi_invltlb_counts[MAXCPU]; u_long *ipi_invlrng_counts[MAXCPU]; @@ -1143,14 +1141,13 @@ ipi_bitmap_handler(struct trapframe frame) ipi_bitmap = atomic_readandclear_int(&cpu_ipi_pending[cpu]); -#ifdef IPI_PREEMPTION - if (ipi_bitmap & IPI_PREEMPT) { + if (ipi_bitmap & (1 << IPI_PREEMPT)) { #ifdef COUNT_IPIS *ipi_preempt_counts[cpu]++; #endif mtx_lock_spin(&sched_lock); /* Don't preempt the idle thread */ - if (curthread->td_priority < PRI_MIN_IDLE) { + if (curthread != PCPU_GET(idlethread)) { struct thread *running_thread = curthread; if (running_thread->td_critnest > 1) running_thread->td_owepreempt = 1; @@ -1159,9 +1156,8 @@ ipi_bitmap_handler(struct trapframe frame) } mtx_unlock_spin(&sched_lock); } -#endif - if (ipi_bitmap & IPI_AST) { + if (ipi_bitmap & (1 << IPI_AST)) { #ifdef COUNT_IPIS *ipi_ast_counts[cpu]++; #endif @@ -1514,10 +1510,8 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, &ipi_invlrng_counts[i]); snprintf(buf, sizeof(buf), "cpu%d: invlpg", i); intrcnt_add(buf, &ipi_invlpg_counts[i]); -#ifdef IPI_PREEMPTION snprintf(buf, sizeof(buf), "cpu%d: preempt", i); intrcnt_add(buf, &ipi_preempt_counts[i]); -#endif snprintf(buf, sizeof(buf), "cpu%d: ast", i); intrcnt_add(buf, &ipi_ast_counts[i]); snprintf(buf, sizeof(buf), "cpu%d: rendezvous", i);