]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: pmu: Reset sample period on overflow handling
authorMarc Zyngier <maz@kernel.org>
Sun, 6 Oct 2019 09:28:50 +0000 (10:28 +0100)
committerMarc Zyngier <maz@kernel.org>
Sun, 20 Oct 2019 09:47:07 +0000 (10:47 +0100)
commit6f3e0895c071daa1ca2ef90655e9be63c287a1a6
tree7ca547d4e4d0c04a8e4bbcf905d4ff8a44ae3788
parent8982b455a765e82bbeff7d2676c5b5d4fc5fc0ee
KVM: arm64: pmu: Reset sample period on overflow handling

The PMU emulation code uses the perf event sample period to trigger
the overflow detection. This works fine  for the *first* overflow
handling, but results in a huge number of interrupts on the host,
unrelated to the number of interrupts handled in the guest (a x20
factor is pretty common for the cycle counter). On a slow system
(such as a SW model), this can result in the guest only making
forward progress at a glacial pace.

It turns out that the clue is in the name. The sample period is
exactly that: a period. And once the an overflow has occured,
the following period should be the full width of the associated
counter, instead of whatever the guest had initially programed.

Reset the sample period to the architected value in the overflow
handler, which now results in a number of host interrupts that is
much closer to the number of interrupts in the guest.

Fixes: 209043e059de ("arm64: KVM: Add PMU overflow interrupt routing")
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
virt/kvm/arm/pmu.c