Skip to content

Perf kvm commands bug fix

Dapeng Mi linux-perf-users lkml 3 versions – Applied

Status from this message: Thanks, applied to perf-tools-next,

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 3 repliesApplied
  2. v26 patches 7 repliesApplied
  3. v15 patches 11 repliesSuperseded

Changes in v3 from the cover letter

* Correct the fixes tag in patch 5-6/6.
* Add "acked-by" tag from Namhyung.

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/6perf tools kvm: Add missed memory allocation check and freetools/perf/builtin-kvm.c+58 -230 replies
2/6perf tools kwork: Add missed memory allocation check and freetools/perf/builtin-kwork.c+22 -50 replies
3/6perf tools kvm: Fix the potential out of range memory access issuetools/perf/builtin-kvm.c+10 -50 replies
4/6perf tools: Add helper x86__is_intel_cpu()tools/perf/util/env.c tools/perf/util/env.h+24 -00 replies
5/6perf tools kvm: Use "cycles" to sample guest for "kvm record" on Inteltools/perf/arch/x86/util/kvm-stat.c tools/perf/builtin-kvm.c tools/perf/util/kvm-stat.h+61 -102 replies
6/6perf tools kvm: Use "cycles" to sample guest for "kvm top" on Inteltools/perf/builtin-kvm.c+33 -10 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchNamhyung Kim
1/6A-b
2/6A-b
3/6A-b
4/6A-b
5/6A-b
6/6A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [Patch v3 0/6] Perf kvm commands bug fix

This patch-set fixes perf kvm commands issues, like missed memory allocation check/free, out of range memory access and especially the issue that fails to sample guest with "perf kvm record/top" commands on Intel platforms.

Since the change "KVM: x86/pmu: Add basic support to enable guest PEBS
via DS"[1] starts, host loses the capability to sample guest with PEBS
since all PEBS related MSRs are switched to guest value after vm-entry, like IA32_DS_AREA MSR is switched to guest GVA at vm-entry. This leads to PEBS events can't be used to sample guest by host, otherwise no guest PEBS records can be really sampled. The patches 5-6/6 fix this issue by using "cycles" event instead of PEBS event "cycles:P" to sample guest on Intel platforms.

Changes:
v2 -> v3:
* Correct the fixes tag in patch 5-6/6.
* Add "acked-by" tag from Namhyung.

v1 -> v2:
* Free memory allocated by strdup().
* Check "--pfm-events" in kvm_add_default_arch_event() as well.
* Opportunistically fix the missed memory allocation and free issue in builtin-kwork.
* Comments refine.

Tests:
* Run command "perf kvm record -a && perf kvm report" and "perf kvm top" on Intel Sapphire Rapids platform, guest records can be captured successfully.
* Since no powerpc platforms on hand, doesn't check the patches on powerpc. Any test on powerpc is appreciated.

Ref:
[1] https://lore.kernel.org/all/[email protected]/

Dapeng Mi (6):
perf tools kvm: Add missed memory allocation check and free perf tools kwork: Add missed memory allocation check and free perf tools kvm: Fix the potential out of range memory access issue perf tools: Add helper x86__is_intel_cpu()
perf tools kvm: Use "cycles" to sample guest for "kvm record" on Intel perf tools kvm: Use "cycles" to sample guest for "kvm top" on Intel

 tools/perf/arch/x86/util/kvm-stat.c |  51 +++++++++++
 tools/perf/builtin-kvm.c            | 130 ++++++++++++++++++++--------
 tools/perf/builtin-kwork.c          |  27 ++++--
 tools/perf/util/env.c               |  22 +++++
 tools/perf/util/env.h               |   2 +
 tools/perf/util/kvm-stat.h          |  10 +++
 6 files changed, 203 insertions(+), 39 deletions(-)

base-commit: 576bd7a8c90c48e9e93a18de0bcc0fa1e0a5433b

Signature · 1 line
2.34.1