diff options
| -rw-r--r-- | include/litmus/litmus.h | 3 | ||||
| -rw-r--r-- | kernel/time/tick-sched.c | 35 |
2 files changed, 24 insertions, 14 deletions
diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index b565b65712..7ef5a62d67 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h | |||
| @@ -221,4 +221,7 @@ static inline quanta_t time2quanta(lt_t time, enum round round) | |||
| 221 | return (quanta_t) time; | 221 | return (quanta_t) time; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | /* By how much is cpu staggered behind CPU 0? */ | ||
| 225 | u64 cpu_stagger_offset(int cpu); | ||
| 226 | |||
| 224 | #endif | 227 | #endif |
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 3b1936fac0..d6dad226a1 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c | |||
| @@ -583,6 +583,26 @@ static int __init tick_set_quanta_type(char *str) | |||
| 583 | } | 583 | } |
| 584 | __setup("quanta=", tick_set_quanta_type); | 584 | __setup("quanta=", tick_set_quanta_type); |
| 585 | 585 | ||
| 586 | u64 cpu_stagger_offset(int cpu) | ||
| 587 | { | ||
| 588 | u64 offset = 0; | ||
| 589 | switch (quanta_type) { | ||
| 590 | case LITMUS_ALIGNED_TICKS: | ||
| 591 | offset = 0; | ||
| 592 | break; | ||
| 593 | case LITMUS_STAGGERED_TICKS: | ||
| 594 | offset = ktime_to_ns(tick_period); | ||
| 595 | do_div(offset, num_possible_cpus()); | ||
| 596 | offset *= cpu; | ||
| 597 | break; | ||
| 598 | default: | ||
| 599 | offset = ktime_to_ns(tick_period) >> 1; | ||
| 600 | do_div(offset, num_possible_cpus()); | ||
| 601 | offset *= cpu; | ||
| 602 | } | ||
| 603 | return offset; | ||
| 604 | } | ||
| 605 | |||
| 586 | /** | 606 | /** |
| 587 | * tick_setup_sched_timer - setup the tick emulation timer | 607 | * tick_setup_sched_timer - setup the tick emulation timer |
| 588 | */ | 608 | */ |
| @@ -603,20 +623,7 @@ void tick_setup_sched_timer(void) | |||
| 603 | ts->sched_timer.expires = tick_init_jiffy_update(); | 623 | ts->sched_timer.expires = tick_init_jiffy_update(); |
| 604 | 624 | ||
| 605 | /* Offset must be set correctly to achieve desired quanta type. */ | 625 | /* Offset must be set correctly to achieve desired quanta type. */ |
| 606 | switch (quanta_type) { | 626 | offset = cpu_stagger_offset(smp_processor_id()); |
| 607 | case LITMUS_ALIGNED_TICKS: | ||
| 608 | offset = 0; | ||
| 609 | break; | ||
| 610 | case LITMUS_STAGGERED_TICKS: | ||
| 611 | offset = ktime_to_ns(tick_period); | ||
| 612 | do_div(offset, num_possible_cpus()); | ||
| 613 | offset *= smp_processor_id(); | ||
| 614 | break; | ||
| 615 | default: | ||
| 616 | offset = ktime_to_ns(tick_period) >> 1; | ||
| 617 | do_div(offset, num_possible_cpus()); | ||
| 618 | offset *= smp_processor_id(); | ||
| 619 | } | ||
| 620 | 627 | ||
| 621 | /* Add correct offset to expiration time. */ | 628 | /* Add correct offset to expiration time. */ |
| 622 | ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset); | 629 | ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset); |
