linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: x86: Fix incorrect VM-exit profiling
@ 2022-04-12 19:58 Wei Zhang
  2022-04-12 19:58 ` [PATCH 1/2] KVM: x86: allow guest to send its _stext for kvm profiling Wei Zhang
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Wei Zhang @ 2022-04-12 19:58 UTC (permalink / raw)
  Cc: Wei Zhang, Suleiman Souhlal, Sangwhan Moon, Ingo Molnar,
	Paolo Bonzini, Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li,
	Jim Mattson, Joerg Roedel, kvm, linux-kernel

The profile=kvm boot option has been useful because it provides a
convenient approach to profile VM exits. However, it's problematic because
the profiling buffer is indexed by (pc - _stext), and a guest's pc minus a
host's _stext doesn't make sense in most cases.

When running another linux kernel in the guest, we could work around the
problem by disabling KASLR in both the host and the guest so they have the
same _stext. However, this is inconvenient and not always possible.

We're looking for a solution to this problem. A straightforward idea is to
pass the guest's _stext to the host so the profiling buffer can be indexed
correctly. This approach is quite brute, as you can see in the prototype
patches.

We had some initial discussions and here is a short summary:
1. The VM-exit profiling is already hacky. It's collecting stats about all
   KVM guests bunched together into a single global buffer without any
   separation.
2. Even if we pass _stext from the guest, there are still a lot of
   limitations: There can be only one running guest, and the size of its
   text region shouldn't exceed the size of the profiling buffer,
   which is (_etext - _stext) in the host.
3. There are other methods for profiling VM exits, but it would be really
   convenient if readprofile just works out of box for KVM profiling.

It would be awesome to hear more thoughts on this. Should we try to fix the
existing VM-exit profiling functionility? Or should we avoid adding more
hacks there? If it should be fixed, what's the preferred way? Thanks in
advance for any suggestions.

Wei Zhang (2):
  KVM: x86: allow guest to send its _stext for kvm profiling
  KVM: x86: illustrative example for sending guest _stext with a
    hypercall

 arch/x86/kernel/setup.c       |  6 ++++++
 arch/x86/kvm/x86.c            | 15 +++++++++++++++
 include/linux/kvm_host.h      |  4 ++++
 include/uapi/linux/kvm_para.h |  1 +
 virt/kvm/Kconfig              |  5 +++++
 5 files changed, 31 insertions(+)

base-commit: 42dcbe7d8bac997eef4c379e61d9121a15ed4e36
-- 
2.35.1.1178.g4f1659d476-goog


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-05-18 15:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 19:58 [PATCH 0/2] KVM: x86: Fix incorrect VM-exit profiling Wei Zhang
2022-04-12 19:58 ` [PATCH 1/2] KVM: x86: allow guest to send its _stext for kvm profiling Wei Zhang
2022-05-09 23:55   ` Sean Christopherson
2022-05-11 16:45     ` Wei Zhang
2022-04-12 19:58 ` [PATCH 2/2] KVM: x86: illustrative example for sending guest _stext with a hypercall Wei Zhang
2022-05-09 23:57 ` [PATCH 0/2] KVM: x86: Fix incorrect VM-exit profiling Sean Christopherson
2022-05-11 16:45   ` Wei Zhang
2022-05-11 19:42     ` Sean Christopherson
2022-05-16 19:30       ` Wei Zhang
2022-05-18  4:27         ` Suleiman Souhlal
2022-05-18 15:34           ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).