Able to dump lock()/unlock() timing data

This commit is contained in:
Ben Gras 2005-06-01 09:40:27 +00:00
parent 66dab193f3
commit bd12703b76

View file

@ -15,6 +15,7 @@
#include <timers.h>
#include <string.h>
#include <ibm/interrupt.h>
#include <minix/config.h>
#include "../../kernel/const.h"
#include "../../kernel/type.h"
#include "../../kernel/proc.h"
@ -37,6 +38,9 @@ FORWARD _PROTOTYPE( void sched_dmp, (void) );
FORWARD _PROTOTYPE( void monparams_dmp, (void) );
FORWARD _PROTOTYPE( void kenv_dmp, (void) );
FORWARD _PROTOTYPE( void memchunks_dmp, (void) );
#if ENABLE_LOCK_TIMING
FORWARD _PROTOTYPE( void timing_dmp, (void) );
#endif
/* Some global data that is shared among several dumping procedures.
* Note that the process table copy has the same name as in the kernel
@ -65,6 +69,9 @@ PUBLIC int do_fkey_pressed(message *m)
case F5: monparams_dmp(); break;
case F6: irqtab_dmp(); break;
case F7: kmessages_dmp(); break;
#if ENABLE_LOCK_TIMING
case F8: timing_dmp(); break;
#endif
case F9: diagnostics_dmp(); break;
case F10: kenv_dmp(); break;
case F11: memchunks_dmp(); break;
@ -108,6 +115,43 @@ PRIVATE void diagnostics_dmp()
printf(print_buf); /* print the messages */
}
#if ENABLE_LOCK_TIMING
/*===========================================================================*
* timing_dmp *
*===========================================================================*/
PRIVATE void timing_dmp()
{
static struct lock_timedata timingdata[TIMING_CATEGORIES];
int r, c, f, skipped = 0, printed = 0, maxlines = 23, x = 0;
static int offsetlines = 0;
if ((r = sys_getlocktimings(timingdata)) != OK) {
report("warning: couldn't get copy of lock timings", r);
return;
}
for(c = 0; c < TIMING_CATEGORIES; c++) {
int b;
if(!timingdata[c].lock_timings_range[0] || !timingdata[c].binsize)
continue;
x = printf("%-*s: misses %lu, resets %lu, measurements %lu: ",
TIMING_NAME, timingdata[c].names,
timingdata[c].misses,
timingdata[c].resets,
timingdata[c].measurements);
for(b = 0; b < TIMING_POINTS; b++) {
int w;
if(!timingdata[c].lock_timings[b])
continue;
x += (w = printf(" %5d: %5d", timingdata[c].lock_timings_range[0] +
b*timingdata[c].binsize,
timingdata[c].lock_timings[b]));
if(x + w >= 80) { printf("\n"); x = 0; }
}
if(x > 0) printf("\n");
}
}
#endif
/*===========================================================================*
* kmessages_dmp *
@ -139,7 +183,7 @@ PRIVATE void kmessages_dmp()
}
print_buf[r] = 0; /* make sure it terminates */
printf("Dump of all messages generated by the kernel.\n\n");
printf(print_buf); /* print the messages */
printf("%s", print_buf); /* print the messages */
}