aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/hrtimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/hrtimer.c')
-rw-r--r--kernel/hrtimer.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 72206cf5c6cf..cb49883b64e5 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -46,6 +46,8 @@
46#include <linux/sched.h> 46#include <linux/sched.h>
47#include <linux/timer.h> 47#include <linux/timer.h>
48 48
49#include <litmus/litmus.h>
50
49#include <asm/uaccess.h> 51#include <asm/uaccess.h>
50 52
51#include <trace/events/timer.h> 53#include <trace/events/timer.h>
@@ -1042,6 +1044,98 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
1042} 1044}
1043EXPORT_SYMBOL_GPL(hrtimer_start); 1045EXPORT_SYMBOL_GPL(hrtimer_start);
1044 1046
1047#ifdef CONFIG_ARCH_HAS_SEND_PULL_TIMERS
1048
1049/**
1050 * hrtimer_start_on_info_init - Initialize hrtimer_start_on_info
1051 */
1052void hrtimer_start_on_info_init(struct hrtimer_start_on_info *info)
1053{
1054 memset(info, 0, sizeof(struct hrtimer_start_on_info));
1055 atomic_set(&info->state, HRTIMER_START_ON_INACTIVE);
1056}
1057
1058/**
1059 * hrtimer_pull - PULL_TIMERS_VECTOR callback on remote cpu
1060 */
1061void hrtimer_pull(void)
1062{
1063 struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases);
1064 struct hrtimer_start_on_info *info;
1065 struct list_head *pos, *safe, list;
1066
1067 raw_spin_lock(&base->lock);
1068 list_replace_init(&base->to_pull, &list);
1069 raw_spin_unlock(&base->lock);
1070
1071 list_for_each_safe(pos, safe, &list) {
1072 info = list_entry(pos, struct hrtimer_start_on_info, list);
1073 TRACE("pulled timer 0x%x\n", info->timer);
1074 list_del(pos);
1075 hrtimer_start(info->timer, info->time, info->mode);
1076 }
1077}
1078
1079/**
1080 * hrtimer_start_on - trigger timer arming on remote cpu
1081 * @cpu: remote cpu
1082 * @info: save timer information for enqueuing on remote cpu
1083 * @timer: timer to be pulled
1084 * @time: expire time
1085 * @mode: timer mode
1086 */
1087int hrtimer_start_on(int cpu, struct hrtimer_start_on_info* info,
1088 struct hrtimer *timer, ktime_t time,
1089 const enum hrtimer_mode mode)
1090{
1091 unsigned long flags;
1092 struct hrtimer_cpu_base* base;
1093 int in_use = 0, was_empty;
1094
1095 /* serialize access to info through the timer base */
1096 lock_hrtimer_base(timer, &flags);
1097
1098 in_use = (atomic_read(&info->state) != HRTIMER_START_ON_INACTIVE);
1099 if (!in_use) {
1100 INIT_LIST_HEAD(&info->list);
1101 info->timer = timer;
1102 info->time = time;
1103 info->mode = mode;
1104 /* mark as in use */
1105 atomic_set(&info->state, HRTIMER_START_ON_QUEUED);
1106 }
1107
1108 unlock_hrtimer_base(timer, &flags);
1109
1110 if (!in_use) {
1111 /* initiate pull */
1112 preempt_disable();
1113 if (cpu == smp_processor_id()) {
1114 /* start timer locally; we may get called
1115 * with rq->lock held, do not wake up anything
1116 */
1117 TRACE("hrtimer_start_on: starting on local CPU\n");
1118 __hrtimer_start_range_ns(info->timer, info->time,
1119 0, info->mode, 0);
1120 } else {
1121 TRACE("hrtimer_start_on: pulling to remote CPU\n");
1122 base = &per_cpu(hrtimer_bases, cpu);
1123 raw_spin_lock_irqsave(&base->lock, flags);
1124 was_empty = list_empty(&base->to_pull);
1125 list_add(&info->list, &base->to_pull);
1126 raw_spin_unlock_irqrestore(&base->lock, flags);
1127 if (was_empty)
1128 /* only send IPI if other no else
1129 * has done so already
1130 */
1131 smp_send_pull_timers(cpu);
1132 }
1133 preempt_enable();
1134 }
1135 return in_use;
1136}
1137
1138#endif
1045 1139
1046/** 1140/**
1047 * hrtimer_try_to_cancel - try to deactivate a timer 1141 * hrtimer_try_to_cancel - try to deactivate a timer
@@ -1634,6 +1728,7 @@ static void __cpuinit init_hrtimers_cpu(int cpu)
1634 cpu_base->clock_base[i].cpu_base = cpu_base; 1728 cpu_base->clock_base[i].cpu_base = cpu_base;
1635 1729
1636 hrtimer_init_hres(cpu_base); 1730 hrtimer_init_hres(cpu_base);
1731 INIT_LIST_HEAD(&cpu_base->to_pull);
1637} 1732}
1638 1733
1639#ifdef CONFIG_HOTPLUG_CPU 1734#ifdef CONFIG_HOTPLUG_CPU