fix _tos->pcycles, make _tos->kcycles actually count cycles executing kernel code on behalf of the process
This commit is contained in:
parent
83865180a2
commit
3fce94e785
8 changed files with 45 additions and 13 deletions
|
@ -50,7 +50,7 @@ kexit(Ureg*)
|
||||||
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
||||||
t = fastticks(nil);
|
t = fastticks(nil);
|
||||||
tos->kcycles += t - up->kentry;
|
tos->kcycles += t - up->kentry;
|
||||||
tos->pcycles = up->pcycles;
|
tos->pcycles = t + up->pcycles;
|
||||||
tos->cyclefreq = Frequency;
|
tos->cyclefreq = Frequency;
|
||||||
tos->pid = up->pid;
|
tos->pid = up->pid;
|
||||||
|
|
||||||
|
@ -124,11 +124,16 @@ void
|
||||||
procsetup(Proc* p)
|
procsetup(Proc* p)
|
||||||
{
|
{
|
||||||
fpusysprocsetup(p);
|
fpusysprocsetup(p);
|
||||||
|
|
||||||
|
cycles(&p->kentry);
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procfork(Proc *)
|
procfork(Proc* p)
|
||||||
{
|
{
|
||||||
|
p->kentry = up->kentry;
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,6 +146,7 @@ procsave(Proc* p)
|
||||||
|
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
p->pcycles += t;
|
p->pcycles += t;
|
||||||
|
p->kentry -= t;
|
||||||
|
|
||||||
fpuprocsave(p);
|
fpuprocsave(p);
|
||||||
}
|
}
|
||||||
|
@ -152,8 +158,10 @@ procrestore(Proc* p)
|
||||||
|
|
||||||
if(p->kp)
|
if(p->kp)
|
||||||
return;
|
return;
|
||||||
t = lcycles();
|
|
||||||
|
cycles(&t);
|
||||||
p->pcycles -= t;
|
p->pcycles -= t;
|
||||||
|
p->kentry += t;
|
||||||
|
|
||||||
fpuprocrestore(p);
|
fpuprocrestore(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ kexit(Ureg*)
|
||||||
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
tos->kcycles += t - up->kentry;
|
tos->kcycles += t - up->kentry;
|
||||||
tos->pcycles = up->pcycles;
|
tos->pcycles = t + up->pcycles;
|
||||||
tos->cyclefreq = m->cpuhz;
|
tos->cyclefreq = m->cpuhz;
|
||||||
tos->pid = up->pid;
|
tos->pid = up->pid;
|
||||||
|
|
||||||
|
@ -124,11 +124,16 @@ void
|
||||||
procsetup(Proc* p)
|
procsetup(Proc* p)
|
||||||
{
|
{
|
||||||
fpusysprocsetup(p);
|
fpusysprocsetup(p);
|
||||||
|
|
||||||
|
cycles(&p->kentry);
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procfork(Proc*)
|
procfork(Proc* p)
|
||||||
{
|
{
|
||||||
|
p->kentry = up->kentry;
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,6 +146,7 @@ procsave(Proc* p)
|
||||||
|
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
p->pcycles += t;
|
p->pcycles += t;
|
||||||
|
p->kentry -= t;
|
||||||
|
|
||||||
// TODO: save and restore VFPv3 FP state once 5[cal] know the new registers.
|
// TODO: save and restore VFPv3 FP state once 5[cal] know the new registers.
|
||||||
fpuprocsave(p);
|
fpuprocsave(p);
|
||||||
|
@ -155,6 +161,7 @@ procrestore(Proc* p)
|
||||||
return;
|
return;
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
p->pcycles -= t;
|
p->pcycles -= t;
|
||||||
|
p->kentry += t;
|
||||||
|
|
||||||
fpuprocrestore(p);
|
fpuprocrestore(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ updatetos(void)
|
||||||
tos = (Tos*) (USTKTOP - sizeof(Tos));
|
tos = (Tos*) (USTKTOP - sizeof(Tos));
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
tos->kcycles += t - up->kentry;
|
tos->kcycles += t - up->kentry;
|
||||||
tos->pcycles = up->pcycles;
|
tos->pcycles = t + up->pcycles;
|
||||||
tos->pid = up->pid;
|
tos->pid = up->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -585,6 +585,9 @@ procsetup(Proc*p)
|
||||||
p->fpstate = FPinit;
|
p->fpstate = FPinit;
|
||||||
fpoff();
|
fpoff();
|
||||||
|
|
||||||
|
cycles(&p->kentry);
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
|
|
||||||
memset(p->gdt, 0, sizeof(p->gdt));
|
memset(p->gdt, 0, sizeof(p->gdt));
|
||||||
p->ldt = nil;
|
p->ldt = nil;
|
||||||
p->nldt = 0;
|
p->nldt = 0;
|
||||||
|
@ -593,6 +596,9 @@ procsetup(Proc*p)
|
||||||
void
|
void
|
||||||
procfork(Proc *p)
|
procfork(Proc *p)
|
||||||
{
|
{
|
||||||
|
p->kentry = up->kentry;
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
|
|
||||||
/* inherit user descriptors */
|
/* inherit user descriptors */
|
||||||
memmove(p->gdt, up->gdt, sizeof(p->gdt));
|
memmove(p->gdt, up->gdt, sizeof(p->gdt));
|
||||||
|
|
||||||
|
@ -611,7 +617,9 @@ procrestore(Proc *p)
|
||||||
|
|
||||||
if(p->kp)
|
if(p->kp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
|
p->kentry += t;
|
||||||
p->pcycles -= t;
|
p->pcycles -= t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +632,9 @@ procsave(Proc *p)
|
||||||
uvlong t;
|
uvlong t;
|
||||||
|
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
|
p->kentry -= t;
|
||||||
p->pcycles += t;
|
p->pcycles += t;
|
||||||
|
|
||||||
if(p->fpstate == FPactive){
|
if(p->fpstate == FPactive){
|
||||||
if(p->state == Moribund)
|
if(p->state == Moribund)
|
||||||
fpclear();
|
fpclear();
|
||||||
|
|
|
@ -299,7 +299,7 @@ kexit(Ureg*)
|
||||||
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
tos->kcycles += t - up->kentry;
|
tos->kcycles += t - up->kentry;
|
||||||
tos->pcycles = up->pcycles;
|
tos->pcycles = t + up->pcycles;
|
||||||
tos->pid = up->pid;
|
tos->pid = up->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,10 +356,10 @@ sysexec(ulong *arg)
|
||||||
*/
|
*/
|
||||||
tos = (Tos*)(TSTKTOP - sizeof(Tos));
|
tos = (Tos*)(TSTKTOP - sizeof(Tos));
|
||||||
tos->cyclefreq = m->cyclefreq;
|
tos->cyclefreq = m->cyclefreq;
|
||||||
cycles((uvlong*)&tos->pcycles);
|
tos->kcycles = 0;
|
||||||
tos->pcycles = -tos->pcycles;
|
tos->pcycles = 0;
|
||||||
tos->kcycles = tos->pcycles;
|
|
||||||
tos->clock = 0;
|
tos->clock = 0;
|
||||||
|
|
||||||
argv = (char**)(TSTKTOP - ssize);
|
argv = (char**)(TSTKTOP - ssize);
|
||||||
charp = (char*)(TSTKTOP - nbytes);
|
charp = (char*)(TSTKTOP - nbytes);
|
||||||
args = charp;
|
args = charp;
|
||||||
|
|
|
@ -284,11 +284,16 @@ void
|
||||||
procsetup(Proc *p)
|
procsetup(Proc *p)
|
||||||
{
|
{
|
||||||
p->fpstate = FPinit;
|
p->fpstate = FPinit;
|
||||||
|
|
||||||
|
cycles(&p->kentry);
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
procfork(Proc *)
|
procfork(Proc *p)
|
||||||
{
|
{
|
||||||
|
p->kentry = up->kentry;
|
||||||
|
p->pcycles = -p->kentry;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -300,6 +305,7 @@ procrestore(Proc *p)
|
||||||
return;
|
return;
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
p->pcycles -= t;
|
p->pcycles -= t;
|
||||||
|
p->kentry += t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -312,6 +318,7 @@ procsave(Proc *p)
|
||||||
|
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
p->pcycles += t;
|
p->pcycles += t;
|
||||||
|
p->kentry -= t;
|
||||||
if(p->fpstate == FPactive){
|
if(p->fpstate == FPactive){
|
||||||
if(p->state != Moribund)
|
if(p->state != Moribund)
|
||||||
fpsave(&up->fpsave);
|
fpsave(&up->fpsave);
|
||||||
|
|
|
@ -150,7 +150,7 @@ kexit(Ureg*)
|
||||||
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
tos = (Tos*)(USTKTOP-sizeof(Tos));
|
||||||
cycles(&t);
|
cycles(&t);
|
||||||
tos->kcycles += t - up->kentry;
|
tos->kcycles += t - up->kentry;
|
||||||
tos->pcycles = up->pcycles;
|
tos->pcycles = t + up->pcycles;
|
||||||
tos->pid = up->pid;
|
tos->pid = up->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue