From c7d1f86705369bed0c65be15b898a9251de21c76 Mon Sep 17 00:00:00 2001 From: "John M. Calandrino" Date: Wed, 30 Apr 2008 16:49:58 -0400 Subject: add synchronized quanta support Modify offsets in such a way that quantum boundaries occur either synchronized or staggered (based on the kernel command line). --- include/linux/tick.h | 3 +++ kernel/time/tick-sched.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/include/linux/tick.h b/include/linux/tick.h index f4a1395e05..7eae3585cb 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -64,6 +64,9 @@ extern int tick_is_oneshot_available(void); extern struct tick_device *tick_get_device(int cpu); # ifdef CONFIG_HIGH_RES_TIMERS +#define LINUX_DEFAULT_TICKS 0 +#define LITMUS_ALIGNED_TICKS 1 +#define LITMUS_STAGGERED_TICKS 2 extern int tick_init_highres(void); extern int tick_program_event(ktime_t expires, int force); extern void tick_setup_sched_timer(void); diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index cb89fa8db1..3b1936fac0 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -567,6 +567,22 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer) return HRTIMER_RESTART; } +/** + * tick_set_quanta_type - get the quanta type as a boot option + * Default is standard setup with ticks staggered over first + * half of tick period. + */ +int quanta_type = LINUX_DEFAULT_TICKS; +static int __init tick_set_quanta_type(char *str) +{ + if (strcmp("aligned", str) == 0) + quanta_type = LITMUS_ALIGNED_TICKS; + else if (strcmp("staggered", str) == 0) + quanta_type = LITMUS_STAGGERED_TICKS; + return 1; +} +__setup("quanta=", tick_set_quanta_type); + /** * tick_setup_sched_timer - setup the tick emulation timer */ @@ -585,9 +601,24 @@ void tick_setup_sched_timer(void) /* Get the next period (per cpu) */ ts->sched_timer.expires = tick_init_jiffy_update(); - offset = ktime_to_ns(tick_period) >> 1; - do_div(offset, num_possible_cpus()); - offset *= smp_processor_id(); + + /* Offset must be set correctly to achieve desired quanta type. */ + switch (quanta_type) { + case LITMUS_ALIGNED_TICKS: + offset = 0; + break; + case LITMUS_STAGGERED_TICKS: + offset = ktime_to_ns(tick_period); + do_div(offset, num_possible_cpus()); + offset *= smp_processor_id(); + break; + default: + offset = ktime_to_ns(tick_period) >> 1; + do_div(offset, num_possible_cpus()); + offset *= smp_processor_id(); + } + + /* Add correct offset to expiration time. */ ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset); for (;;) { -- cgit v1.2.2