From 17e3dae7404aa1b34145dc63c6ec85a3d12f41ee Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 20 Aug 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-08-20 --- pc/dat.h | 2 +- pc/trap.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/pc/dat.h b/pc/dat.h index 725e3bba0accca4f28f64c3debff1251cf5312e6..e40618a1933f0ca329867c1151046112f50484d6 100644 --- a/pc/dat.h +++ b/pc/dat.h @@ -175,7 +175,7 @@ struct Mach int syscall; int load; int intr; - vlong intrts; /* time stamp of last interrupt */ + uvlong intrts; /* time stamp of last interrupt */ int flushmmu; /* make current proc flush it's mmu state */ int ilockdepth; diff --git a/pc/trap.c b/pc/trap.c index 2a52c96c34cc46f007662245cb6877c1dccb7e88..a3eea2f037d727480c3854638526004a05c3c6e1 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -14,6 +14,12 @@ static void fault386(Ureg*, void*); static Lock vctllock; static Vctl *vctl[256]; +ulong *intrtimes[256]; + +enum +{ + Ntimevec = 1000 /* number of time buckets for each intr */ +}; void intrenable(int irq, void (*f)(Ureg*, void*), void* a, int tbdf, char *name) @@ -240,6 +246,25 @@ static char* excname[32] = { "31 (reserved)", }; +/* + * keep histogram of interrupt service times (tops off at 1/100 second) + */ +void +intrtime(Mach *m, int vno) +{ + uvlong now; + ulong diff; + + rdtsc(&now); + diff = now - m->intrts; + diff /= m->cpumhz; + if(diff >= 1000) + diff = 999; + if(intrtimes[vno] == nil) + intrtimes[vno] = xalloc(Ntimevec*sizeof(ulong)); + intrtimes[vno][diff]++; +} + /* * All traps come here. It is slower to have all traps call trap() * rather than directly vectoring the handler. However, this avoids a @@ -255,7 +280,8 @@ trap(Ureg* ureg) Vctl *ctl, *v; Mach *mach; - m->intrts = fastticks(nil); + if(m->havetsc) + rdtsc(&m->intrts); user = 0; if((ureg->cs & 0xFFFF) == UESEL){ user = 1; @@ -278,6 +304,8 @@ trap(Ureg* ureg) } if(ctl->eoi) ctl->eoi(vno); + if(ctl->isintr && m->havetsc) + intrtime(m, vno); /* * preemptive scheduling. to limit stack depth,