Perf: Add support for L2 cycle counter in default list

Adding the L2 cycle counter in the default list of events
has the advantage that the user can do a :

perf stat -e l2-cycles -e cycles ls

and see the outputs for the L2 cycle counter and L1 cycle
counter separately. Previously, it was only accessible via
the raw code "rsfe".

This method also allows us to program the L2 cycle counter
only from one CPU.

The changes in this patch are used by the userspace perf
tool.

Change-Id: I61b85b48f5474fe9f6ffb1a405b60b4332ab60c7
Signed-off-by: Ashwin Chaugule <ashwinc@codeaurora.org>
This commit is contained in:
Ashwin Chaugule
2011-11-11 15:32:15 -05:00
committed by Neil Leeder
parent a9b96e1ba3
commit 389497b245
3 changed files with 15 additions and 3 deletions

View File

@@ -584,10 +584,15 @@ static int krait_l2_event_init(struct perf_event *event)
return err;
}
hwc->config_base = event->attr.config;
hwc->config = 0;
hwc->event_base = 0;
/* Check if we came via perf default syms */
if (event->attr.config == PERF_COUNT_HW_L2_CYCLES)
hwc->config_base = L2CYCLE_CTR_RAW_CODE;
else
hwc->config_base = event->attr.config;
/* Only one CPU can control the cycle counter */
if (hwc->config_base == L2CYCLE_CTR_RAW_CODE) {
/* Check if its already running */

View File

@@ -911,10 +911,15 @@ static int bb_l2_event_init(struct perf_event *event)
return err;
}
hwc->config_base = event->attr.config & 0xff;
hwc->config = 0;
hwc->event_base = 0;
/* Check if we came via perf default syms */
if (event->attr.config == PERF_COUNT_HW_L2_CYCLES)
hwc->config_base = BB_L2CYCLE_CTR_RAW_CODE;
else
hwc->config_base = event->attr.config;
/* Only one CPU can control the cycle counter */
if (hwc->config_base == BB_L2CYCLE_CTR_RAW_CODE) {
/* Check if its already running */

View File

@@ -55,6 +55,7 @@ enum perf_hw_id {
PERF_COUNT_HW_BUS_CYCLES = 6,
PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 7,
PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 8,
PERF_COUNT_HW_L2_CYCLES = 9,
PERF_COUNT_HW_MAX, /* non-ABI */
};
@@ -219,8 +220,9 @@ struct perf_event_attr {
precise_ip : 2, /* skid constraint */
mmap_data : 1, /* non-exec mmap data */
sample_id_all : 1, /* sample_type all events */
single_instance:1, /* per-cpu event if unset */
__reserved_1 : 45;
__reserved_1:44;
union {
__u32 wakeup_events; /* wakeup every n events */