From 6d449d27d9b974175ea30c8dfe3a388718c78183 Mon Sep 17 00:00:00 2001 From: Kip Macy Date: Fri, 2 Feb 2007 05:00:21 +0000 Subject: [PATCH] Add support for IPI_PREEMPT in order to enable use of the ULE scheduler --- sys/sun4v/include/intr_machdep.h | 1 + sys/sun4v/include/smp.h | 3 +++ sys/sun4v/sun4v/intr_machdep.c | 4 +++- sys/sun4v/sun4v/mp_machdep.c | 14 ++++++++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/sun4v/include/intr_machdep.h b/sys/sun4v/include/intr_machdep.h index 4c8111c7be9..9788e3904d7 100644 --- a/sys/sun4v/include/intr_machdep.h +++ b/sys/sun4v/include/intr_machdep.h @@ -46,6 +46,7 @@ #define PIL_RENDEZVOUS 3 /* smp rendezvous ipi */ #define PIL_AST 4 /* ast ipi */ #define PIL_STOP 5 /* stop cpu ipi */ +#define PIL_PREEMPT 6 /* preempt idle thread cpu ipi */ #define PIL_FAST 13 /* fast interrupts */ #define PIL_TICK 14 diff --git a/sys/sun4v/include/smp.h b/sys/sun4v/include/smp.h index b562c2b470e..73359814d41 100644 --- a/sys/sun4v/include/smp.h +++ b/sys/sun4v/include/smp.h @@ -44,6 +44,8 @@ #define IPI_AST PIL_AST #define IPI_RENDEZVOUS PIL_RENDEZVOUS #define IPI_STOP PIL_STOP +#define IPI_PREEMPT PIL_PREEMPT + #define IPI_RETRIES 5000 @@ -79,6 +81,7 @@ void cpu_ipi_send(u_int mid, u_long d0, u_long d1, u_long d2); void cpu_ipi_ast(struct trapframe *tf); void cpu_ipi_stop(struct trapframe *tf); +void cpu_ipi_preempt(struct trapframe *tf); void ipi_selected(u_int cpus, u_int ipi); void ipi_all(u_int ipi); diff --git a/sys/sun4v/sun4v/intr_machdep.c b/sys/sun4v/sun4v/intr_machdep.c index edb5efe2dd1..6f17a698240 100644 --- a/sys/sun4v/sun4v/intr_machdep.c +++ b/sys/sun4v/sun4v/intr_machdep.c @@ -114,7 +114,8 @@ static char *pil_names[] = { "rndzvs", /* PIL_RENDEZVOUS */ "ast", /* PIL_AST */ "stop", /* PIL_STOP */ - "stray", "stray", "stray", "stray", "stray", "stray", "stray", + "preempt", /* PIL_PREEMPT */ + "stray", "stray", "stray", "stray", "stray", "stray", "fast", /* PIL_FAST */ "tick", /* PIL_TICK */ }; @@ -266,6 +267,7 @@ intr_init(void) intr_handlers[PIL_AST] = cpu_ipi_ast; intr_handlers[PIL_RENDEZVOUS] = (ih_func_t *)smp_rendezvous_action; intr_handlers[PIL_STOP]= cpu_ipi_stop; + intr_handlers[PIL_PREEMPT]= cpu_ipi_preempt; #endif mtx_init(&intr_table_lock, "intr table", NULL, MTX_SPIN); cpu_intrq_alloc(); diff --git a/sys/sun4v/sun4v/mp_machdep.c b/sys/sun4v/sun4v/mp_machdep.c index d3cea9d13d7..e9c7d435f45 100644 --- a/sys/sun4v/sun4v/mp_machdep.c +++ b/sys/sun4v/sun4v/mp_machdep.c @@ -455,6 +455,20 @@ cpu_ipi_stop(struct trapframe *tf) CTR1(KTR_SMP, "cpu_ipi_stop: restarted %d", curcpu); } +void +cpu_ipi_preempt(struct trapframe *tf) +{ + struct thread *running_thread = curthread; + + mtx_lock_spin(&sched_lock); + if (running_thread->td_critnest > 1) + running_thread->td_owepreempt = 1; + else + mi_switch(SW_INVOL | SW_PREEMPT, NULL); + mtx_unlock_spin(&sched_lock); + +} + void cpu_ipi_selected(int cpu_count, uint16_t *cpulist, u_long d0, u_long d1, u_long d2, uint64_t *ackmask) { -- 2.45.2