SMP - trully idle APs
- any cpu can use smp_schedule() to tell another cpu to reschedule - if an AP is idle, it turns off timer as there is nothing to preempt, no need to wakeup just to go back to sleep again - if a cpu makes a process runnable on an idle cpu, it must wake it up to reschedule
This commit is contained in:
+11
-5
@@ -159,7 +159,10 @@ PRIVATE u32_t lapic_tctr0, lapic_tctr1;
|
||||
PRIVATE unsigned apic_imcrp;
|
||||
PRIVATE const unsigned nlints = 0;
|
||||
|
||||
#define apic_eoi() do { *((volatile u32_t *) lapic_eoi_addr) = 0; } while(0)
|
||||
PUBLIC void arch_eoi(void)
|
||||
{
|
||||
apic_eoi();
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME this should be a cpulocal variable but there are some problems with
|
||||
@@ -394,10 +397,6 @@ PUBLIC void ioapic_mask_irq(unsigned irq)
|
||||
irq_8259_mask(irq);
|
||||
}
|
||||
|
||||
PUBLIC void apic_ipi_sched_handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
PUBLIC unsigned int apicid(void)
|
||||
{
|
||||
return lapic_read(LAPIC_ID);
|
||||
@@ -546,6 +545,13 @@ PUBLIC void lapic_stop_timer(void)
|
||||
lapic_write(LAPIC_LVTTR, lvtt | APIC_LVTT_MASK);
|
||||
}
|
||||
|
||||
PUBLIC void lapic_restart_timer(void)
|
||||
{
|
||||
u32_t lvtt;
|
||||
lvtt = lapic_read(LAPIC_LVTTR);
|
||||
lapic_write(LAPIC_LVTTR, lvtt & ~APIC_LVTT_MASK);
|
||||
}
|
||||
|
||||
PUBLIC void lapic_microsec_sleep(unsigned count)
|
||||
{
|
||||
lapic_set_timer_one_shot(count);
|
||||
|
||||
@@ -152,11 +152,14 @@ _PROTOTYPE(int apic_single_cpu_init, (void));
|
||||
_PROTOTYPE(void lapic_set_timer_periodic, (const unsigned freq));
|
||||
_PROTOTYPE(void lapic_set_timer_one_shot, (const u32_t value));
|
||||
_PROTOTYPE(void lapic_stop_timer, (void));
|
||||
_PROTOTYPE(void lapic_restart_timer, (void));
|
||||
|
||||
_PROTOTYPE(void ioapic_set_irq, (unsigned irq));
|
||||
_PROTOTYPE(void ioapic_unset_irq, (unsigned irq));
|
||||
|
||||
/* signal the end of interrupt handler to apic */
|
||||
/* signal the end of interrupt handler to apic */
|
||||
#define apic_eoi() do { *((volatile u32_t *) lapic_eoi_addr) = 0; } while(0)
|
||||
|
||||
_PROTOTYPE(void ioapic_eoi, (int irq));
|
||||
|
||||
_PROTOTYPE(void dump_apic_irq_state, (void));
|
||||
@@ -166,8 +169,6 @@ _PROTOTYPE(void apic_send_ipi, (unsigned vector, unsigned cpu, int type));
|
||||
_PROTOTYPE(void apic_ipi_sched_intr, (void));
|
||||
_PROTOTYPE(void apic_ipi_halt_intr, (void));
|
||||
|
||||
_PROTOTYPE(void apic_ipi_sched_handler, (void));
|
||||
|
||||
#define APIC_IPI_DEST 0
|
||||
#define APIC_IPI_SELF 1
|
||||
#define APIC_IPI_TO_ALL 2
|
||||
|
||||
@@ -70,7 +70,7 @@ ENTRY(lapic_timer_int_handler)
|
||||
#ifdef CONFIG_SMP
|
||||
|
||||
ENTRY(apic_ipi_sched_intr)
|
||||
lapic_intr(_C_LABEL(apic_ipi_sched_handler))
|
||||
lapic_intr(_C_LABEL(smp_ipi_sched_handler))
|
||||
|
||||
ENTRY(apic_ipi_halt_intr)
|
||||
lapic_intr(_C_LABEL(smp_ipi_halt_handler))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "kernel/clock.h"
|
||||
#include "kernel/proc.h"
|
||||
#include "kernel/interrupt.h"
|
||||
#include <minix/u64.h>
|
||||
#include "glo.h"
|
||||
|
||||
@@ -144,6 +145,7 @@ PUBLIC void arch_stop_local_timer(void)
|
||||
#ifdef CONFIG_APIC
|
||||
if (lapic_addr) {
|
||||
lapic_stop_timer();
|
||||
apic_eoi();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -151,6 +153,18 @@ PUBLIC void arch_stop_local_timer(void)
|
||||
}
|
||||
}
|
||||
|
||||
PUBLIC void arch_restart_local_timer(void)
|
||||
{
|
||||
#ifdef CONFIG_APIC
|
||||
if (lapic_addr) {
|
||||
lapic_restart_timer();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
init_8253A_timer(system_hz);
|
||||
}
|
||||
}
|
||||
|
||||
PUBLIC int arch_register_local_timer_handler(const irq_handler_t handler)
|
||||
{
|
||||
#ifdef CONFIG_APIC
|
||||
@@ -243,7 +257,16 @@ PUBLIC void context_stop(struct proc * p)
|
||||
|
||||
PUBLIC void context_stop_idle(void)
|
||||
{
|
||||
context_stop(proc_addr(IDLE));
|
||||
int is_idle;
|
||||
unsigned cpu = cpuid;
|
||||
|
||||
is_idle = get_cpu_var(cpu, cpu_is_idle);
|
||||
get_cpu_var(cpu, cpu_is_idle) = 0;
|
||||
|
||||
context_stop(get_cpulocal_var_ptr(idle_proc));
|
||||
|
||||
if (is_idle)
|
||||
arch_restart_local_timer();
|
||||
}
|
||||
|
||||
PUBLIC u64_t ms_2_cpu_time(unsigned ms)
|
||||
|
||||
@@ -353,3 +353,8 @@ PUBLIC void arch_smp_halt_cpu(void)
|
||||
BKL_UNLOCK();
|
||||
for(;;);
|
||||
}
|
||||
|
||||
PUBLIC void arch_send_smp_schedule_ipi(unsigned cpu)
|
||||
{
|
||||
apic_send_ipi(APIC_SMP_SCHED_PROC_VECTOR, cpu, APIC_IPI_DEST);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ _PROTOTYPE(void i8259_disable,(void));
|
||||
ioapic_reset_pic(); \
|
||||
lapic_disable(); \
|
||||
} while (0)
|
||||
#ifdef CONFIG_SMP
|
||||
#define ipi_ack apic_eoi
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* legacy PIC */
|
||||
|
||||
Reference in New Issue
Block a user