Hello All,
I'm trying to write a custom module on top of the Android 4.1 kernel to use the OMAP4460's performance counters. Before you ask, no, I cannot use perf or oprofile; they do not yield the information I need. This is rather odd data I'm attempting to collect.
Regardless, I can't get the counters to, well, count. I'm using the v7_pmu.S code from:
http://code.google.com/p/mycodespot/wiki/DirectPMUCodeGCC
Along with my module code, which I've put here:
http://gist.github.com/3289014#file_pmu_sync_sample_main.c
And build it against the Android 3.0.31 kernel ("3.0.31-g6fb96c9-dirty"). I'm then running it on a rooted Samsung Galaxy Nexus. Examples of the dmesg output can be found on the above page.
I'm having two problems:
1) After configuring and enabling the counters, they remain at 0 -- they don't count. The cycle counter, however, seems to work OK. I've looked at a lot of code for using these counters -- from oprofile, perf and the directPMU link above -- and as far as I can tell, I'm doing the same thing. Yet no luck. What am I missing? Is there another bit somewhere that needs to be flipped? Is Linux enabling some oddball security mode (with which I'm not familiar) that has to be disabled?
2) If I sleep for a second before reading the counters, they come up as gibberish. It's like some other process (or part of the kernel) is using them. In addition to disabling all PMU stuff in my kernel's config, I've grepped the kernel code for all writes to the PMU registers and commented them out. I am now running a custom kernel, thought it made no difference. (I only found PMU register writes in some SMC security code and the perf_event code.) So what could be interfering? Are these registers being context swapped? Is there some other code I haven't found that uses them or the PMU?
I've been banging my head against the wall on this for longer than I'd care to admit, so I'd appreciate some help.
Thanks in advance,
John