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.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index d5097c44b40..0c0e02f1b81 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -766,12 +766,53 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
766} 766}
767 767
768/** 768/**
769 * tick_set_quanta_type - get the quanta type as a boot option
770 * Default is standard setup with ticks staggered over first
771 * half of tick period.
772 */
773int quanta_type = LINUX_DEFAULT_TICKS;
774static int __init tick_set_quanta_type(char *str)
775{
776 if (strcmp("aligned", str) == 0) {
777 quanta_type = LITMUS_ALIGNED_TICKS;
778 printk(KERN_INFO "LITMUS^RT: setting aligned quanta\n");
779 }
780 else if (strcmp("staggered", str) == 0) {
781 quanta_type = LITMUS_STAGGERED_TICKS;
782 printk(KERN_INFO "LITMUS^RT: setting staggered quanta\n");
783 }
784 return 1;
785}
786__setup("quanta=", tick_set_quanta_type);
787
788u64 cpu_stagger_offset(int cpu)
789{
790 u64 offset = 0;
791 switch (quanta_type) {
792 case LITMUS_ALIGNED_TICKS:
793 offset = 0;
794 break;
795 case LITMUS_STAGGERED_TICKS:
796 offset = ktime_to_ns(tick_period);
797 do_div(offset, num_possible_cpus());
798 offset *= cpu;
799 break;
800 default:
801 offset = ktime_to_ns(tick_period) >> 1;
802 do_div(offset, num_possible_cpus());
803 offset *= cpu;
804 }
805 return offset;
806}
807
808/**
769 * tick_setup_sched_timer - setup the tick emulation timer 809 * tick_setup_sched_timer - setup the tick emulation timer
770 */ 810 */
771void tick_setup_sched_timer(void) 811void tick_setup_sched_timer(void)
772{ 812{
773 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched); 813 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
774 ktime_t now = ktime_get(); 814 ktime_t now = ktime_get();
815 u64 offset;
775 816
776 /* 817 /*
777 * Emulate tick processing via per-CPU hrtimers: 818 * Emulate tick processing via per-CPU hrtimers:
@@ -782,6 +823,12 @@ void tick_setup_sched_timer(void)
782 /* Get the next period (per cpu) */ 823 /* Get the next period (per cpu) */
783 hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update()); 824 hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());
784 825
826 /* Offset must be set correctly to achieve desired quanta type. */
827 offset = cpu_stagger_offset(smp_processor_id());
828
829 /* Add the correct offset to expiration time */
830 hrtimer_add_expires_ns(&ts->sched_timer, offset);
831
785 for (;;) { 832 for (;;) {
786 hrtimer_forward(&ts->sched_timer, now, tick_period); 833 hrtimer_forward(&ts->sched_timer, now, tick_period);
787 hrtimer_start_expires(&ts->sched_timer, 834 hrtimer_start_expires(&ts->sched_timer,