perf test: Remove x86 rdpmc test
authorIan Rogers <irogers@google.com>
Tue, 19 Jul 2022 22:39:45 +0000 (15:39 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 1 Aug 2022 12:18:12 +0000 (09:18 -0300)
This test has been superseded by test_stat_user_read in:

  tools/lib/perf/tests/test-evsel.c

The updated test doesn't divide-by-0 when running time of a counter is
0. It also supports ARM64.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Rob Herring <robh@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20220719223946.176299-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/x86/tests/Build
tools/perf/arch/x86/tests/arch-tests.c
tools/perf/arch/x86/tests/rdpmc.c [deleted file]

index 28d7933..70b5bcb 100644 (file)
@@ -2,7 +2,6 @@ perf-$(CONFIG_DWARF_UNWIND) += regs_load.o
 perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
 
 perf-y += arch-tests.o
-perf-y += rdpmc.o
 perf-y += sample-parsing.o
 perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o
 perf-$(CONFIG_X86_64) += bp-modify.o
index 64fb73d..04018b8 100644 (file)
@@ -3,7 +3,6 @@
 #include "tests/tests.h"
 #include "arch-tests.h"
 
-DEFINE_SUITE("x86 rdpmc", rdpmc);
 #ifdef HAVE_AUXTRACE_SUPPORT
 DEFINE_SUITE("x86 instruction decoder - new instructions", insn_x86);
 DEFINE_SUITE("Intel PT packet decoder", intel_pt_pkt_decoder);
@@ -14,7 +13,6 @@ DEFINE_SUITE("x86 bp modify", bp_modify);
 DEFINE_SUITE("x86 Sample parsing", x86_sample_parsing);
 
 struct test_suite *arch_tests[] = {
-       &suite__rdpmc,
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
        &suite__dwarf_unwind,
 #endif
diff --git a/tools/perf/arch/x86/tests/rdpmc.c b/tools/perf/arch/x86/tests/rdpmc.c
deleted file mode 100644 (file)
index 498413a..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include "perf-sys.h"
-#include "debug.h"
-#include "tests/tests.h"
-#include "cloexec.h"
-#include "event.h"
-#include <internal/lib.h> // page_size
-#include "arch-tests.h"
-
-static u64 rdpmc(unsigned int counter)
-{
-       unsigned int low, high;
-
-       asm volatile("rdpmc" : "=a" (low), "=d" (high) : "c" (counter));
-
-       return low | ((u64)high) << 32;
-}
-
-static u64 rdtsc(void)
-{
-       unsigned int low, high;
-
-       asm volatile("rdtsc" : "=a" (low), "=d" (high));
-
-       return low | ((u64)high) << 32;
-}
-
-static u64 mmap_read_self(void *addr)
-{
-       struct perf_event_mmap_page *pc = addr;
-       u32 seq, idx, time_mult = 0, time_shift = 0;
-       u64 count, cyc = 0, time_offset = 0, enabled, running, delta;
-
-       do {
-               seq = pc->lock;
-               barrier();
-
-               enabled = pc->time_enabled;
-               running = pc->time_running;
-
-               if (enabled != running) {
-                       cyc = rdtsc();
-                       time_mult = pc->time_mult;
-                       time_shift = pc->time_shift;
-                       time_offset = pc->time_offset;
-               }
-
-               idx = pc->index;
-               count = pc->offset;
-               if (idx)
-                       count += rdpmc(idx - 1);
-
-               barrier();
-       } while (pc->lock != seq);
-
-       if (enabled != running) {
-               u64 quot, rem;
-
-               quot = (cyc >> time_shift);
-               rem = cyc & (((u64)1 << time_shift) - 1);
-               delta = time_offset + quot * time_mult +
-                       ((rem * time_mult) >> time_shift);
-
-               enabled += delta;
-               if (idx)
-                       running += delta;
-
-               quot = count / running;
-               rem = count % running;
-               count = quot * enabled + (rem * enabled) / running;
-       }
-
-       return count;
-}
-
-/*
- * If the RDPMC instruction faults then signal this back to the test parent task:
- */
-static void segfault_handler(int sig __maybe_unused,
-                            siginfo_t *info __maybe_unused,
-                            void *uc __maybe_unused)
-{
-       exit(-1);
-}
-
-static int __test__rdpmc(void)
-{
-       volatile int tmp = 0;
-       u64 i, loops = 1000;
-       int n;
-       int fd;
-       void *addr;
-       struct perf_event_attr attr = {
-               .type = PERF_TYPE_HARDWARE,
-               .config = PERF_COUNT_HW_INSTRUCTIONS,
-               .exclude_kernel = 1,
-       };
-       u64 delta_sum = 0;
-        struct sigaction sa;
-       char sbuf[STRERR_BUFSIZE];
-
-       sigfillset(&sa.sa_mask);
-       sa.sa_sigaction = segfault_handler;
-       sa.sa_flags = 0;
-       sigaction(SIGSEGV, &sa, NULL);
-
-       fd = sys_perf_event_open(&attr, 0, -1, -1,
-                                perf_event_open_cloexec_flag());
-       if (fd < 0) {
-               pr_err("Error: sys_perf_event_open() syscall returned "
-                      "with %d (%s)\n", fd,
-                      str_error_r(errno, sbuf, sizeof(sbuf)));
-               return -1;
-       }
-
-       addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0);
-       if (addr == (void *)(-1)) {
-               pr_err("Error: mmap() syscall returned with (%s)\n",
-                      str_error_r(errno, sbuf, sizeof(sbuf)));
-               goto out_close;
-       }
-
-       for (n = 0; n < 6; n++) {
-               u64 stamp, now, delta;
-
-               stamp = mmap_read_self(addr);
-
-               for (i = 0; i < loops; i++)
-                       tmp++;
-
-               now = mmap_read_self(addr);
-               loops *= 10;
-
-               delta = now - stamp;
-               pr_debug("%14d: %14Lu\n", n, (long long)delta);
-
-               delta_sum += delta;
-       }
-
-       munmap(addr, page_size);
-       pr_debug("   ");
-out_close:
-       close(fd);
-
-       if (!delta_sum)
-               return -1;
-
-       return 0;
-}
-
-int test__rdpmc(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
-{
-       int status = 0;
-       int wret = 0;
-       int ret;
-       int pid;
-
-       pid = fork();
-       if (pid < 0)
-               return -1;
-
-       if (!pid) {
-               ret = __test__rdpmc();
-
-               exit(ret);
-       }
-
-       wret = waitpid(pid, &status, 0);
-       if (wret < 0 || status)
-               return -1;
-
-       return 0;
-}