aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/xen/time.c
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy@xensource.com>2007-07-17 18:37:06 -0700
committerJeremy Fitzhardinge <jeremy@goop.org>2007-07-18 08:47:44 -0700
commitf120f13ea0dbb0b0d6675683d5f6faea71277e65 (patch)
tree6b525ab73bedfa78e43dee303ac991099377e9c5 /arch/i386/xen/time.c
parentxen: SMP guest support (diff)
downloadlinux-dev-f120f13ea0dbb0b0d6675683d5f6faea71277e65.tar.xz
linux-dev-f120f13ea0dbb0b0d6675683d5f6faea71277e65.zip
xen: Add support for preemption
Add Xen support for preemption. This is mostly a cleanup of existing preempt_enable/disable calls, or just comments to explain the current usage. Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com> Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Diffstat (limited to '')
-rw-r--r--arch/i386/xen/time.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/arch/i386/xen/time.c b/arch/i386/xen/time.c
index aeb04cf5dbf1..51fdabf1fd4d 100644
--- a/arch/i386/xen/time.c
+++ b/arch/i386/xen/time.c
@@ -88,7 +88,7 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
u64 state_time;
struct vcpu_runstate_info *state;
- preempt_disable();
+ BUG_ON(preemptible());
state = &__get_cpu_var(runstate);
@@ -103,8 +103,6 @@ static void get_runstate_snapshot(struct vcpu_runstate_info *res)
*res = *state;
barrier();
} while (get64(&state->state_entry_time) != state_time);
-
- preempt_enable();
}
static void setup_runstate_info(int cpu)
@@ -179,9 +177,19 @@ static void do_stolen_accounting(void)
unsigned long long xen_sched_clock(void)
{
struct vcpu_runstate_info state;
- cycle_t now = xen_clocksource_read();
+ 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);
@@ -190,9 +198,13 @@ unsigned long long xen_sched_clock(void)
if (offset < 0)
offset = 0;
- return state.time[RUNSTATE_blocked] +
+ ret = state.time[RUNSTATE_blocked] +
state.time[RUNSTATE_running] +
offset;
+
+ preempt_enable();
+
+ return ret;
}