perf events: Add stalled cycles generic event - PERF_COUNT_HW_STALLED_CYCLES
authorIngo Molnar <mingo@elte.hu>
Sun, 24 Apr 2011 06:18:31 +0000 (08:18 +0200)
committerIngo Molnar <mingo@elte.hu>
Tue, 26 Apr 2011 18:04:53 +0000 (20:04 +0200)
The new PERF_COUNT_HW_STALLED_CYCLES event tries to approximate
cycles the CPU does nothing useful, because it is stalled on a
cache-miss or some other condition.

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/n/tip-fue11vymwqsoo5to72jxxjyl@git.kernel.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/cpu/perf_event_intel.c
include/linux/perf_event.h
tools/perf/util/parse-events.c
tools/perf/util/python.c

index 9ae4a2aa739825d50a1dcbf8d390b90ee357bc46..efa2704c9dfd582563238e4d6de065e89397f5c0 100644 (file)
@@ -1413,6 +1413,9 @@ static __init int intel_pmu_init(void)
                x86_pmu.enable_all = intel_pmu_nhm_enable_all;
                x86_pmu.extra_regs = intel_nehalem_extra_regs;
 
+               /* Install the stalled-cycles event: 0xff: All reasons, 0xa2: Resource stalls */
+               intel_perfmon_event_map[PERF_COUNT_HW_STALLED_CYCLES] = 0xffa2;
+
                if (ebx & 0x40) {
                        /*
                         * Erratum AAJ80 detected, we work it around by using
index ee9f1e7828001f26a5657962040277cb6e574795..ac636dd20a0c3224763a1c7e8a640bdd7aaa74f0 100644 (file)
@@ -52,6 +52,7 @@ enum perf_hw_id {
        PERF_COUNT_HW_BRANCH_INSTRUCTIONS       = 4,
        PERF_COUNT_HW_BRANCH_MISSES             = 5,
        PERF_COUNT_HW_BUS_CYCLES                = 6,
+       PERF_COUNT_HW_STALLED_CYCLES            = 7,
 
        PERF_COUNT_HW_MAX,                      /* non-ABI */
 };
index 952b4ae3d954f36c2a85ec9db2d4908e44a91188..1869e4c646db4bdcdc3b4bc7e18de65adf4dc26c 100644 (file)
@@ -38,6 +38,7 @@ static struct event_symbol event_symbols[] = {
   { CHW(BRANCH_INSTRUCTIONS),  "branch-instructions",  "branches"      },
   { CHW(BRANCH_MISSES),                "branch-misses",        ""              },
   { CHW(BUS_CYCLES),           "bus-cycles",           ""              },
+  { CHW(STALLED_CYCLES),       "stalled-cycles",       ""              },
 
   { CSW(CPU_CLOCK),            "cpu-clock",            ""              },
   { CSW(TASK_CLOCK),           "task-clock",           ""              },
index f5e38451fdc505e329ac77415e9e8aba5fbe7ebb..406f613ee619419353ac8cf3c7bbbef26353f3ef 100644 (file)
@@ -798,6 +798,7 @@ static struct {
        { "COUNT_HW_BRANCH_INSTRUCTIONS", PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
        { "COUNT_HW_BRANCH_MISSES",       PERF_COUNT_HW_BRANCH_MISSES },
        { "COUNT_HW_BUS_CYCLES",          PERF_COUNT_HW_BUS_CYCLES },
+       { "COUNT_HW_STALLED_CYCLES",      PERF_COUNT_HW_STALLED_CYCLES },
        { "COUNT_HW_CACHE_L1D",           PERF_COUNT_HW_CACHE_L1D },
        { "COUNT_HW_CACHE_L1I",           PERF_COUNT_HW_CACHE_L1I },
        { "COUNT_HW_CACHE_LL",            PERF_COUNT_HW_CACHE_LL },