Remove obsolete profiling code

上级 a7d6a3f6
......@@ -56,4 +56,3 @@
$ apt-get install libjemalloc-dev
$ make HW=user o.user/utest
......@@ -194,11 +194,6 @@ void yield(void);
struct proc* threadalloc(void (*fn)(void*), void *arg);
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
void sampstart(void);
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 = \
picirq.o \
pipe.o \
proc.o \
prof.o \
gc.o \
rnd.o \
sampler.o \
......
......@@ -270,18 +270,6 @@ consoleintr(int (*getc)(void))
case C('W'):
wq_dump();
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
kmemprint();
break;
......
......@@ -12,7 +12,6 @@
#include "vm.hh"
#include "elf.hh"
#include "cpu.hh"
#include "prof.hh"
#include "wq.hh"
#include "cilk.hh"
......@@ -39,7 +38,6 @@ dosegment(struct eargs *args, u64 off)
uptr in_sz;
int npg;
prof_start(dosegment_prof);
if(readi(args->ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph))
goto bad;
if(ph.type != ELF_PROG_LOAD)
......@@ -62,7 +60,6 @@ dosegment(struct eargs *args, u64 off)
if(args->vmap->insert(vmn, va_start, 1) < 0)
goto bad;
prof_end(dosegment_prof);
return;
bad:
......@@ -78,7 +75,6 @@ dostack(struct eargs *args)
uptr ustack[1+MAXARG+1];
const char *s, *last;
prof_start(dostack_prof);
// Allocate a one-page stack at the top of the (user) address space
if((vmn = new vmnode(USTACKPAGES)) == 0)
goto bad;
......@@ -98,7 +94,6 @@ dostack(struct eargs *args)
}
ustack[1+argc] = 0;
//prof_start(exec3_prof);
ustack[0] = 0xffffffffffffffffull; // fake return PC
args->proc->tf->rdi = argc;
args->proc->tf->rsi = sp - (argc+1)*8;
......@@ -116,7 +111,6 @@ dostack(struct eargs *args)
safestrcpy(args->proc->name, last, sizeof(args->proc->name));
args->proc->tf->rsp = sp;
prof_end(dostack_prof);
return;
bad:
......@@ -128,14 +122,12 @@ doheap(struct eargs *args)
{
struct vmnode *vmn = nullptr;
prof_start(doheap_prof);
// Allocate a vmnode for the heap.
// XXX pre-allocate 32 pages..
if((vmn = new vmnode(32)) == 0)
goto bad;
if(args->vmap->insert(vmn, BRK, 1) < 0)
goto bad;
prof_end(doheap_prof);
return;
......@@ -154,7 +146,6 @@ exec(const char *path, char **argv)
int i;
struct vmap *oldvmap;
prof_start(exec_prof);
if((ip = namei(myproc()->cwd, path)) == 0)
return -1;
......@@ -218,7 +209,6 @@ exec(const char *path, char **argv)
oldvmap->decref();
gc_end_epoch();
prof_end(exec_prof);
return 0;
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论