Skip to content

Commit

Permalink
xen: drop xen_sched_clock in favour of using plain wallclock time
Browse files Browse the repository at this point in the history
xen_sched_clock only counts unstolen time.  In principle this should
be useful to the Linux scheduler so that it knows how much time a process
actually consumed.  But in practice this doesn't work very well as the
scheduler expects the sched_clock time to be synchronized between
cpus.  It also uses sched_clock to measure the time a task spends
sleeping, in which case "unstolen time" isn't meaningful.

So just use plain xen_clocksource_read to return wallclock nanoseconds
for sched_clock.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
  • Loading branch information
Jeremy Fitzhardinge committed Aug 4, 2010
1 parent 31de189 commit 8a22b99
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
2 changes: 1 addition & 1 deletion arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ static const struct pv_init_ops xen_init_ops __initdata = {
};

static const struct pv_time_ops xen_time_ops __initdata = {
.sched_clock = xen_sched_clock,
.sched_clock = xen_clocksource_read,
};

static const struct pv_cpu_ops xen_cpu_ops __initdata = {
Expand Down
39 changes: 0 additions & 39 deletions arch/x86/xen/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,45 +155,6 @@ static void do_stolen_accounting(void)
account_idle_ticks(ticks);
}

/*
* 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;

/*
* Ideally sched_clock should be called on a per-cpu basis
* anyway, so preempt should already be disabled, but that's
* not current practice at the moment.
*/
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;
}


/* Get the TSC speed from Xen */
unsigned long xen_tsc_khz(void)
{
Expand Down

0 comments on commit 8a22b99

Please sign in to comment.