fix _tos->pcycles, make _tos->kcycles actually count cycles executing kernel code on behalf of the process

This commit is contained in:
cinap_lenrek 2011-10-25 20:17:39 +02:00
parent 83865180a2
commit 3fce94e785
8 changed files with 45 additions and 13 deletions

View file

@ -50,7 +50,7 @@ kexit(Ureg*)
tos = (Tos*)(USTKTOP-sizeof(Tos));
t = fastticks(nil);
tos->kcycles += t - up->kentry;
tos->pcycles = up->pcycles;
tos->pcycles = t + up->pcycles;
tos->cyclefreq = Frequency;
tos->pid = up->pid;
@ -124,11 +124,16 @@ void
procsetup(Proc* p)
{
fpusysprocsetup(p);
cycles(&p->kentry);
p->pcycles = -p->kentry;
}
void
procfork(Proc *)
procfork(Proc* p)
{
p->kentry = up->kentry;
p->pcycles = -p->kentry;
}
/*
@ -141,6 +146,7 @@ procsave(Proc* p)
cycles(&t);
p->pcycles += t;
p->kentry -= t;
fpuprocsave(p);
}
@ -152,8 +158,10 @@ procrestore(Proc* p)
if(p->kp)
return;
t = lcycles();
cycles(&t);
p->pcycles -= t;
p->kentry += t;
fpuprocrestore(p);
}

View file

@ -50,7 +50,7 @@ kexit(Ureg*)
tos = (Tos*)(USTKTOP-sizeof(Tos));
cycles(&t);
tos->kcycles += t - up->kentry;
tos->pcycles = up->pcycles;
tos->pcycles = t + up->pcycles;
tos->cyclefreq = m->cpuhz;
tos->pid = up->pid;
@ -124,11 +124,16 @@ void
procsetup(Proc* p)
{
fpusysprocsetup(p);
cycles(&p->kentry);
p->pcycles = -p->kentry;
}
void
procfork(Proc*)
procfork(Proc* p)
{
p->kentry = up->kentry;
p->pcycles = -p->kentry;
}
/*
@ -141,6 +146,7 @@ procsave(Proc* p)
cycles(&t);
p->pcycles += t;
p->kentry -= t;
// TODO: save and restore VFPv3 FP state once 5[cal] know the new registers.
fpuprocsave(p);
@ -155,6 +161,7 @@ procrestore(Proc* p)
return;
cycles(&t);
p->pcycles -= t;
p->kentry += t;
fpuprocrestore(p);
}

View file

@ -124,7 +124,7 @@ updatetos(void)
tos = (Tos*) (USTKTOP - sizeof(Tos));
cycles(&t);
tos->kcycles += t - up->kentry;
tos->pcycles = up->pcycles;
tos->pcycles = t + up->pcycles;
tos->pid = up->pid;
}

View file

@ -580,11 +580,14 @@ mathinit(void)
* set up floating point for a new process
*/
void
procsetup(Proc*p)
procsetup(Proc *p)
{
p->fpstate = FPinit;
fpoff();
cycles(&p->kentry);
p->pcycles = -p->kentry;
memset(p->gdt, 0, sizeof(p->gdt));
p->ldt = nil;
p->nldt = 0;
@ -593,6 +596,9 @@ procsetup(Proc*p)
void
procfork(Proc *p)
{
p->kentry = up->kentry;
p->pcycles = -p->kentry;
/* inherit user descriptors */
memmove(p->gdt, up->gdt, sizeof(p->gdt));
@ -611,7 +617,9 @@ procrestore(Proc *p)
if(p->kp)
return;
cycles(&t);
p->kentry += t;
p->pcycles -= t;
}
@ -624,7 +632,9 @@ procsave(Proc *p)
uvlong t;
cycles(&t);
p->kentry -= t;
p->pcycles += t;
if(p->fpstate == FPactive){
if(p->state == Moribund)
fpclear();

View file

@ -299,7 +299,7 @@ kexit(Ureg*)
tos = (Tos*)(USTKTOP-sizeof(Tos));
cycles(&t);
tos->kcycles += t - up->kentry;
tos->pcycles = up->pcycles;
tos->pcycles = t + up->pcycles;
tos->pid = up->pid;
}

View file

@ -356,10 +356,10 @@ sysexec(ulong *arg)
*/
tos = (Tos*)(TSTKTOP - sizeof(Tos));
tos->cyclefreq = m->cyclefreq;
cycles((uvlong*)&tos->pcycles);
tos->pcycles = -tos->pcycles;
tos->kcycles = tos->pcycles;
tos->kcycles = 0;
tos->pcycles = 0;
tos->clock = 0;
argv = (char**)(TSTKTOP - ssize);
charp = (char*)(TSTKTOP - nbytes);
args = charp;

View file

@ -284,11 +284,16 @@ void
procsetup(Proc *p)
{
p->fpstate = FPinit;
cycles(&p->kentry);
p->pcycles = -p->kentry;
}
void
procfork(Proc *)
procfork(Proc *p)
{
p->kentry = up->kentry;
p->pcycles = -p->kentry;
}
void
@ -300,6 +305,7 @@ procrestore(Proc *p)
return;
cycles(&t);
p->pcycles -= t;
p->kentry += t;
}
/*
@ -312,6 +318,7 @@ procsave(Proc *p)
cycles(&t);
p->pcycles += t;
p->kentry -= t;
if(p->fpstate == FPactive){
if(p->state != Moribund)
fpsave(&up->fpsave);

View file

@ -150,7 +150,7 @@ kexit(Ureg*)
tos = (Tos*)(USTKTOP-sizeof(Tos));
cycles(&t);
tos->kcycles += t - up->kentry;
tos->pcycles = up->pcycles;
tos->pcycles = t + up->pcycles;
tos->pid = up->pid;
}