/* Xen sched_clock implementation. Returns the number of unstolen nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED states.  */
unsigned long long xen_sched_clock(void)
/* Xen sched_clock implementation. Returns the number of unstolen nanoseconds, which is nanoseconds the VCPU spent in RUNNING+BLOCKED states.  */
unsigned long long xen_sched_clock(void)
{
	struct vcpu_runstate_info state;
	cycle_t now;
	u64 ret;
	s64 offset;
	preempt_disable();
	now = xen_clocksource_read();
	get_runstate_snapshot(&state);
	WARN_ON(state.state != RUNSTATE_running);
	offset = now - state.state_entry_time;
	if (offset < 0)
		offset = 0;
	ret = state.time[RUNSTATE_blocked] +
		state.time[RUNSTATE_running] +
		offset;
	preempt_enable();
	return ret;
}