diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-04-19 17:31:52 -0400 |
commit | f70a290e8a889caa905ab7650c696f2bb299be1a (patch) | |
tree | 56f0886d839499e9f522f189999024b3e86f9be2 /kernel/time/tick-sched.c | |
parent | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (diff) | |
parent | 7ef4a793a624c6e66c16ca1051847f75161f5bec (diff) |
Merge branch 'wip-nested-locking' into tegra-nested-lockingwip-nested-locking
Conflicts:
Makefile
include/linux/fs.h
Diffstat (limited to 'kernel/time/tick-sched.c')
-rw-r--r-- | kernel/time/tick-sched.c | 47 |
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 | */ | ||
773 | int quanta_type = LINUX_DEFAULT_TICKS; | ||
774 | static 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 | |||
788 | u64 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 | */ |
771 | void tick_setup_sched_timer(void) | 811 | void 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, |