Skip to content

Commit

Permalink
KVM guest: prevent tracing recursion with kvmclock
Browse files Browse the repository at this point in the history
Prevent tracing of preempt_disable() in get_cpu_var() in
kvm_clock_read(). When CONFIG_DEBUG_PREEMPT is enabled,
preempt_disable/enable() are traced and this causes the function_graph
tracer to go into an infinite recursion. By open coding the
preempt_disable() around the get_cpu_var(), we can use the notrace
version which prevents preempt_disable/enable() from being traced and
prevents the recursion.

Based on a similar patch for Xen from Jeremy Fitzhardinge.

Tested-by: Gleb Natapov <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>
  • Loading branch information
avikivity committed Nov 20, 2011
1 parent bb75c62 commit 95ef1e5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/x86/kernel/kvmclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ static cycle_t kvm_clock_read(void)
struct pvclock_vcpu_time_info *src;
cycle_t ret;

src = &get_cpu_var(hv_clock);
preempt_disable_notrace();
src = &__get_cpu_var(hv_clock);
ret = pvclock_clocksource_read(src);
put_cpu_var(hv_clock);
preempt_enable_notrace();
return ret;
}

Expand Down

0 comments on commit 95ef1e5

Please sign in to comment.