Inform TSC deadline clockevent device about recalibration 43/23643/1
authorYunhong Jiang <yunhong.jiang@linux.intel.com>
Sat, 22 Oct 2016 00:38:29 +0000 (17:38 -0700)
committerYunhong Jiang <yunhong.jiang@linux.intel.com>
Tue, 25 Oct 2016 01:20:43 +0000 (18:20 -0700)
commitab1366e1b48fa0b56752a3b56e7456c3c7ecb011
tree46a4520d0a8579a431ccb4f78985e8f471d35195
parent540333b9f4ebaaf2362437da2990f3c63ac4f2e8
Inform TSC deadline clockevent device about recalibration

This patch, together with previous TSC calculation patch,
fixes duplicate timer interrupt on the guest.

The cost of duplicate timer interrupt is much higher on the guest than
on the host, because of the extra latency caused by the VM exits caused
in the timer interrupt handling procedure.

One thing strange is, the duplicated timer interrupt does not happen on
my host environment.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
Backport-by: Yunhong Jiang <yunhong.jiang@intel.com>
Upstream status: Backport

Change the sign off to the below special character to avoid spam to the
original author. And removed the CC/ack list.

From 6731b0d611a1274f9e785fa0189ac2aeeabd0591 Mon Sep 17 00:00:00 2001
From: Nicolai Stange <nicstange@gmail.com>
Date: Thu, 14 Jul 2016 17:22:55 +0200
Subject: [PATCH] x86/timers/apic: Inform TSC deadline clockevent device about
 recalibration

This patch eliminates a source of imprecise APIC timer interrupts,
which imprecision may result in double interrupts or even late
interrupts.

The TSC deadline clockevent devices' configuration and registration
happens before the TSC frequency calibration is refined in
tsc_refine_calibration_work().

This results in the TSC clocksource and the TSC deadline clockevent
devices being configured with slightly different frequencies: the former
gets the refined one and the latter are configured with the inaccurate
frequency detected earlier by means of the "Fast TSC calibration using PIT".

Within the APIC code, introduce the notifier function
lapic_update_tsc_freq() which reconfigures all per-CPU TSC deadline
clockevent devices with the current tsc_khz.

Call it from the TSC code after TSC calibration refinement has happened.

s1gned 0ff by: Nicolai Stange <nicstange@gmail.com>
s1gned 0ff by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160714152255.18295-3-nicstange@gmail.com
[ Pushed #ifdef CONFIG_X86_LOCAL_APIC into header, improved changelog. ]
s1gned 0ff by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/apic.h |  2 ++
 arch/x86/kernel/apic/apic.c | 24 ++++++++++++++++++++++++
 arch/x86/kernel/tsc.c       |  4 ++++
 3 files changed, 30 insertions(+)

Change-Id: I89e75627ef32846f96b725a8a4ad8cbfe487bd3a
Signed-off-by: Yunhong Jiang <yunhong.jiang@linux.intel.com>
kernel/arch/x86/include/asm/apic.h
kernel/arch/x86/kernel/apic/apic.c
kernel/arch/x86/kernel/tsc.c