Performance Events/Hw Cache Miss counting

From: SUJA JAMES
Date: Mon Oct 17 2011 - 14:32:13 EST


Message body
Hi All,

I am trying to query the performance management counters on my box,
which is based on Kernel 2.6.38 and running Intel processor. I am
trying to do the same from my kernel module itself as I need to
profile my kernel modules. I use the
perf_event_create_kernel_counter() api with the following attr/config

The below attrs/configuration is working and I am getting the counter
values/overflow_handler is getting called.
static struct perf_event_attr counter_attrs[] = {
{
 Â {
ÂÂÂ .typeÂÂÂ ÂÂÂ = PERF_TYPE_HARDWARE,
ÂÂÂ .configÂÂÂ ÂÂÂ = PERF_COUNT_HW_CACHE_MISSES,
ÂÂÂ .sizeÂÂÂ ÂÂÂ = sizeof(struct perf_event_attr),
ÂÂÂ .pinnedÂÂÂ = 1,
ÂÂÂ .disabledÂÂÂ = 0,
ÂÂÂ },
};

But, when I use the following attrs/config, the
perf_event_create_kernel_counter() API is failing. Ie,
(IS_ERR(returned_pevent) is TRUE and the event is not triggered on the
CPU. I even tried âPERF_TYPE_HARDWAREâ type also with the below
config. Also I used different values for "sample_period" [100 to 1000]

static struct perf_event_attr counter_attrs[] = {
{
ÂÂÂ .typeÂÂÂ ÂÂÂ Â =Â PERF_TYPE_HW_CACHE,
.configÂÂÂ Â =ÂÂÂ PERF_COUNT_HW_CACHE_L1D ÂÂÂ ÂÂÂ ÂÂÂ Â <<Â 0Â |
ÂÂÂ ÂÂÂ Â ÂÂÂ (PERF_COUNT_HW_CACHE_OP_READ ÂÂÂ ÂÂÂ Â <<Â 8) |
ÂÂÂ ÂÂÂ ÂÂÂ (PERF_COUNT_HW_CACHE_RESULT_MISS ÂÂÂ Â << 16),
ÂÂÂ .sizeÂÂÂ Â = sizeof(struct perf_event_attr),
 .pinned = 1,
ÂÂÂ .disabled = 0,
ÂÂÂ },
};

Does anybody know why?. What âconfigâ value I should use to query the
L1D/ L1I cache misses. I think the âPERF_COUNT_HW_CACHE_MISSESâ counts
only 2nd and 3rd level caches.

Thanks,
Suja

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/