29 #include <asm/timex.h>
31 #include <asm/xen/hypervisor.h>
35 #include "../kernel/fsyscall_gtod_data.h"
42 static void xen_init_missing_ticks_accounting(
int cpu)
48 memset(runstate, 0,
sizeof(*runstate));
50 area.addr.v = runstate;
86 #define NS_PER_TICK (1000000000LL/HZ)
89 consider_steal_time(
unsigned long new_itm)
91 unsigned long stolen, blocked;
92 unsigned long delta_itm = 0, stolentick = 0;
97 get_runstate_snapshot(&runstate);
106 per_cpu(xen_blocked_time, cpu)))
111 per_cpu(xen_stolen_time, cpu)))
114 if (!
time_after(delta_itm + new_itm, ia64_get_itc()))
115 stolentick = ia64_get_itc() - new_itm;
122 if (stolen > stolentick)
125 stolentick -= stolen;
128 if (blocked > stolentick)
129 blocked = stolentick;
131 if (stolen > 0 || blocked > 0) {
153 static int xen_do_steal_accounting(
unsigned long *new_itm)
155 unsigned long delta_itm;
156 delta_itm = consider_steal_time(*new_itm);
157 *new_itm += delta_itm;
158 if (
time_after(*new_itm, ia64_get_itc()) && delta_itm)
164 static void xen_itc_jitter_data_reset(
void)
184 static unsigned long long xen_sched_clock(
void)
188 unsigned long long now;
189 unsigned long long offset;
190 unsigned long long ret;
205 get_runstate_snapshot(&runstate);
222 .init_missing_ticks_accounting = xen_init_missing_ticks_accounting,
223 .do_steal_accounting = xen_do_steal_accounting,
224 .clocksource_resume = xen_itc_jitter_data_reset,
225 .sched_clock = xen_sched_clock,
229 static void xen_local_tick_resume(
void)
241 xen_local_tick_resume();
244 xen_init_missing_ticks_accounting(cpu);
247 static void ia64_cpu_local_tick_fn(
void *
unused)
249 xen_local_tick_resume();