measuring time intervals in kernel
Howdy,
Are there patches/applications/tools for mips that allow to measure time intervals in kernel paths? I'm thinking of something like timepeg (http://www.uow.edu.au/~andrewm/linux/)
but prefer something that is running on mips already.
Tom
Quoted 9 lines · Tom Appermont
Howdy,
Are there patches/applications/tools for mips that allow to measure time intervals in kernel paths? I'm thinking of something like timepeg (http://www.uow.edu.au/~andrewm/linux/)
but prefer something that is running on mips already.Tom
I wrote the original intlat patch for intel and ppc. There is a half-way ported MIPS patch you might be interested. The patch is aginst mvista HHL2.0 kernel. YOu can find the source in the journeyman edit/Malta cross lsp rpm package from the ftp site. You may also need to download the perfview user program by following the www.mvista.com/realtime.
Jun
This patch is obtained by mirroring ppc patch. Two things need to be done:
1. get CPU counter frequency
2. do_IRQ() does not apply readily to Malta board. Either work harder to get it right (under arch/mips/mips-boards/Malta/int.c, roughly), or pick another board.
Jun Sun
010623
arch/mips/kernel/Makefile renamed from arch/mips/kernel/Makefile.orig +2 -1
@@ -20,7 +20,8 @@ obj-y += branch.o process.o signal.o entry.o \ traps.o ptrace.o vm86.o ioport.o reset.o \ semaphore.o setup.o syscall.o sysmips.o \ - ipc.o scall_o32.o unaligned.o fast-sysmips.o + ipc.o scall_o32.o unaligned.o fast-sysmips.o\ + intr_blocking.o ktprocentry.o intlatsamps.o obj-$(CONFIG_MODULES) += mips_ksyms.o ifdef CONFIG_CPU_R3000
arch/mips/kernel/intlatsamps.c renamed from arch/mips/kernel/intlatsamps.c.orig +159 -0
159 lines not on this page · raw message
arch/mips/kernel/intr_blocking.c renamed from arch/mips/kernel/intr_blocking.c.orig +258 -0
258 lines not on this page · raw message
arch/mips/kernel/ktprocentry.c renamed from arch/mips/kernel/ktprocentry.c.orig +156 -0
156 lines not on this page · raw message
arch/mips/kernel/syscalls.h renamed from arch/mips/kernel/syscalls.h.orig +1 -0
@@ -235,3 +235,4 @@ SYS(sys_madvise, 3) SYS(sys_getdents64, 3) SYS(sys_fcntl64, 3) /* 4220 */ +SYS (sys_get_intrData,1 )
include/asm-mips/system.h renamed from include/asm-mips/system.h.orig +17 -3
@@ -46,7 +46,7 @@* no nops at all. */ extern __inline__void -__cli (void ) +__intr_cli (void ) { __asm__ __volatile__( ".set\tpush\n\t"
@@ -66,7 +66,7 @@ : "$1", "memory"); } -#define __save_flags (x) \ +#define __intr_save_flags (x) \ __asm__ __volatile__( \ ".set\tpush\n\t" \ ".set\treorder\n\t" \
@@ -74,6 +74,7 @@ ".set\tpop\n\t" \ : "=r" (x)) +#if 0 #define __save_and_cli (x) \ __asm__ __volatile__( \ ".set\tpush\n\t" \
@@ -91,8 +92,9 @@ : "=r" (x) \ : /* no inputs */ \ : "$1", "memory") +#endif -#define __restore_flags (flags) \ +#define __intr_restore_flags (flags) \ do { \ unsigned long __tmp1; \ \
@@ -114,6 +116,18 @@ : "0" (flags) \ : "$1", "memory"); \ }while (0 ) + +extern int intr_cli(const char*, unsigned); +extern void intr_sti (const char *,unsigned ); +extern void intr_restore_flags (const char *,unsigned ,unsigned ); + +#define __cli () intr_cli(__FILE__,__LINE__) +#define __sti () intr_sti(__FILE__,__LINE__) +#define __save_flags (flags) __intr_save_flags(flags) +gs) +#define __restore_flags (flags) intr_restore_flags(__FILE__,__LINE__, flags) + +#define __save_and_cli (flags) ({__save_flags(flags);__cli();})/* * Non-SMP versions ...
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"jun" == Jun Sun <[email protected]> writes:
Hi
could you look at this changes, no change in functionality, only better readability,
jun> +asmlinkage void inthoff_logentry(unsigned diff) jun> +{
jun> + unsigned sampletime = diff / (cpu_khz / 1000);
jun> +
jun> + if (sampletime < bucketlog [0][0] )
jun> + bucketlog[1][0]++;
jun> + else if (sampletime < bucketlog [0][1] )
jun> + bucketlog[1][1]++;
jun> + else if (sampletime < bucketlog [0][2] )
jun> + bucketlog[1][2]++;
jun> + else if (sampletime < bucketlog [0][3] )
jun> + bucketlog[1][3]++;
jun> + else if (sampletime < bucketlog [0][4] )
jun> + bucketlog[1][4]++;
jun> + else if (sampletime < bucketlog [0][5] )
jun> + bucketlog[1][5]++;
jun> + else if (sampletime < bucketlog [0][6] )
jun> + bucketlog[1][6]++;
jun> + else if (sampletime < bucketlog [0][7] )
jun> + bucketlog[1][7]++;
jun> + else if (sampletime < bucketlog [0][8] )
jun> + bucketlog[1][8]++;
jun> + else if (sampletime < bucketlog [0][9] )
jun> + bucketlog[1][9]++;
jun> + else if (sampletime < bucketlog [0][10] )
jun> + bucketlog[1][10]++;
jun> + else if (sampletime < bucketlog [0][11] )
jun> + bucketlog[1][11]++;
jun> + else if (sampletime < bucketlog [0][12] )
jun> + bucketlog[1][12]++;
jun> + else if (sampletime < bucketlog [0][13] )
jun> + bucketlog[1][13]++;
jun> + else if (sampletime < bucketlog [0][14] )
jun> + bucketlog[1][14]++;
jun> + else if (sampletime < bucketlog [0][15] )
jun> + bucketlog[1][15]++;
jun> + else if (sampletime < bucketlog [0][16] )
jun> + bucketlog[1][16]++;
jun> + else if (sampletime < bucketlog [0][17] )
jun> + bucketlog[1][17]++;
jun> + else if (sampletime < bucketlog [0][18] )
jun> + bucketlog[1][18]++;
jun> + else if (sampletime < bucketlog [0][19] )
jun> + bucketlog[1][19]++;
jun> + else if (sampletime < bucketlog [0][20] )
jun> + bucketlog[1][20]++;
jun> + else if (sampletime < bucketlog [0][21] )
jun> + bucketlog[1][21]++;
jun> + else if (sampletime < bucketlog [0][22] )
jun> + bucketlog[1][22]++;
jun> + else if (sampletime < bucketlog [0][23] )
jun> + bucketlog[1][23]++;
jun> + else if (sampletime < bucketlog [0][24] )
jun> + bucketlog[1][24]++;
jun> + else if (sampletime < bucketlog [0][25] )
jun> + bucketlog[1][25]++;
jun> + else if (sampletime < bucketlog [0][26] )
jun> + bucketlog[1][26]++;
jun> + else if (sampletime < bucketlog [0][27] )
jun> + bucketlog[1][27]++;
jun> + else if (sampletime < bucketlog [0][28] )
jun> + bucketlog[1][28]++;
jun> + else
jun> + bucketlog[1][29]++;
jun> +
jun> + total_samples++;
jun> +
jun> + return;
jun> +}
Any reason for not changing that to something like this?
asmlinkage void inthoff_logentry(unsigned diff)
{
unsigned sampletime = diff / (cpu_khz / 1000);
int i = 0;
while ((i < BUCKETS-1) && (sampletime >= bucketlog [0][i]))
i++;
bucketlog[1][i]++;
total_samples++;
return;
}jun> +struct IntrData intrData = {
jun> + 0, jun> + "interrupt latency test for PPC (8 distinctive entries)", jun> + 0, jun> + 0, jun> + 0,
jun> +
jun> + 1,
jun> + 0xffffffff,
jun> +
jun> + 0,
jun> + 0,
jun> +
jun> + 0, jun> + 0, jun> + 0, jun> + 0, jun> + 0, jun> + 0, jun> + 0
jun> +};
struct IntrData intrData = {
testname: "interrupt latency test for PPC (8 distinctive entries)",
rangeLow: 1,
rangeHigh: 0xffffffff,
}
jun> + * we do a count only if
jun> + * 1. syncFlag is 1 (a valid cli() was called)
jun> + * 2. breakCount is 0 (no iret is called between cli() and this sti() jun> + */
Move this commets to their position in the code (not sure what is better, but /* check 1 */ /* check 2 */ comments are missleading, and don't show clearly in diffs :(((
jun> +void intr_sti(const char *fname, unsigned lineno) jun> +{
[...]
jun> +
jun> + /* check 1*/
here
jun> + if (intrData.syncFlag != 1) {
jun> + intrData.syncStiError ++; jun> + __intr_sti(); jun> + return;
jun> + }
jun> +
jun> + /* check 2 */
and here
jun> + if (intrData.breakCount != 0) {
jun> + intrData.stiBreakError ++; jun> + __intr_sti(); jun> + return;
jun> + }
I miss read this two tests the first time, how about a change like that (I assume that the the check with (x & INT_IENABLE) means interrupts enabled, otherwise change the names of the vars.
jun> +void intr_restore_flags(const char *fname, unsigned lineno, unsigned x) jun> +{
jun> + unsigned flag;
unsigned flag_int_enabled;
unsigned x_int_enabled;jun> +
jun> + /* if we are not logging or we have an error, do nothing */
jun> + if ((intrData.logFlag == 0) || ( intrData.panicFlag != 0)) {
jun> + __intr_restore_flags(x);
jun> + return;
jun> + }
jun> +
jun> + __save_flags(flag);
flag_int_enabled = (flag & INTR_IENABLE) != 0;
x_int_enabled = (x & INTR_IENABLE) != 0;jun> + if (((flag & INTR_IENABLE) == 0) &&
jun> + ((x & INTR_IENABLE) != 0) ) {
if (!flag_int_enabled && x_int_enabled) {jun> + intrData.restoreSti ++;
jun> + intr_sti(fname, lineno);
jun> + }
jun> +
jun> + if ( ((flag & INTR_IENABLE) != 0) &&
jun> + ((x & INTR_IENABLE) == 0) ) {
if (flag_int_enabled && !x_int_enabled) {jun> + intrData.restoreCli ++;
jun> + intr_cli(fname, lineno);
jun> + }
jun> +
jun> + __intr_restore_flags(x);
jun> +}
/me decides that he has been enough pedantic today.
Later, Juan.
Signature · 2 lines
In theory, practice and theory are the same, but in practice they are different -- Larry McVoy