diff options
Diffstat (limited to 'kernel/time/timekeeping_debug.c')
-rw-r--r-- | kernel/time/timekeeping_debug.c | 9 |
1 files changed, 7 insertions, 2 deletions
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 | ||
26 | static unsigned int sleep_time_bin[32] = {0}; | 26 | #define NUM_BINS 32 |
27 | |||
28 | static unsigned int sleep_time_bin[NUM_BINS] = {0}; | ||
27 | 29 | ||
28 | static int tk_debug_show_sleep_time(struct seq_file *s, void *data) | 30 | static 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 | ||
70 | void tk_debug_account_sleep_time(struct timespec64 *t) | 72 | void 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 | ||