linux/arch
Igor Mammedov df156f90a0 x86: Introduce x86_cpuinit.early_percpu_clock_init hook
When kvm guest uses kvmclock, it may hang on vcpu hot-plug.
This is caused by an overflow in pvclock_get_nsec_offset,

    u64 delta = tsc - shadow->tsc_timestamp;

which in turn is caused by an undefined values from percpu
hv_clock that hasn't been initialized yet.
Uninitialized clock on being booted cpu is accessed from
   start_secondary
    -> smp_callin
      ->  smp_store_cpu_info
        -> identify_secondary_cpu
          -> mtrr_ap_init
            -> mtrr_restore
              -> stop_machine_from_inactive_cpu
                -> queue_stop_cpus_work
                  ...
                    -> sched_clock
                      -> kvm_clock_read
which is well before x86_cpuinit.setup_percpu_clockev call in
start_secondary, where percpu clock is initialized.

This patch introduces a hook that allows to setup/initialize
per_cpu clock early and avoid overflow due to reading
  - undefined values
  - old values if cpu was offlined and then onlined again

Another possible early user of this clock source is ftrace that
accesses it to get timestamps for ring buffer entries. So if
mtrr_ap_init is moved from identify_secondary_cpu to past
x86_cpuinit.setup_percpu_clockev in start_secondary, ftrace
may cause the same overflow/hang on cpu hot-plug anyway.

More complete description of the problem:
  https://lkml.org/lkml/2012/2/2/101

Credits to Marcelo Tosatti <mtosatti@redhat.com> for hook idea.

Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2012-03-05 14:57:32 +02:00
..
alpha
arm IOMMU fixes for Linux 3.3-rc5 2012-02-28 09:15:31 -08:00
avr32
blackfin
c6x Kbuild: Use dtc's -d (dependency) option 2012-02-14 21:14:44 -05:00
cris
frv
h8300
hexagon
ia64 KVM: provide synchronous registers in kvm_run 2012-03-05 14:52:22 +02:00
m32r
m68k
microblaze
mips
mn10300
openrisc openrisc: Fix up audit_syscall_[entry|exit]() usage 2012-02-17 09:53:12 +01:00
parisc
powerpc KVM: PPC: Add HPT preallocator 2012-03-05 14:57:28 +02:00
s390 KVM: s390: provide access guest registers via kvm_run 2012-03-05 14:52:22 +02:00
score
sh SuperH fixes for 3.3-rc5 2012-02-24 08:56:51 -08:00
sparc
tile
um
unicore32
x86 x86: Introduce x86_cpuinit.early_percpu_clock_init hook 2012-03-05 14:57:32 +02:00
xtensa
.gitignore
Kconfig