From 42098fc3d098a14b8a0137565e72f24aef743c67 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Tue, 14 Jun 2016 17:00:01 +0800 Subject: [PATCH] cputimer: Add per-cpu handler and private data for interrupt cputimer. --- sys/kern/kern_cputimer.c | 38 ++++++++++++++++++++++++++++++ sys/kern/kern_systimer.c | 27 --------------------- sys/platform/pc64/apic/lapic.c | 4 +++- sys/platform/pc64/isa/clock.c | 4 +++- sys/platform/vkernel64/platform/systimer.c | 4 +++- sys/sys/systimer.h | 4 ++++ 6 files changed, 51 insertions(+), 30 deletions(-) diff --git a/sys/kern/kern_cputimer.c b/sys/kern/kern_cputimer.c index 47a68db9f9..e84a2bc377 100644 --- a/sys/kern/kern_cputimer.c +++ b/sys/kern/kern_cputimer.c @@ -45,6 +45,9 @@ #include #include +extern void pcpu_timer_process(void); +extern void pcpu_timer_process_frame(struct intrframe *); + static sysclock_t dummy_cputimer_count(void); static struct cputimer dummy_cputimer = { @@ -572,3 +575,38 @@ cputimer_intr_powersave_remreq(void) lwkt_serialize_exit(&cputimer_intr_ps_slize); } + +static __inline void +cputimer_intr_pcpuhand(void) +{ + struct cputimer_intr *cti = sys_cputimer_intr; + + if (cti->pcpuhand != NULL) + cti->pcpuhand(cti); +} + +static void +pcpu_timer_process_oncpu(struct globaldata *gd, struct intrframe *frame) +{ + sysclock_t count; + + cputimer_intr_pcpuhand(); + + gd->gd_timer_running = 0; + + count = sys_cputimer->count(); + if (TAILQ_FIRST(&gd->gd_systimerq) != NULL) + systimer_intr(&count, 0, frame); +} + +void +pcpu_timer_process(void) +{ + pcpu_timer_process_oncpu(mycpu, NULL); +} + +void +pcpu_timer_process_frame(struct intrframe *frame) +{ + pcpu_timer_process_oncpu(mycpu, frame); +} diff --git a/sys/kern/kern_systimer.c b/sys/kern/kern_systimer.c index a73d1a0730..50283004a8 100644 --- a/sys/kern/kern_systimer.c +++ b/sys/kern/kern_systimer.c @@ -58,9 +58,6 @@ #include #include -extern void pcpu_timer_process(void); -extern void pcpu_timer_process_frame(struct intrframe *); - /* * Execute ready systimers. Called directly from the platform-specific * one-shot timer clock interrupt (e.g. clkintr()) or via an IPI. May @@ -301,27 +298,3 @@ systimer_init_oneshot(systimer_t info, systimer_func_t func, void *data, int us) info->gd = mycpu; systimer_add(info); } - -static void -pcpu_timer_process_oncpu(struct globaldata *gd, struct intrframe *frame) -{ - sysclock_t count; - - gd->gd_timer_running = 0; - - count = sys_cputimer->count(); - if (TAILQ_FIRST(&gd->gd_systimerq) != NULL) - systimer_intr(&count, 0, frame); -} - -void -pcpu_timer_process(void) -{ - pcpu_timer_process_oncpu(mycpu, NULL); -} - -void -pcpu_timer_process_frame(struct intrframe *frame) -{ - pcpu_timer_process_oncpu(mycpu, frame); -} diff --git a/sys/platform/pc64/apic/lapic.c b/sys/platform/pc64/apic/lapic.c index 7e9df916cf..9500b648b7 100644 --- a/sys/platform/pc64/apic/lapic.c +++ b/sys/platform/pc64/apic/lapic.c @@ -72,11 +72,13 @@ static struct cputimer_intr lapic_cputimer_intr = { .restart = lapic_timer_intr_restart, .pmfixup = lapic_timer_intr_pmfixup, .initclock = cputimer_intr_default_initclock, + .pcpuhand = NULL, .next = SLIST_ENTRY_INITIALIZER, .name = "lapic", .type = CPUTIMER_INTR_LAPIC, .prio = CPUTIMER_INTR_PRIO_LAPIC, - .caps = CPUTIMER_INTR_CAP_NONE + .caps = CPUTIMER_INTR_CAP_NONE, + .priv = NULL }; static int lapic_timer_divisor_idx = -1; diff --git a/sys/platform/pc64/isa/clock.c b/sys/platform/pc64/isa/clock.c index 7669125b79..8ec70288f0 100644 --- a/sys/platform/pc64/isa/clock.c +++ b/sys/platform/pc64/isa/clock.c @@ -177,11 +177,13 @@ static struct cputimer_intr i8254_cputimer_intr = { .restart = cputimer_intr_default_restart, .pmfixup = cputimer_intr_default_pmfixup, .initclock = i8254_intr_initclock, + .pcpuhand = NULL, .next = SLIST_ENTRY_INITIALIZER, .name = "i8254", .type = CPUTIMER_INTR_8254, .prio = CPUTIMER_INTR_PRIO_8254, - .caps = CPUTIMER_INTR_CAP_PS + .caps = CPUTIMER_INTR_CAP_PS, + .priv = NULL }; /* diff --git a/sys/platform/vkernel64/platform/systimer.c b/sys/platform/vkernel64/platform/systimer.c index 5ef35fb99b..d48b58a52b 100644 --- a/sys/platform/vkernel64/platform/systimer.c +++ b/sys/platform/vkernel64/platform/systimer.c @@ -109,11 +109,13 @@ static struct cputimer_intr vkernel_cputimer_intr = { .restart = cputimer_intr_default_restart, .pmfixup = cputimer_intr_default_pmfixup, .initclock = vktimer_intr_initclock, + .pcpuhand = NULL, .next = SLIST_ENTRY_INITIALIZER, .name = "vkernel", .type = CPUTIMER_INTR_VKERNEL, .prio = CPUTIMER_INTR_PRIO_VKERNEL, - .caps = CPUTIMER_INTR_CAP_NONE + .caps = CPUTIMER_INTR_CAP_NONE, + .priv = NULL }; /* diff --git a/sys/sys/systimer.h b/sys/sys/systimer.h index ffc2f08f8a..58c86e8a5b 100644 --- a/sys/sys/systimer.h +++ b/sys/sys/systimer.h @@ -175,6 +175,7 @@ void cputimer_default_destruct(struct cputimer *); * restart -- Start the possibly stalled interrupt cputimer immediately. * Do fixup if necessary. * pmfixup -- Called after ACPI power management is enabled. + * pcpuhand -- Per-cpu handler (could be NULL). */ struct cputimer_intr { sysclock_t freq; @@ -190,11 +191,14 @@ struct cputimer_intr { (struct cputimer_intr *); void (*initclock) (struct cputimer_intr *, boolean_t); + void (*pcpuhand) + (struct cputimer_intr *); SLIST_ENTRY(cputimer_intr) next; const char *name; int type; /* CPUTIMER_INTR_ */ int prio; /* CPUTIMER_INTR_PRIO_ */ uint32_t caps; /* CPUTIMER_INTR_CAP_ */ + void *priv; /* private data */ }; #define CPUTIMER_INTR_8254 0 -- 2.11.4.GIT