• L
    KVM: PPC: Tick accounting should defer vtime accounting 'til after IRQ handling · 235cee16
    Laurent Vivier 提交于
    Commit 11266528 ("KVM: PPC: Book3S HV: Context tracking exit guest
    context before enabling irqs") moved guest_exit() into the interrupt
    protected area to avoid wrong context warning (or worse). The problem is
    that tick-based time accounting has not yet been updated at this point
    (because it depends on the timer interrupt firing), so the guest time
    gets incorrectly accounted to system time.
    
    To fix the problem, follow the x86 fix in commit 16045714 ("Defer
    vtime accounting 'til after IRQ handling"), and allow host IRQs to run
    before accounting the guest exit time.
    
    In the case vtime accounting is enabled, this is not required because TB
    is used directly for accounting.
    
    Before this patch, with CONFIG_TICK_CPU_ACCOUNTING=y in the host and a
    guest running a kernel compile, the 'guest' fields of /proc/stat are
    stuck at zero. With the patch they can be observed increasing roughly as
    expected.
    
    Fixes: e233d54d ("KVM: booke: use __kvm_guest_exit")
    Fixes: 11266528 ("KVM: PPC: Book3S HV: Context tracking exit guest context before enabling irqs")
    Cc: stable@vger.kernel.org # 5.12+
    Signed-off-by: NLaurent Vivier <lvivier@redhat.com>
    [np: only required for tick accounting, add Book3E fix, tweak changelog]
    Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
    Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20211027142150.3711582-1-npiggin@gmail.com
    235cee16
booke.c 56.7 KB