aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time/tick-sched.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r--kernel/time/tick-sched.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index f992762d7f51..0adc54bd7c7c 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -721,6 +721,46 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
721} 721}
722 722
723/** 723/**
724 * tick_set_quanta_type - get the quanta type as a boot option
725 * Default is standard setup with ticks staggered over first
726 * half of tick period.
727 */
728int quanta_type = LINUX_DEFAULT_TICKS;
729static int __init tick_set_quanta_type(char *str)
730{
731 if (strcmp("aligned", str) == 0) {
732 quanta_type = LITMUS_ALIGNED_TICKS;
733 printk(KERN_INFO "LITMUS^RT: setting aligned quanta\n");
734 }
735 else if (strcmp("staggered", str) == 0) {
736 quanta_type = LITMUS_STAGGERED_TICKS;
737 printk(KERN_INFO "LITMUS^RT: setting staggered quanta\n");
738 }
739 return 1;
740}
741__setup("quanta=", tick_set_quanta_type);
742
743u64 cpu_stagger_offset(int cpu)
744{
745 u64 offset = 0;
746 switch (quanta_type) {
747 case LITMUS_ALIGNED_TICKS:
748 offset = 0;
749 break;
750 case LITMUS_STAGGERED_TICKS:
751 offset = ktime_to_ns(tick_period);
752 do_div(offset, num_possible_cpus());
753 offset *= cpu;
754 break;
755 default:
756 offset = ktime_to_ns(tick_period) >> 1;
757 do_div(offset, num_possible_cpus());
758 offset *= cpu;
759 }
760 return offset;
761}
762
763/**
724 * tick_setup_sched_timer - setup the tick emulation timer 764 * tick_setup_sched_timer - setup the tick emulation timer
725 */ 765 */
726void tick_setup_sched_timer(void) 766void tick_setup_sched_timer(void)
@@ -737,9 +777,11 @@ void tick_setup_sched_timer(void)
737 777
738 /* Get the next period (per cpu) */ 778 /* Get the next period (per cpu) */
739 hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update()); 779 hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());
740 offset = ktime_to_ns(tick_period) >> 1; 780
741 do_div(offset, num_possible_cpus()); 781 /* Offset must be set correctly to achieve desired quanta type. */
742 offset *= smp_processor_id(); 782 offset = cpu_stagger_offset(smp_processor_id());
783
784 /* Add the correct offset to expiration time */
743 hrtimer_add_expires_ns(&ts->sched_timer, offset); 785 hrtimer_add_expires_ns(&ts->sched_timer, offset);
744 786
745 for (;;) { 787 for (;;) {