1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#include <linux/cpu.h>
35#include <linux/export.h>
36#include <linux/percpu.h>
37#include <linux/hrtimer.h>
38#include <linux/notifier.h>
39#include <linux/syscalls.h>
40#include <linux/kallsyms.h>
41#include <linux/interrupt.h>
42#include <linux/tick.h>
43#include <linux/seq_file.h>
44#include <linux/err.h>
45#include <linux/debugobjects.h>
46#include <linux/sched.h>
47#include <linux/sched/sysctl.h>
48#include <linux/sched/rt.h>
49#include <linux/timer.h>
50#include <linux/freezer.h>
51
52#include <asm/uaccess.h>
53
54#include <trace/events/timer.h>
55
56
57
58
59
60
61
62
63
64DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
65{
66
67 .lock = __RAW_SPIN_LOCK_UNLOCKED(hrtimer_bases.lock),
68 .clock_base =
69 {
70 {
71 .index = HRTIMER_BASE_MONOTONIC,
72 .clockid = CLOCK_MONOTONIC,
73 .get_time = &ktime_get,
74 .resolution = KTIME_LOW_RES,
75 },
76 {
77 .index = HRTIMER_BASE_REALTIME,
78 .clockid = CLOCK_REALTIME,
79 .get_time = &ktime_get_real,
80 .resolution = KTIME_LOW_RES,
81 },
82 {
83 .index = HRTIMER_BASE_BOOTTIME,
84 .clockid = CLOCK_BOOTTIME,
85 .get_time = &ktime_get_boottime,
86 .resolution = KTIME_LOW_RES,
87 },
88 {
89 .index = HRTIMER_BASE_TAI,
90 .clockid = CLOCK_TAI,
91 .get_time = &ktime_get_clocktai,
92 .resolution = KTIME_LOW_RES,
93 },
94 }
95};
96
97static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = {
98 [CLOCK_REALTIME] = HRTIMER_BASE_REALTIME,
99 [CLOCK_MONOTONIC] = HRTIMER_BASE_MONOTONIC,
100 [CLOCK_BOOTTIME] = HRTIMER_BASE_BOOTTIME,
101 [CLOCK_TAI] = HRTIMER_BASE_TAI,
102};
103
104static inline int hrtimer_clockid_to_base(clockid_t clock_id)
105{
106 return hrtimer_clock_to_base_table[clock_id];
107}
108
109
110
111
112
113
114static void hrtimer_get_softirq_time(struct hrtimer_cpu_base *base)
115{
116 ktime_t xtim, mono, boot;
117 struct timespec xts, tom, slp;
118 s32 tai_offset;
119
120 get_xtime_and_monotonic_and_sleep_offset(&xts, &tom, &slp);
121 tai_offset = timekeeping_get_tai_offset();
122
123 xtim = timespec_to_ktime(xts);
124 mono = ktime_add(xtim, timespec_to_ktime(tom));
125 boot = ktime_add(mono, timespec_to_ktime(slp));
126 base->clock_base[HRTIMER_BASE_REALTIME].softirq_time = xtim;
127 base->clock_base[HRTIMER_BASE_MONOTONIC].softirq_time = mono;
128 base->clock_base[HRTIMER_BASE_BOOTTIME].softirq_time = boot;
129 base->clock_base[HRTIMER_BASE_TAI].softirq_time =
130 ktime_add(xtim, ktime_set(tai_offset, 0));
131}
132
133
134
135
136
137#ifdef CONFIG_SMP
138
139
140
141
142
143
144
145
146
147
148
149
150
151static
152struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
153 unsigned long *flags)
154{
155 struct hrtimer_clock_base *base;
156
157 for (;;) {
158 base = timer->base;
159 if (likely(base != NULL)) {
160 raw_spin_lock_irqsave(&base->cpu_base->lock, *flags);
161 if (likely(base == timer->base))
162 return base;
163
164 raw_spin_unlock_irqrestore(&base->cpu_base->lock, *flags);
165 }
166 cpu_relax();
167 }
168}
169
170
171
172
173
174static int hrtimer_get_target(int this_cpu, int pinned)
175{
176#ifdef CONFIG_NO_HZ_COMMON
177 if (!pinned && get_sysctl_timer_migration() && idle_cpu(this_cpu))
178 return get_nohz_timer_target();
179#endif
180 return this_cpu;
181}
182
183
184
185
186
187
188
189
190static int
191hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base)
192{
193#ifdef CONFIG_HIGH_RES_TIMERS
194 ktime_t expires;
195
196 if (!new_base->cpu_base->hres_active)
197 return 0;
198
199 expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset);
200 return expires.tv64 <= new_base->cpu_base->expires_next.tv64;
201#else
202 return 0;
203#endif
204}
205
206
207
208
209static inline struct hrtimer_clock_base *
210switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
211 int pinned)
212{
213 struct hrtimer_clock_base *new_base;
214 struct hrtimer_cpu_base *new_cpu_base;
215 int this_cpu = smp_processor_id();
216 int cpu = hrtimer_get_target(this_cpu, pinned);
217 int basenum = base->index;
218
219again:
220 new_cpu_base = &per_cpu(hrtimer_bases, cpu);
221 new_base = &new_cpu_base->clock_base[basenum];
222
223 if (base != new_base) {
224
225
226
227
228
229
230
231
232
233 if (unlikely(hrtimer_callback_running(timer)))
234 return base;
235
236
237 timer->base = NULL;
238 raw_spin_unlock(&base->cpu_base->lock);
239 raw_spin_lock(&new_base->cpu_base->lock);
240
241 if (cpu != this_cpu && hrtimer_check_target(timer, new_base)) {
242 cpu = this_cpu;
243 raw_spin_unlock(&new_base->cpu_base->lock);
244 raw_spin_lock(&base->cpu_base->lock);
245 timer->base = base;
246 goto again;
247 }
248 timer->base = new_base;
249 }
250 return new_base;
251}
252
253#else
254
255static inline struct hrtimer_clock_base *
256lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
257{
258 struct hrtimer_clock_base *base = timer->base;
259
260 raw_spin_lock_irqsave(&base->cpu_base->lock, *flags);
261
262 return base;
263}
264
265# define switch_hrtimer_base(t, b, p) (b)
266
267#endif
268
269
270
271
272
273#if BITS_PER_LONG < 64
274# ifndef CONFIG_KTIME_SCALAR
275
276
277
278
279
280
281
282ktime_t ktime_add_ns(const ktime_t kt, u64 nsec)
283{
284 ktime_t tmp;
285
286 if (likely(nsec < NSEC_PER_SEC)) {
287 tmp.tv64 = nsec;
288 } else {
289 unsigned long rem = do_div(nsec, NSEC_PER_SEC);
290
291
292 if (unlikely(nsec > KTIME_SEC_MAX))
293 return (ktime_t){ .tv64 = KTIME_MAX };
294
295 tmp = ktime_set((long)nsec, rem);
296 }
297
298 return ktime_add(kt, tmp);
299}
300
301EXPORT_SYMBOL_GPL(ktime_add_ns);
302
303
304
305
306
307
308
309
310ktime_t ktime_sub_ns(const ktime_t kt, u64 nsec)
311{
312 ktime_t tmp;
313
314 if (likely(nsec < NSEC_PER_SEC)) {
315 tmp.tv64 = nsec;
316 } else {
317 unsigned long rem = do_div(nsec, NSEC_PER_SEC);
318
319 tmp = ktime_set((long)nsec, rem);
320 }
321
322 return ktime_sub(kt, tmp);
323}
324
325EXPORT_SYMBOL_GPL(ktime_sub_ns);
326# endif
327
328
329
330
331u64 ktime_divns(const ktime_t kt, s64 div)
332{
333 u64 dclc;
334 int sft = 0;
335
336 dclc = ktime_to_ns(kt);
337
338 while (div >> 32) {
339 sft++;
340 div >>= 1;
341 }
342 dclc >>= sft;
343 do_div(dclc, (unsigned long) div);
344
345 return dclc;
346}
347#endif
348
349
350
351
352ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs)
353{
354 ktime_t res = ktime_add(lhs, rhs);
355
356
357
358
359
360 if (res.tv64 < 0 || res.tv64 < lhs.tv64 || res.tv64 < rhs.tv64)
361 res = ktime_set(KTIME_SEC_MAX, 0);
362
363 return res;
364}
365
366EXPORT_SYMBOL_GPL(ktime_add_safe);
367
368#ifdef CONFIG_DEBUG_OBJECTS_TIMERS
369
370static struct debug_obj_descr hrtimer_debug_descr;
371
372static void *hrtimer_debug_hint(void *addr)
373{
374 return ((struct hrtimer *) addr)->function;
375}
376
377
378
379
380
381static int hrtimer_fixup_init(void *addr, enum debug_obj_state state)
382{
383 struct hrtimer *timer = addr;
384
385 switch (state) {
386 case ODEBUG_STATE_ACTIVE:
387 hrtimer_cancel(timer);
388 debug_object_init(timer, &hrtimer_debug_descr);
389 return 1;
390 default:
391 return 0;
392 }
393}
394
395
396
397
398
399
400static int hrtimer_fixup_activate(void *addr, enum debug_obj_state state)
401{
402 switch (state) {
403
404 case ODEBUG_STATE_NOTAVAILABLE:
405 WARN_ON_ONCE(1);
406 return 0;
407
408 case ODEBUG_STATE_ACTIVE:
409 WARN_ON(1);
410
411 default:
412 return 0;
413 }
414}
415
416
417
418
419
420static int hrtimer_fixup_free(void *addr, enum debug_obj_state state)
421{
422 struct hrtimer *timer = addr;
423
424 switch (state) {
425 case ODEBUG_STATE_ACTIVE:
426 hrtimer_cancel(timer);
427 debug_object_free(timer, &hrtimer_debug_descr);
428 return 1;
429 default:
430 return 0;
431 }
432}
433
434static struct debug_obj_descr hrtimer_debug_descr = {
435 .name = "hrtimer",
436 .debug_hint = hrtimer_debug_hint,
437 .fixup_init = hrtimer_fixup_init,
438 .fixup_activate = hrtimer_fixup_activate,
439 .fixup_free = hrtimer_fixup_free,
440};
441
442static inline void debug_hrtimer_init(struct hrtimer *timer)
443{
444 debug_object_init(timer, &hrtimer_debug_descr);
445}
446
447static inline void debug_hrtimer_activate(struct hrtimer *timer)
448{
449 debug_object_activate(timer, &hrtimer_debug_descr);
450}
451
452static inline void debug_hrtimer_deactivate(struct hrtimer *timer)
453{
454 debug_object_deactivate(timer, &hrtimer_debug_descr);
455}
456
457static inline void debug_hrtimer_free(struct hrtimer *timer)
458{
459 debug_object_free(timer, &hrtimer_debug_descr);
460}
461
462static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
463 enum hrtimer_mode mode);
464
465void hrtimer_init_on_stack(struct hrtimer *timer, clockid_t clock_id,
466 enum hrtimer_mode mode)
467{
468 debug_object_init_on_stack(timer, &hrtimer_debug_descr);
469 __hrtimer_init(timer, clock_id, mode);
470}
471EXPORT_SYMBOL_GPL(hrtimer_init_on_stack);
472
473void destroy_hrtimer_on_stack(struct hrtimer *timer)
474{
475 debug_object_free(timer, &hrtimer_debug_descr);
476}
477
478#else
479static inline void debug_hrtimer_init(struct hrtimer *timer) { }
480static inline void debug_hrtimer_activate(struct hrtimer *timer) { }
481static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { }
482#endif
483
484static inline void
485debug_init(struct hrtimer *timer, clockid_t clockid,
486 enum hrtimer_mode mode)
487{
488 debug_hrtimer_init(timer);
489 trace_hrtimer_init(timer, clockid, mode);
490}
491
492static inline void debug_activate(struct hrtimer *timer)
493{
494 debug_hrtimer_activate(timer);
495 trace_hrtimer_start(timer);
496}
497
498static inline void debug_deactivate(struct hrtimer *timer)
499{
500 debug_hrtimer_deactivate(timer);
501 trace_hrtimer_cancel(timer);
502}
503
504
505#ifdef CONFIG_HIGH_RES_TIMERS
506
507
508
509
510static int hrtimer_hres_enabled __read_mostly = 1;
511
512
513
514
515static int __init setup_hrtimer_hres(char *str)
516{
517 if (!strcmp(str, "off"))
518 hrtimer_hres_enabled = 0;
519 else if (!strcmp(str, "on"))
520 hrtimer_hres_enabled = 1;
521 else
522 return 0;
523 return 1;
524}
525
526__setup("highres=", setup_hrtimer_hres);
527
528
529
530
531static inline int hrtimer_is_hres_enabled(void)
532{
533 return hrtimer_hres_enabled;
534}
535
536
537
538
539static inline int hrtimer_hres_active(void)
540{
541 return __this_cpu_read(hrtimer_bases.hres_active);
542}
543
544
545
546
547
548
549static void
550hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
551{
552 int i;
553 struct hrtimer_clock_base *base = cpu_base->clock_base;
554 ktime_t expires, expires_next;
555
556 expires_next.tv64 = KTIME_MAX;
557
558 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) {
559 struct hrtimer *timer;
560 struct timerqueue_node *next;
561
562 next = timerqueue_getnext(&base->active);
563 if (!next)
564 continue;
565 timer = container_of(next, struct hrtimer, node);
566
567 expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
568
569
570
571
572
573 if (expires.tv64 < 0)
574 expires.tv64 = 0;
575 if (expires.tv64 < expires_next.tv64)
576 expires_next = expires;
577 }
578
579 if (skip_equal && expires_next.tv64 == cpu_base->expires_next.tv64)
580 return;
581
582 cpu_base->expires_next.tv64 = expires_next.tv64;
583
584 if (cpu_base->expires_next.tv64 != KTIME_MAX)
585 tick_program_event(cpu_base->expires_next, 1);
586}
587
588
589
590
591
592
593
594
595
596
597static int hrtimer_reprogram(struct hrtimer *timer,
598 struct hrtimer_clock_base *base)
599{
600 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
601 ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
602 int res;
603
604 WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0);
605
606
607
608
609
610
611
612
613 if (hrtimer_callback_running(timer))
614 return 0;
615
616
617
618
619
620
621
622 if (expires.tv64 < 0)
623 return -ETIME;
624
625 if (expires.tv64 >= cpu_base->expires_next.tv64)
626 return 0;
627
628
629
630
631
632
633
634 if (cpu_base->hang_detected)
635 return 0;
636
637
638
639
640 res = tick_program_event(expires, 0);
641 if (!IS_ERR_VALUE(res))
642 cpu_base->expires_next = expires;
643 return res;
644}
645
646
647
648
649static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base)
650{
651 base->expires_next.tv64 = KTIME_MAX;
652 base->hres_active = 0;
653}
654
655
656
657
658
659
660
661static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
662 struct hrtimer_clock_base *base)
663{
664 return base->cpu_base->hres_active && hrtimer_reprogram(timer, base);
665}
666
667static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
668{
669 ktime_t *offs_real = &base->clock_base[HRTIMER_BASE_REALTIME].offset;
670 ktime_t *offs_boot = &base->clock_base[HRTIMER_BASE_BOOTTIME].offset;
671 ktime_t *offs_tai = &base->clock_base[HRTIMER_BASE_TAI].offset;
672
673 return ktime_get_update_offsets(offs_real, offs_boot, offs_tai);
674}
675
676
677
678
679
680
681static void retrigger_next_event(void *arg)
682{
683 struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases);
684
685 if (!hrtimer_hres_active())
686 return;
687
688 raw_spin_lock(&base->lock);
689 hrtimer_update_base(base);
690 hrtimer_force_reprogram(base, 0);
691 raw_spin_unlock(&base->lock);
692}
693
694
695
696
697static int hrtimer_switch_to_hres(void)
698{
699 int i, cpu = smp_processor_id();
700 struct hrtimer_cpu_base *base = &per_cpu(hrtimer_bases, cpu);
701 unsigned long flags;
702
703 if (base->hres_active)
704 return 1;
705
706 local_irq_save(flags);
707
708 if (tick_init_highres()) {
709 local_irq_restore(flags);
710 printk(KERN_WARNING "Could not switch to high resolution "
711 "mode on CPU %d\n", cpu);
712 return 0;
713 }
714 base->hres_active = 1;
715 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++)
716 base->clock_base[i].resolution = KTIME_HIGH_RES;
717
718 tick_setup_sched_timer();
719
720 retrigger_next_event(NULL);
721 local_irq_restore(flags);
722 return 1;
723}
724
725static void clock_was_set_work(struct work_struct *work)
726{
727 clock_was_set();
728}
729
730static DECLARE_WORK(hrtimer_work, clock_was_set_work);
731
732
733
734
735
736void clock_was_set_delayed(void)
737{
738 schedule_work(&hrtimer_work);
739}
740
741#else
742
743static inline int hrtimer_hres_active(void) { return 0; }
744static inline int hrtimer_is_hres_enabled(void) { return 0; }
745static inline int hrtimer_switch_to_hres(void) { return 0; }
746static inline void
747hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { }
748static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
749 struct hrtimer_clock_base *base)
750{
751 return 0;
752}
753static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base) { }
754static inline void retrigger_next_event(void *arg) { }
755
756#endif
757
758
759
760
761
762
763
764
765
766
767
768
769void clock_was_set(void)
770{
771#ifdef CONFIG_HIGH_RES_TIMERS
772
773 on_each_cpu(retrigger_next_event, NULL, 1);
774#endif
775 timerfd_clock_was_set();
776}
777
778
779
780
781
782
783
784void hrtimers_resume(void)
785{
786 WARN_ONCE(!irqs_disabled(),
787 KERN_INFO "hrtimers_resume() called with IRQs enabled!");
788
789
790 retrigger_next_event(NULL);
791
792 clock_was_set_delayed();
793}
794
795static inline void timer_stats_hrtimer_set_start_info(struct hrtimer *timer)
796{
797#ifdef CONFIG_TIMER_STATS
798 if (timer->start_site)
799 return;
800 timer->start_site = __builtin_return_address(0);
801 memcpy(timer->start_comm, current->comm, TASK_COMM_LEN);
802 timer->start_pid = current->pid;
803#endif
804}
805
806static inline void timer_stats_hrtimer_clear_start_info(struct hrtimer *timer)
807{
808#ifdef CONFIG_TIMER_STATS
809 timer->start_site = NULL;
810#endif
811}
812
813static inline void timer_stats_account_hrtimer(struct hrtimer *timer)
814{
815#ifdef CONFIG_TIMER_STATS
816 if (likely(!timer_stats_active))
817 return;
818 timer_stats_update_stats(timer, timer->start_pid, timer->start_site,
819 timer->function, timer->start_comm, 0);
820#endif
821}
822
823
824
825
826static inline
827void unlock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags)
828{
829 raw_spin_unlock_irqrestore(&timer->base->cpu_base->lock, *flags);
830}
831
832
833
834
835
836
837
838
839
840
841u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
842{
843 u64 orun = 1;
844 ktime_t delta;
845
846 delta = ktime_sub(now, hrtimer_get_expires(timer));
847
848 if (delta.tv64 < 0)
849 return 0;
850
851 if (interval.tv64 < timer->base->resolution.tv64)
852 interval.tv64 = timer->base->resolution.tv64;
853
854 if (unlikely(delta.tv64 >= interval.tv64)) {
855 s64 incr = ktime_to_ns(interval);
856
857 orun = ktime_divns(delta, incr);
858 hrtimer_add_expires_ns(timer, incr * orun);
859 if (hrtimer_get_expires_tv64(timer) > now.tv64)
860 return orun;
861
862
863
864
865 orun++;
866 }
867 hrtimer_add_expires(timer, interval);
868
869 return orun;
870}
871EXPORT_SYMBOL_GPL(hrtimer_forward);
872
873
874
875
876
877
878
879
880
881static int enqueue_hrtimer(struct hrtimer *timer,
882 struct hrtimer_clock_base *base)
883{
884 debug_activate(timer);
885
886 timerqueue_add(&base->active, &timer->node);
887 base->cpu_base->active_bases |= 1 << base->index;
888
889
890
891
892
893 timer->state |= HRTIMER_STATE_ENQUEUED;
894
895 return (&timer->node == base->active.next);
896}
897
898
899
900
901
902
903
904
905
906
907
908static void __remove_hrtimer(struct hrtimer *timer,
909 struct hrtimer_clock_base *base,
910 unsigned long newstate, int reprogram)
911{
912 struct timerqueue_node *next_timer;
913 if (!(timer->state & HRTIMER_STATE_ENQUEUED))
914 goto out;
915
916 next_timer = timerqueue_getnext(&base->active);
917 timerqueue_del(&base->active, &timer->node);
918 if (&timer->node == next_timer) {
919#ifdef CONFIG_HIGH_RES_TIMERS
920
921 if (reprogram && hrtimer_hres_active()) {
922 ktime_t expires;
923
924 expires = ktime_sub(hrtimer_get_expires(timer),
925 base->offset);
926 if (base->cpu_base->expires_next.tv64 == expires.tv64)
927 hrtimer_force_reprogram(base->cpu_base, 1);
928 }
929#endif
930 }
931 if (!timerqueue_getnext(&base->active))
932 base->cpu_base->active_bases &= ~(1 << base->index);
933out:
934 timer->state = newstate;
935}
936
937
938
939
940static inline int
941remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base)
942{
943 if (hrtimer_is_queued(timer)) {
944 unsigned long state;
945 int reprogram;
946
947
948
949
950
951
952
953
954
955 debug_deactivate(timer);
956 timer_stats_hrtimer_clear_start_info(timer);
957 reprogram = base->cpu_base == &__get_cpu_var(hrtimer_bases);
958
959
960
961
962
963 state = timer->state & HRTIMER_STATE_CALLBACK;
964 __remove_hrtimer(timer, base, state, reprogram);
965 return 1;
966 }
967 return 0;
968}
969
970int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
971 unsigned long delta_ns, const enum hrtimer_mode mode,
972 int wakeup)
973{
974 struct hrtimer_clock_base *base, *new_base;
975 unsigned long flags;
976 int ret, leftmost;
977
978 base = lock_hrtimer_base(timer, &flags);
979
980
981 ret = remove_hrtimer(timer, base);
982
983
984 new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED);
985
986 if (mode & HRTIMER_MODE_REL) {
987 tim = ktime_add_safe(tim, new_base->get_time());
988
989
990
991
992
993
994
995#ifdef CONFIG_TIME_LOW_RES
996 tim = ktime_add_safe(tim, base->resolution);
997#endif
998 }
999
1000 hrtimer_set_expires_range_ns(timer, tim, delta_ns);
1001
1002 timer_stats_hrtimer_set_start_info(timer);
1003
1004 leftmost = enqueue_hrtimer(timer, new_base);
1005
1006
1007
1008
1009
1010
1011
1012 if (leftmost && new_base->cpu_base == &__get_cpu_var(hrtimer_bases)
1013 && hrtimer_enqueue_reprogram(timer, new_base)) {
1014 if (wakeup) {
1015
1016
1017
1018
1019 raw_spin_unlock(&new_base->cpu_base->lock);
1020 raise_softirq_irqoff(HRTIMER_SOFTIRQ);
1021 local_irq_restore(flags);
1022 return ret;
1023 } else {
1024 __raise_softirq_irqoff(HRTIMER_SOFTIRQ);
1025 }
1026 }
1027
1028 unlock_hrtimer_base(timer, &flags);
1029
1030 return ret;
1031}
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045int hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
1046 unsigned long delta_ns, const enum hrtimer_mode mode)
1047{
1048 return __hrtimer_start_range_ns(timer, tim, delta_ns, mode, 1);
1049}
1050EXPORT_SYMBOL_GPL(hrtimer_start_range_ns);
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063int
1064hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
1065{
1066 return __hrtimer_start_range_ns(timer, tim, 0, mode, 1);
1067}
1068EXPORT_SYMBOL_GPL(hrtimer_start);
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081int hrtimer_try_to_cancel(struct hrtimer *timer)
1082{
1083 struct hrtimer_clock_base *base;
1084 unsigned long flags;
1085 int ret = -1;
1086
1087 base = lock_hrtimer_base(timer, &flags);
1088
1089 if (!hrtimer_callback_running(timer))
1090 ret = remove_hrtimer(timer, base);
1091
1092 unlock_hrtimer_base(timer, &flags);
1093
1094 return ret;
1095
1096}
1097EXPORT_SYMBOL_GPL(hrtimer_try_to_cancel);
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107int hrtimer_cancel(struct hrtimer *timer)
1108{
1109 for (;;) {
1110 int ret = hrtimer_try_to_cancel(timer);
1111
1112 if (ret >= 0)
1113 return ret;
1114 cpu_relax();
1115 }
1116}
1117EXPORT_SYMBOL_GPL(hrtimer_cancel);
1118
1119
1120
1121
1122
1123ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
1124{
1125 unsigned long flags;
1126 ktime_t rem;
1127
1128 lock_hrtimer_base(timer, &flags);
1129 rem = hrtimer_expires_remaining(timer);
1130 unlock_hrtimer_base(timer, &flags);
1131
1132 return rem;
1133}
1134EXPORT_SYMBOL_GPL(hrtimer_get_remaining);
1135
1136#ifdef CONFIG_NO_HZ_COMMON
1137
1138
1139
1140
1141
1142
1143ktime_t hrtimer_get_next_event(void)
1144{
1145 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
1146 struct hrtimer_clock_base *base = cpu_base->clock_base;
1147 ktime_t delta, mindelta = { .tv64 = KTIME_MAX };
1148 unsigned long flags;
1149 int i;
1150
1151 raw_spin_lock_irqsave(&cpu_base->lock, flags);
1152
1153 if (!hrtimer_hres_active()) {
1154 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++, base++) {
1155 struct hrtimer *timer;
1156 struct timerqueue_node *next;
1157
1158 next = timerqueue_getnext(&base->active);
1159 if (!next)
1160 continue;
1161
1162 timer = container_of(next, struct hrtimer, node);
1163 delta.tv64 = hrtimer_get_expires_tv64(timer);
1164 delta = ktime_sub(delta, base->get_time());
1165 if (delta.tv64 < mindelta.tv64)
1166 mindelta.tv64 = delta.tv64;
1167 }
1168 }
1169
1170 raw_spin_unlock_irqrestore(&cpu_base->lock, flags);
1171
1172 if (mindelta.tv64 < 0)
1173 mindelta.tv64 = 0;
1174 return mindelta;
1175}
1176#endif
1177
1178static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
1179 enum hrtimer_mode mode)
1180{
1181 struct hrtimer_cpu_base *cpu_base;
1182 int base;
1183
1184 memset(timer, 0, sizeof(struct hrtimer));
1185
1186 cpu_base = &__raw_get_cpu_var(hrtimer_bases);
1187
1188 if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS)
1189 clock_id = CLOCK_MONOTONIC;
1190
1191 base = hrtimer_clockid_to_base(clock_id);
1192 timer->base = &cpu_base->clock_base[base];
1193 timerqueue_init(&timer->node);
1194
1195#ifdef CONFIG_TIMER_STATS
1196 timer->start_site = NULL;
1197 timer->start_pid = -1;
1198 memset(timer->start_comm, 0, TASK_COMM_LEN);
1199#endif
1200}
1201
1202
1203
1204
1205
1206
1207
1208void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
1209 enum hrtimer_mode mode)
1210{
1211 debug_init(timer, clock_id, mode);
1212 __hrtimer_init(timer, clock_id, mode);
1213}
1214EXPORT_SYMBOL_GPL(hrtimer_init);
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224int hrtimer_get_res(const clockid_t which_clock, struct timespec *tp)
1225{
1226 struct hrtimer_cpu_base *cpu_base;
1227 int base = hrtimer_clockid_to_base(which_clock);
1228
1229 cpu_base = &__raw_get_cpu_var(hrtimer_bases);
1230 *tp = ktime_to_timespec(cpu_base->clock_base[base].resolution);
1231
1232 return 0;
1233}
1234EXPORT_SYMBOL_GPL(hrtimer_get_res);
1235
1236static void __run_hrtimer(struct hrtimer *timer, ktime_t *now)
1237{
1238 struct hrtimer_clock_base *base = timer->base;
1239 struct hrtimer_cpu_base *cpu_base = base->cpu_base;
1240 enum hrtimer_restart (*fn)(struct hrtimer *);
1241 int restart;
1242
1243 WARN_ON(!irqs_disabled());
1244
1245 debug_deactivate(timer);
1246 __remove_hrtimer(timer, base, HRTIMER_STATE_CALLBACK, 0);
1247 timer_stats_account_hrtimer(timer);
1248 fn = timer->function;
1249
1250
1251
1252
1253
1254
1255 raw_spin_unlock(&cpu_base->lock);
1256 trace_hrtimer_expire_entry(timer, now);
1257 restart = fn(timer);
1258 trace_hrtimer_expire_exit(timer);
1259 raw_spin_lock(&cpu_base->lock);
1260
1261
1262
1263
1264
1265
1266 if (restart != HRTIMER_NORESTART) {
1267 BUG_ON(timer->state != HRTIMER_STATE_CALLBACK);
1268 enqueue_hrtimer(timer, base);
1269 }
1270
1271 WARN_ON_ONCE(!(timer->state & HRTIMER_STATE_CALLBACK));
1272
1273 timer->state &= ~HRTIMER_STATE_CALLBACK;
1274}
1275
1276#ifdef CONFIG_HIGH_RES_TIMERS
1277
1278
1279
1280
1281
1282void hrtimer_interrupt(struct clock_event_device *dev)
1283{
1284 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
1285 ktime_t expires_next, now, entry_time, delta;
1286 int i, retries = 0;
1287
1288 BUG_ON(!cpu_base->hres_active);
1289 cpu_base->nr_events++;
1290 dev->next_event.tv64 = KTIME_MAX;
1291
1292 raw_spin_lock(&cpu_base->lock);
1293 entry_time = now = hrtimer_update_base(cpu_base);
1294retry:
1295 expires_next.tv64 = KTIME_MAX;
1296
1297
1298
1299
1300
1301
1302
1303 cpu_base->expires_next.tv64 = KTIME_MAX;
1304
1305 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
1306 struct hrtimer_clock_base *base;
1307 struct timerqueue_node *node;
1308 ktime_t basenow;
1309
1310 if (!(cpu_base->active_bases & (1 << i)))
1311 continue;
1312
1313 base = cpu_base->clock_base + i;
1314 basenow = ktime_add(now, base->offset);
1315
1316 while ((node = timerqueue_getnext(&base->active))) {
1317 struct hrtimer *timer;
1318
1319 timer = container_of(node, struct hrtimer, node);
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334 if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) {
1335 ktime_t expires;
1336
1337 expires = ktime_sub(hrtimer_get_expires(timer),
1338 base->offset);
1339 if (expires.tv64 < 0)
1340 expires.tv64 = KTIME_MAX;
1341 if (expires.tv64 < expires_next.tv64)
1342 expires_next = expires;
1343 break;
1344 }
1345
1346 __run_hrtimer(timer, &basenow);
1347 }
1348 }
1349
1350
1351
1352
1353
1354 cpu_base->expires_next = expires_next;
1355 raw_spin_unlock(&cpu_base->lock);
1356
1357
1358 if (expires_next.tv64 == KTIME_MAX ||
1359 !tick_program_event(expires_next, 0)) {
1360 cpu_base->hang_detected = 0;
1361 return;
1362 }
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377 raw_spin_lock(&cpu_base->lock);
1378 now = hrtimer_update_base(cpu_base);
1379 cpu_base->nr_retries++;
1380 if (++retries < 3)
1381 goto retry;
1382
1383
1384
1385
1386
1387
1388 cpu_base->nr_hangs++;
1389 cpu_base->hang_detected = 1;
1390 raw_spin_unlock(&cpu_base->lock);
1391 delta = ktime_sub(now, entry_time);
1392 if (delta.tv64 > cpu_base->max_hang_time.tv64)
1393 cpu_base->max_hang_time = delta;
1394
1395
1396
1397
1398 if (delta.tv64 > 100 * NSEC_PER_MSEC)
1399 expires_next = ktime_add_ns(now, 100 * NSEC_PER_MSEC);
1400 else
1401 expires_next = ktime_add(now, delta);
1402 tick_program_event(expires_next, 1);
1403 printk_once(KERN_WARNING "hrtimer: interrupt took %llu ns\n",
1404 ktime_to_ns(delta));
1405}
1406
1407
1408
1409
1410
1411static void __hrtimer_peek_ahead_timers(void)
1412{
1413 struct tick_device *td;
1414
1415 if (!hrtimer_hres_active())
1416 return;
1417
1418 td = &__get_cpu_var(tick_cpu_device);
1419 if (td && td->evtdev)
1420 hrtimer_interrupt(td->evtdev);
1421}
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432void hrtimer_peek_ahead_timers(void)
1433{
1434 unsigned long flags;
1435
1436 local_irq_save(flags);
1437 __hrtimer_peek_ahead_timers();
1438 local_irq_restore(flags);
1439}
1440
1441static void run_hrtimer_softirq(struct softirq_action *h)
1442{
1443 hrtimer_peek_ahead_timers();
1444}
1445
1446#else
1447
1448static inline void __hrtimer_peek_ahead_timers(void) { }
1449
1450#endif
1451
1452
1453
1454
1455
1456
1457
1458
1459void hrtimer_run_pending(void)
1460{
1461 if (hrtimer_hres_active())
1462 return;
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472 if (tick_check_oneshot_change(!hrtimer_is_hres_enabled()))
1473 hrtimer_switch_to_hres();
1474}
1475
1476
1477
1478
1479void hrtimer_run_queues(void)
1480{
1481 struct timerqueue_node *node;
1482 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
1483 struct hrtimer_clock_base *base;
1484 int index, gettime = 1;
1485
1486 if (hrtimer_hres_active())
1487 return;
1488
1489 for (index = 0; index < HRTIMER_MAX_CLOCK_BASES; index++) {
1490 base = &cpu_base->clock_base[index];
1491 if (!timerqueue_getnext(&base->active))
1492 continue;
1493
1494 if (gettime) {
1495 hrtimer_get_softirq_time(cpu_base);
1496 gettime = 0;
1497 }
1498
1499 raw_spin_lock(&cpu_base->lock);
1500
1501 while ((node = timerqueue_getnext(&base->active))) {
1502 struct hrtimer *timer;
1503
1504 timer = container_of(node, struct hrtimer, node);
1505 if (base->softirq_time.tv64 <=
1506 hrtimer_get_expires_tv64(timer))
1507 break;
1508
1509 __run_hrtimer(timer, &base->softirq_time);
1510 }
1511 raw_spin_unlock(&cpu_base->lock);
1512 }
1513}
1514
1515
1516
1517
1518static enum hrtimer_restart hrtimer_wakeup(struct hrtimer *timer)
1519{
1520 struct hrtimer_sleeper *t =
1521 container_of(timer, struct hrtimer_sleeper, timer);
1522 struct task_struct *task = t->task;
1523
1524 t->task = NULL;
1525 if (task)
1526 wake_up_process(task);
1527
1528 return HRTIMER_NORESTART;
1529}
1530
1531void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, struct task_struct *task)
1532{
1533 sl->timer.function = hrtimer_wakeup;
1534 sl->task = task;
1535}
1536EXPORT_SYMBOL_GPL(hrtimer_init_sleeper);
1537
1538static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode)
1539{
1540 hrtimer_init_sleeper(t, current);
1541
1542 do {
1543 set_current_state(TASK_INTERRUPTIBLE);
1544 hrtimer_start_expires(&t->timer, mode);
1545 if (!hrtimer_active(&t->timer))
1546 t->task = NULL;
1547
1548 if (likely(t->task))
1549 freezable_schedule();
1550
1551 hrtimer_cancel(&t->timer);
1552 mode = HRTIMER_MODE_ABS;
1553
1554 } while (t->task && !signal_pending(current));
1555
1556 __set_current_state(TASK_RUNNING);
1557
1558 return t->task == NULL;
1559}
1560
1561static int update_rmtp(struct hrtimer *timer, struct timespec __user *rmtp)
1562{
1563 struct timespec rmt;
1564 ktime_t rem;
1565
1566 rem = hrtimer_expires_remaining(timer);
1567 if (rem.tv64 <= 0)
1568 return 0;
1569 rmt = ktime_to_timespec(rem);
1570
1571 if (copy_to_user(rmtp, &rmt, sizeof(*rmtp)))
1572 return -EFAULT;
1573
1574 return 1;
1575}
1576
1577long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
1578{
1579 struct hrtimer_sleeper t;
1580 struct timespec __user *rmtp;
1581 int ret = 0;
1582
1583 hrtimer_init_on_stack(&t.timer, restart->nanosleep.clockid,
1584 HRTIMER_MODE_ABS);
1585 hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires);
1586
1587 if (do_nanosleep(&t, HRTIMER_MODE_ABS))
1588 goto out;
1589
1590 rmtp = restart->nanosleep.rmtp;
1591 if (rmtp) {
1592 ret = update_rmtp(&t.timer, rmtp);
1593 if (ret <= 0)
1594 goto out;
1595 }
1596
1597
1598 ret = -ERESTART_RESTARTBLOCK;
1599out:
1600 destroy_hrtimer_on_stack(&t.timer);
1601 return ret;
1602}
1603
1604long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
1605 const enum hrtimer_mode mode, const clockid_t clockid)
1606{
1607 struct restart_block *restart;
1608 struct hrtimer_sleeper t;
1609 int ret = 0;
1610 unsigned long slack;
1611
1612 slack = current->timer_slack_ns;
1613 if (rt_task(current))
1614 slack = 0;
1615
1616 hrtimer_init_on_stack(&t.timer, clockid, mode);
1617 hrtimer_set_expires_range_ns(&t.timer, timespec_to_ktime(*rqtp), slack);
1618 if (do_nanosleep(&t, mode))
1619 goto out;
1620
1621
1622 if (mode == HRTIMER_MODE_ABS) {
1623 ret = -ERESTARTNOHAND;
1624 goto out;
1625 }
1626
1627 if (rmtp) {
1628 ret = update_rmtp(&t.timer, rmtp);
1629 if (ret <= 0)
1630 goto out;
1631 }
1632
1633 restart = ¤t_thread_info()->restart_block;
1634 restart->fn = hrtimer_nanosleep_restart;
1635 restart->nanosleep.clockid = t.timer.base->clockid;
1636 restart->nanosleep.rmtp = rmtp;
1637 restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer);
1638
1639 ret = -ERESTART_RESTARTBLOCK;
1640out:
1641 destroy_hrtimer_on_stack(&t.timer);
1642 return ret;
1643}
1644
1645SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp,
1646 struct timespec __user *, rmtp)
1647{
1648 struct timespec tu;
1649
1650 if (copy_from_user(&tu, rqtp, sizeof(tu)))
1651 return -EFAULT;
1652
1653 if (!timespec_valid(&tu))
1654 return -EINVAL;
1655
1656 return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC);
1657}
1658
1659
1660
1661
1662static void init_hrtimers_cpu(int cpu)
1663{
1664 struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
1665 int i;
1666
1667 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
1668 cpu_base->clock_base[i].cpu_base = cpu_base;
1669 timerqueue_init_head(&cpu_base->clock_base[i].active);
1670 }
1671
1672 hrtimer_init_hres(cpu_base);
1673}
1674
1675#ifdef CONFIG_HOTPLUG_CPU
1676
1677static void migrate_hrtimer_list(struct hrtimer_clock_base *old_base,
1678 struct hrtimer_clock_base *new_base)
1679{
1680 struct hrtimer *timer;
1681 struct timerqueue_node *node;
1682
1683 while ((node = timerqueue_getnext(&old_base->active))) {
1684 timer = container_of(node, struct hrtimer, node);
1685 BUG_ON(hrtimer_callback_running(timer));
1686 debug_deactivate(timer);
1687
1688
1689
1690
1691
1692
1693 __remove_hrtimer(timer, old_base, HRTIMER_STATE_MIGRATE, 0);
1694 timer->base = new_base;
1695
1696
1697
1698
1699
1700
1701
1702
1703 enqueue_hrtimer(timer, new_base);
1704
1705
1706 timer->state &= ~HRTIMER_STATE_MIGRATE;
1707 }
1708}
1709
1710static void migrate_hrtimers(int scpu)
1711{
1712 struct hrtimer_cpu_base *old_base, *new_base;
1713 int i;
1714
1715 BUG_ON(cpu_online(scpu));
1716 tick_cancel_sched_timer(scpu);
1717
1718 local_irq_disable();
1719 old_base = &per_cpu(hrtimer_bases, scpu);
1720 new_base = &__get_cpu_var(hrtimer_bases);
1721
1722
1723
1724
1725 raw_spin_lock(&new_base->lock);
1726 raw_spin_lock_nested(&old_base->lock, SINGLE_DEPTH_NESTING);
1727
1728 for (i = 0; i < HRTIMER_MAX_CLOCK_BASES; i++) {
1729 migrate_hrtimer_list(&old_base->clock_base[i],
1730 &new_base->clock_base[i]);
1731 }
1732
1733 raw_spin_unlock(&old_base->lock);
1734 raw_spin_unlock(&new_base->lock);
1735
1736
1737 __hrtimer_peek_ahead_timers();
1738 local_irq_enable();
1739}
1740
1741#endif
1742
1743static int hrtimer_cpu_notify(struct notifier_block *self,
1744 unsigned long action, void *hcpu)
1745{
1746 int scpu = (long)hcpu;
1747
1748 switch (action) {
1749
1750 case CPU_UP_PREPARE:
1751 case CPU_UP_PREPARE_FROZEN:
1752 init_hrtimers_cpu(scpu);
1753 break;
1754
1755#ifdef CONFIG_HOTPLUG_CPU
1756 case CPU_DYING:
1757 case CPU_DYING_FROZEN:
1758 clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DYING, &scpu);
1759 break;
1760 case CPU_DEAD:
1761 case CPU_DEAD_FROZEN:
1762 {
1763 clockevents_notify(CLOCK_EVT_NOTIFY_CPU_DEAD, &scpu);
1764 migrate_hrtimers(scpu);
1765 break;
1766 }
1767#endif
1768
1769 default:
1770 break;
1771 }
1772
1773 return NOTIFY_OK;
1774}
1775
1776static struct notifier_block hrtimers_nb = {
1777 .notifier_call = hrtimer_cpu_notify,
1778};
1779
1780void __init hrtimers_init(void)
1781{
1782 hrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE,
1783 (void *)(long)smp_processor_id());
1784 register_cpu_notifier(&hrtimers_nb);
1785#ifdef CONFIG_HIGH_RES_TIMERS
1786 open_softirq(HRTIMER_SOFTIRQ, run_hrtimer_softirq);
1787#endif
1788}
1789
1790
1791
1792
1793
1794
1795
1796
1797int __sched
1798schedule_hrtimeout_range_clock(ktime_t *expires, unsigned long delta,
1799 const enum hrtimer_mode mode, int clock)
1800{
1801 struct hrtimer_sleeper t;
1802
1803
1804
1805
1806
1807 if (expires && !expires->tv64) {
1808 __set_current_state(TASK_RUNNING);
1809 return 0;
1810 }
1811
1812
1813
1814
1815 if (!expires) {
1816 schedule();
1817 __set_current_state(TASK_RUNNING);
1818 return -EINTR;
1819 }
1820
1821 hrtimer_init_on_stack(&t.timer, clock, mode);
1822 hrtimer_set_expires_range_ns(&t.timer, *expires, delta);
1823
1824 hrtimer_init_sleeper(&t, current);
1825
1826 hrtimer_start_expires(&t.timer, mode);
1827 if (!hrtimer_active(&t.timer))
1828 t.task = NULL;
1829
1830 if (likely(t.task))
1831 schedule();
1832
1833 hrtimer_cancel(&t.timer);
1834 destroy_hrtimer_on_stack(&t.timer);
1835
1836 __set_current_state(TASK_RUNNING);
1837
1838 return !t.task ? 0 : -EINTR;
1839}
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869int __sched schedule_hrtimeout_range(ktime_t *expires, unsigned long delta,
1870 const enum hrtimer_mode mode)
1871{
1872 return schedule_hrtimeout_range_clock(expires, delta, mode,
1873 CLOCK_MONOTONIC);
1874}
1875EXPORT_SYMBOL_GPL(schedule_hrtimeout_range);
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899int __sched schedule_hrtimeout(ktime_t *expires,
1900 const enum hrtimer_mode mode)
1901{
1902 return schedule_hrtimeout_range(expires, 0, mode);
1903}
1904EXPORT_SYMBOL_GPL(schedule_hrtimeout);
1905