Skip to content

KVM: x86: never specify a sample period for virtualized in_tx_cp counters

Robert O'Callahan kvm lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest1 patch 3 repliesIn review
  2. v11 patch 1 replySuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1KVM: x86: never specify a sample period for virtualized in_tx_cp countersarch/x86/kvm/pmu.c+10 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/01] KVM: x86: never specify a sample period for virtualized in_tx_cp counters

Changes in version 2:
- Fixed block comment formatting as requested by Ingo Molnar
- Changed commit summary to refer to a testcase that more easily shows the problem.

For reference here's a complete testcase for an Intel TSX-enabled KVM guest:

#include <linux/perf_event.h>
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <unistd.h>

int main(void) {
    struct perf_event_attr attr;
    int fd;
    long long count;
    memset(&attr, 0, sizeof(attr));
    attr.type = PERF_TYPE_RAW;
    attr.size = sizeof(attr);
    attr.config = 0x2005101c4; // conditional branches retired IN_TXCP
    attr.sample_period = 0;
    attr.exclude_kernel = 1;
    attr.exclude_guest = 1;
    fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
    ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
    ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
    for (int i = 0; i < 500; ++i) {
        putchar('.');
    }
    read(fd, &count, sizeof(count));
    printf("\nConditional branches: %lld\n%s\n", count,
           count < 500 ? "FAILED" : "PASSED");
    return 0;
}

Robert O'Callahan (1):
KVM: x86: never specify a sample period for virtualized in_tx_cp
counters

 arch/x86/kvm/pmu.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
Signature · 1 line
2.9.3