Remove obsolete profiling code

上级 a7d6a3f6
...@@ -56,4 +56,3 @@ ...@@ -56,4 +56,3 @@
$ apt-get install libjemalloc-dev $ apt-get install libjemalloc-dev
$ make HW=user o.user/utest $ make HW=user o.user/utest
...@@ -194,11 +194,6 @@ void yield(void); ...@@ -194,11 +194,6 @@ void yield(void);
struct proc* threadalloc(void (*fn)(void*), void *arg); struct proc* threadalloc(void (*fn)(void*), void *arg);
struct proc* threadpin(void (*fn)(void*), void *arg, const char *name, int cpu); struct proc* threadpin(void (*fn)(void*), void *arg, const char *name, int cpu);
// prof.c
extern int profenable;
void profreset(void);
void profdump(void);
// sampler.c // sampler.c
void sampstart(void); void sampstart(void);
int sampintr(struct trapframe*); int sampintr(struct trapframe*);
......
struct profrec {
u64 tot;
u64 cnt;
__padout__;
} __mpalign__;
typedef struct profctr {
const char *name;
struct profrec rec[NCPU] __mpalign__;
__padout__;
} profctr_t;
#if 0 /* not for c++ */
#define DEFINE_PROFCTR(xname) \
profctr_t xname __attribute__((section(".prof"))) = { .name = #xname };
#define prof_start(name) \
u64 __prof##name = profenable ? rdtsc() : 0;
#define prof_end(name) do { \
if (profenable) { \
u64 __eprof##name = rdtsc(); \
u64 __profid = mycpu()->id; \
name.rec[__profid].tot += __eprof##name - __prof##name; \
name.rec[__profid].cnt++; \
} \
} while (0)
#else
#define DEFINE_PROFCTR(x)
#define prof_start(x)
#define prof_end(x)
#endif
...@@ -29,7 +29,6 @@ OBJS = \ ...@@ -29,7 +29,6 @@ OBJS = \
picirq.o \ picirq.o \
pipe.o \ pipe.o \
proc.o \ proc.o \
prof.o \
gc.o \ gc.o \
rnd.o \ rnd.o \
sampler.o \ sampler.o \
......
...@@ -270,18 +270,6 @@ consoleintr(int (*getc)(void)) ...@@ -270,18 +270,6 @@ consoleintr(int (*getc)(void))
case C('W'): case C('W'):
wq_dump(); wq_dump();
break; break;
case C('L'): // Prof stats
profdump();
break;
case C('K'): // Prof enable
profreset();
cprintf("prof enabled\n");
profenable = 1;
break;
case C('I'): // Prof disable
profenable = 0;
cprintf("prof disabled\n");
break;
case C('F'): // kmem stats case C('F'): // kmem stats
kmemprint(); kmemprint();
break; break;
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "vm.hh" #include "vm.hh"
#include "elf.hh" #include "elf.hh"
#include "cpu.hh" #include "cpu.hh"
#include "prof.hh"
#include "wq.hh" #include "wq.hh"
#include "cilk.hh" #include "cilk.hh"
...@@ -39,7 +38,6 @@ dosegment(struct eargs *args, u64 off) ...@@ -39,7 +38,6 @@ dosegment(struct eargs *args, u64 off)
uptr in_sz; uptr in_sz;
int npg; int npg;
prof_start(dosegment_prof);
if(readi(args->ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) if(readi(args->ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph))
goto bad; goto bad;
if(ph.type != ELF_PROG_LOAD) if(ph.type != ELF_PROG_LOAD)
...@@ -62,7 +60,6 @@ dosegment(struct eargs *args, u64 off) ...@@ -62,7 +60,6 @@ dosegment(struct eargs *args, u64 off)
if(args->vmap->insert(vmn, va_start, 1) < 0) if(args->vmap->insert(vmn, va_start, 1) < 0)
goto bad; goto bad;
prof_end(dosegment_prof);
return; return;
bad: bad:
...@@ -78,7 +75,6 @@ dostack(struct eargs *args) ...@@ -78,7 +75,6 @@ dostack(struct eargs *args)
uptr ustack[1+MAXARG+1]; uptr ustack[1+MAXARG+1];
const char *s, *last; const char *s, *last;
prof_start(dostack_prof);
// Allocate a one-page stack at the top of the (user) address space // Allocate a one-page stack at the top of the (user) address space
if((vmn = new vmnode(USTACKPAGES)) == 0) if((vmn = new vmnode(USTACKPAGES)) == 0)
goto bad; goto bad;
...@@ -98,7 +94,6 @@ dostack(struct eargs *args) ...@@ -98,7 +94,6 @@ dostack(struct eargs *args)
} }
ustack[1+argc] = 0; ustack[1+argc] = 0;
//prof_start(exec3_prof);
ustack[0] = 0xffffffffffffffffull; // fake return PC ustack[0] = 0xffffffffffffffffull; // fake return PC
args->proc->tf->rdi = argc; args->proc->tf->rdi = argc;
args->proc->tf->rsi = sp - (argc+1)*8; args->proc->tf->rsi = sp - (argc+1)*8;
...@@ -116,7 +111,6 @@ dostack(struct eargs *args) ...@@ -116,7 +111,6 @@ dostack(struct eargs *args)
safestrcpy(args->proc->name, last, sizeof(args->proc->name)); safestrcpy(args->proc->name, last, sizeof(args->proc->name));
args->proc->tf->rsp = sp; args->proc->tf->rsp = sp;
prof_end(dostack_prof);
return; return;
bad: bad:
...@@ -128,14 +122,12 @@ doheap(struct eargs *args) ...@@ -128,14 +122,12 @@ doheap(struct eargs *args)
{ {
struct vmnode *vmn = nullptr; struct vmnode *vmn = nullptr;
prof_start(doheap_prof);
// Allocate a vmnode for the heap. // Allocate a vmnode for the heap.
// XXX pre-allocate 32 pages.. // XXX pre-allocate 32 pages..
if((vmn = new vmnode(32)) == 0) if((vmn = new vmnode(32)) == 0)
goto bad; goto bad;
if(args->vmap->insert(vmn, BRK, 1) < 0) if(args->vmap->insert(vmn, BRK, 1) < 0)
goto bad; goto bad;
prof_end(doheap_prof);
return; return;
...@@ -154,7 +146,6 @@ exec(const char *path, char **argv) ...@@ -154,7 +146,6 @@ exec(const char *path, char **argv)
int i; int i;
struct vmap *oldvmap; struct vmap *oldvmap;
prof_start(exec_prof);
if((ip = namei(myproc()->cwd, path)) == 0) if((ip = namei(myproc()->cwd, path)) == 0)
return -1; return -1;
...@@ -218,7 +209,6 @@ exec(const char *path, char **argv) ...@@ -218,7 +209,6 @@ exec(const char *path, char **argv)
oldvmap->decref(); oldvmap->decref();
gc_end_epoch(); gc_end_epoch();
prof_end(exec_prof);
return 0; return 0;
bad: bad:
......
#include "types.h"
#include "kernel.hh"
#include "spinlock.h"
#include "condvar.h"
#include "fs.h"
#include "file.hh"
#include "prof.hh"
#include "bits.hh"
#include "amd64.h"
extern profctr_t sprof[];
extern profctr_t eprof[];
int profenable;
void
profreset(void)
{
profctr_t *p = sprof;
for (; p != eprof; p++) {
memset(p->rec, 0, sizeof(p->rec));
}
}
static void
profsum(struct profctr *ctr, u64 *tot, u64 *cnt)
{
for (int i = 0; i < NCPU; i++) {
*tot += ctr->rec[i].tot;
*cnt += ctr->rec[i].cnt;
}
}
void
profdump(void)
{
profctr_t *p = sprof;
for (; p != eprof; p++) {
u64 tot = 0, cnt = 0;
profsum(p, &tot, &cnt);
if (cnt)
cprintf("%s %lu\n", p->name, tot/cnt);
}
sampdump();
}
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论