diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-20 22:34:41 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-12-20 22:34:41 +0100 |
commit | e4ce6aadac9e1de8d5ea625e9680d24cabce0e1a (patch) | |
tree | 63c0b00f6f2c8eac29d4a0354d402206bc61397a /sys/src/9/xen | |
parent | 08c1622b0d8de92c2650d7b0338d9abf20985827 (diff) |
kernel: handle tos and per process pcycle counters in port/
we might as well handle the per process cycle
counter in the portable part instead of duplicating the code
in every arch and have inconsistent implementations.
we now have a portable kenter() and kexit() function,
that is ment to be used in trap/syscall from user,
which updates the counters.
some kernels missed initializing Mach.cyclefreq.
Diffstat (limited to 'sys/src/9/xen')
-rw-r--r-- | sys/src/9/xen/main.c | 13 | ||||
-rw-r--r-- | sys/src/9/xen/trap.c | 43 |
2 files changed, 4 insertions, 52 deletions
diff --git a/sys/src/9/xen/main.c b/sys/src/9/xen/main.c index 76bdfe2f5..9d0b32ca1 100644 --- a/sys/src/9/xen/main.c +++ b/sys/src/9/xen/main.c @@ -337,9 +337,6 @@ procfork(Proc *p) { int s; - p->kentry = up->kentry; - p->pcycles = -p->kentry; - /* save floating point state */ s = splhi(); switch(up->fpstate & ~FPillegal){ @@ -358,12 +355,6 @@ procfork(Proc *p) void procrestore(Proc *p) { - uvlong t; - - if(p->kp) - return; - cycles(&t); - p->pcycles -= t; } /* @@ -372,10 +363,6 @@ procrestore(Proc *p) void procsave(Proc *p) { - uvlong t; - - cycles(&t); - p->pcycles += t; if(p->fpstate == FPactive){ if(p->state == Moribund) fpclear(); diff --git a/sys/src/9/xen/trap.c b/sys/src/9/xen/trap.c index 0ed66fbd4..72f7e98eb 100644 --- a/sys/src/9/xen/trap.c +++ b/sys/src/9/xen/trap.c @@ -134,22 +134,6 @@ usertrap(int vno) return 0; } -/* go to user space */ -void -kexit(Ureg*) -{ - uvlong t; - Tos *tos; - - /* precise time accounting, kernel exit */ - tos = (Tos*)(USTKTOP-sizeof(Tos)); - cycles(&t); - tos->kcycles += t - up->kentry; - tos->pcycles = up->pcycles; - tos->pid = up->pid; - INTRLOG(dprint("leave kexit, TOS %p\n", tos);) -} - /* * All traps come here. It is slower to have all traps call trap() * rather than directly vectoring the handler. However, this avoids a @@ -162,12 +146,7 @@ trap(Ureg* ureg) { int vno, user; - user = userureg(ureg); - if(user){ - up->dbgreg = ureg; - cycles(&up->kentry); - } - + user = kenter(ureg); vno = ureg->trap; if(!irqhandled(ureg, vno) && (!user || !usertrap(vno))){ if(!user){ @@ -406,15 +385,12 @@ syscall(Ureg* ureg) SYSCALLLOG(dprint("%d: syscall ...#%ld(%s)\n", up->pid, ureg->ax, sysctab[ureg->ax]);) - if((ureg->cs & 0xFFFF) != UESEL) + if(!kenter(ureg)) panic("syscall: cs 0x%4.4luX\n", ureg->cs); - cycles(&up->kentry); - m->syscall++; up->insyscall = 1; up->pc = ureg->pc; - up->dbgreg = ureg; if(up->procctl == Proc_tracesyscall){ up->procctl = Proc_stopme; @@ -725,27 +701,16 @@ setregisters(Ureg* ureg, char* pureg, char* uva, int n) ureg->ss = ss; } -static void -linkproc(void) -{ - spllo(); - up->kpfun(up->kparg); - pexit("kproc dying", 0); -} - void -kprocchild(Proc* p, void (*func)(void*), void* arg) +kprocchild(Proc *p, void (*entry)(void)) { /* * gotolabel() needs a word on the stack in * which to place the return PC used to jump * to linkproc(). */ - p->sched.pc = (ulong)linkproc; + p->sched.pc = (ulong)entry; p->sched.sp = (ulong)p->kstack+KSTACK-BY2WD; - - p->kpfun = func; - p->kparg = arg; } void |