aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/hrtimer.h1
-rw-r--r--include/linux/time.h1
-rw-r--r--kernel/hrtimer.c16
3 files changed, 14 insertions, 4 deletions
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 7a9e7ee0f35c..6bc1804bfbfa 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -151,6 +151,7 @@ struct hrtimer_clock_base {
151enum hrtimer_base_type { 151enum hrtimer_base_type {
152 HRTIMER_BASE_REALTIME, 152 HRTIMER_BASE_REALTIME,
153 HRTIMER_BASE_MONOTONIC, 153 HRTIMER_BASE_MONOTONIC,
154 HRTIMER_BASE_BOOTTIME,
154 HRTIMER_MAX_CLOCK_BASES, 155 HRTIMER_MAX_CLOCK_BASES,
155}; 156};
156 157
diff --git a/include/linux/time.h b/include/linux/time.h
index 02d48fb30b41..454a26205787 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -293,6 +293,7 @@ struct itimerval {
293#define CLOCK_MONOTONIC_RAW 4 293#define CLOCK_MONOTONIC_RAW 4
294#define CLOCK_REALTIME_COARSE 5 294#define CLOCK_REALTIME_COARSE 5
295#define CLOCK_MONOTONIC_COARSE 6 295#define CLOCK_MONOTONIC_COARSE 6
296#define CLOCK_BOOTTIME 7
296 297
297/* 298/*
298 * The IDs of various hardware clocks: 299 * The IDs of various hardware clocks:
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index e8bf3ad99063..4c53af18734b 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -73,6 +73,11 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
73 .get_time = &ktime_get, 73 .get_time = &ktime_get,
74 .resolution = KTIME_LOW_RES, 74 .resolution = KTIME_LOW_RES,
75 }, 75 },
76 {
77 .index = CLOCK_BOOTTIME,
78 .get_time = &ktime_get_boottime,
79 .resolution = KTIME_LOW_RES,
80 },
76 } 81 }
77}; 82};
78 83
@@ -90,16 +95,17 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
90 */ 95 */
91static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base) 96static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
92{ 97{
93 ktime_t xtim, tomono; 98 ktime_t xtim, mono, boot;
94 struct timespec xts, tom, slp; 99 struct timespec xts, tom, slp;
95 100
96 get_xtime_and_monotonic_and_sleep_offset(&xts, &tom, &slp); 101 get_xtime_and_monotonic_and_sleep_offset(&xts, &tom, &slp);
97 102
98 xtim = timespec_to_ktime(xts); 103 xtim = timespec_to_ktime(xts);
99 tomono = timespec_to_ktime(tom); 104 mono = ktime_add(xtim, timespec_to_ktime(tom));
105 boot = ktime_add(mono, timespec_to_ktime(slp));
100 base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim; 106 base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim;
101 base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = 107 base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = mono;
102 ktime_add(xtim, tomono); 108 base->clock_base[HRTIMER_BASE_BOOTTIME].softirq_time = boot;
103} 109}
104 110
105/* 111/*
@@ -727,6 +733,7 @@ static int hrtimer_switch_to_hres(void)
727 base->hres_active = 1; 733 base->hres_active = 1;
728 base->clock_base[HRTIMER_BASE_REALTIME].resolution = KTIME_HIGH_RES; 734 base->clock_base[HRTIMER_BASE_REALTIME].resolution = KTIME_HIGH_RES;
729 base->clock_base[HRTIMER_BASE_MONOTONIC].resolution = KTIME_HIGH_RES; 735 base->clock_base[HRTIMER_BASE_MONOTONIC].resolution = KTIME_HIGH_RES;
736 base->clock_base[HRTIMER_BASE_BOOTTIME].resolution = KTIME_HIGH_RES;
730 737
731 tick_setup_sched_timer(); 738 tick_setup_sched_timer();
732 739
@@ -1719,6 +1726,7 @@ void __init hrtimers_init(void)
1719{ 1726{
1720 hrtimer_clock_to_base_table[CLOCK_REALTIME] = HRTIMER_BASE_REALTIME; 1727 hrtimer_clock_to_base_table[CLOCK_REALTIME] = HRTIMER_BASE_REALTIME;
1721 hrtimer_clock_to_base_table[CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC; 1728 hrtimer_clock_to_base_table[CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC;
1729 hrtimer_clock_to_base_table[CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME;
1722 1730
1723 hrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE, 1731 hrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE,
1724 (void *)(long)smp_processor_id()); 1732 (void *)(long)smp_processor_id());