I need to measure a very short time interval when debugging something in Linux kernel on an ARM android device (Nexus 7 with Qualcomm's quad-core Snapdragon S4 SoC). I found the shortest time interval that ktime_get() can measure is 30us since Nexus 7 uses a 30MHz timer, but my testing code (a simple interrupt handler) running less than 30us, so I always get 0us or 30us. I tried to read performance counter like below:
unsigned long t1, t2;
asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(t1));
...... //my interrupt handling code
asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(t2));
unsigned long interval = t2 - t1;
but the value of "t1", "t2" and "interval" was always 0.
My questions are: 1. does "asm volatile ("MRC p15, 0, %0, c9, c13, 0\t\n": "=r"(value));" work on Nexus 7? 2. what is this register? CPU cycles at current CPU frequency or a particular frequency? 3. Is there any method to measure the code execution time that shorter than a tick of 30MHz timer on Nexus 7?
Many thanks in advance!
Thanks Wang Li