aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/time
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/timekeeping.c5
-rw-r--r--kernel/time/timekeeping_debug.c9
-rw-r--r--kernel/time/timer.c5
3 files changed, 15 insertions, 4 deletions
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 3b65746c7f15..e07fb093f819 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -401,7 +401,10 @@ static __always_inline u64 __ktime_get_fast_ns(struct tk_fast *tkf)
401 do { 401 do {
402 seq = raw_read_seqcount_latch(&tkf->seq); 402 seq = raw_read_seqcount_latch(&tkf->seq);
403 tkr = tkf->base + (seq & 0x01); 403 tkr = tkf->base + (seq & 0x01);
404 now = ktime_to_ns(tkr->base) + timekeeping_get_ns(tkr); 404 now = ktime_to_ns(tkr->base);
405
406 now += clocksource_delta(tkr->read(tkr->clock),
407 tkr->cycle_last, tkr->mask);
405 } while (read_seqcount_retry(&tkf->seq, seq)); 408 } while (read_seqcount_retry(&tkf->seq, seq));
406 409
407 return now; 410 return now;
diff --git a/kernel/time/timekeeping_debug.c b/kernel/time/timekeeping_debug.c
index f6bd65236712..107310a6f36f 100644
--- a/kernel/time/timekeeping_debug.c
+++ b/kernel/time/timekeeping_debug.c
@@ -23,7 +23,9 @@
23 23
24#include "timekeeping_internal.h" 24#include "timekeeping_internal.h"
25 25
26static unsigned int sleep_time_bin[32] = {0}; 26#define NUM_BINS 32
27
28static unsigned int sleep_time_bin[NUM_BINS] = {0};
27 29
28static int tk_debug_show_sleep_time(struct seq_file *s, void *data) 30static int tk_debug_show_sleep_time(struct seq_file *s, void *data)
29{ 31{
@@ -69,6 +71,9 @@ late_initcall(tk_debug_sleep_time_init);
69 71
70void tk_debug_account_sleep_time(struct timespec64 *t) 72void tk_debug_account_sleep_time(struct timespec64 *t)
71{ 73{
72 sleep_time_bin[fls(t->tv_sec)]++; 74 /* Cap bin index so we don't overflow the array */
75 int bin = min(fls(t->tv_sec), NUM_BINS-1);
76
77 sleep_time_bin[bin]++;
73} 78}
74 79
diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 555670a5143c..32bf6f75a8fe 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1496,6 +1496,7 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
1496 struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]); 1496 struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
1497 u64 expires = KTIME_MAX; 1497 u64 expires = KTIME_MAX;
1498 unsigned long nextevt; 1498 unsigned long nextevt;
1499 bool is_max_delta;
1499 1500
1500 /* 1501 /*
1501 * Pretend that there is no timer pending if the cpu is offline. 1502 * Pretend that there is no timer pending if the cpu is offline.
@@ -1506,6 +1507,7 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
1506 1507
1507 spin_lock(&base->lock); 1508 spin_lock(&base->lock);
1508 nextevt = __next_timer_interrupt(base); 1509 nextevt = __next_timer_interrupt(base);
1510 is_max_delta = (nextevt == base->clk + NEXT_TIMER_MAX_DELTA);
1509 base->next_expiry = nextevt; 1511 base->next_expiry = nextevt;
1510 /* 1512 /*
1511 * We have a fresh next event. Check whether we can forward the base: 1513 * We have a fresh next event. Check whether we can forward the base:
@@ -1519,7 +1521,8 @@ u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
1519 expires = basem; 1521 expires = basem;
1520 base->is_idle = false; 1522 base->is_idle = false;
1521 } else { 1523 } else {
1522 expires = basem + (nextevt - basej) * TICK_NSEC; 1524 if (!is_max_delta)
1525 expires = basem + (nextevt - basej) * TICK_NSEC;
1523 /* 1526 /*
1524 * If we expect to sleep more than a tick, mark the base idle: 1527 * If we expect to sleep more than a tick, mark the base idle:
1525 */ 1528 */