summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2006-02-08 08:09:17 +0000
committerphk <phk@FreeBSD.org>2006-02-08 08:09:17 +0000
commit74f8e63a104485f17205e2a3e446e00f968c324c (patch)
treedcc7f358367ea74ccf47cede57e272875e9b589d /sys
parent4d8070a25b5c7585b416e8a3db16fc15f2e3cd13 (diff)
downloadFreeBSD-src-74f8e63a104485f17205e2a3e446e00f968c324c.zip
FreeBSD-src-74f8e63a104485f17205e2a3e446e00f968c324c.tar.gz
Simplify system time accounting for profiling.
Rename struct thread's td_sticks to td_pticks, we will need the other name for more appropriately named use shortly. Reduce it from uint64_t to u_int. Clear td_pticks whenever we enter the kernel instead of recording its value as reference for userret(). Use the absolute value of td->pticks in userret() and eliminate third argument.
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/alpha/trap.c11
-rw-r--r--sys/amd64/amd64/trap.c10
-rw-r--r--sys/amd64/ia32/ia32_syscall.c5
-rw-r--r--sys/arm/arm/trap.c23
-rw-r--r--sys/i386/i386/trap.c10
-rw-r--r--sys/ia64/ia32/ia32_trap.c5
-rw-r--r--sys/ia64/ia64/trap.c11
-rw-r--r--sys/kern/kern_clock.c2
-rw-r--r--sys/kern/kern_fork.c2
-rw-r--r--sys/kern/subr_trap.c14
-rw-r--r--sys/powerpc/aim/trap.c7
-rw-r--r--sys/powerpc/powerpc/trap.c7
-rw-r--r--sys/sparc64/sparc64/trap.c10
-rw-r--r--sys/sys/proc.h4
14 files changed, 49 insertions, 72 deletions
diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c
index 7d8f8bf..a3a47cd 100644
--- a/sys/alpha/alpha/trap.c
+++ b/sys/alpha/alpha/trap.c
@@ -259,7 +259,6 @@ trap(a0, a1, a2, entry, framep)
register struct proc *p;
register int i;
u_int64_t ucode;
- u_int sticks;
int user;
#ifdef SMP
register_t s;
@@ -302,12 +301,11 @@ trap(a0, a1, a2, entry, framep)
CTR5(KTR_TRAP, "%s trap: pid %d, (%lx, %lx, %lx)",
user ? "user" : "kernel", p->p_pid, a0, a1, a2);
if (user) {
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = framep;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
} else {
- sticks = 0; /* XXX bogus -Wuninitialized warning */
KASSERT(cold || td->td_ucred != NULL,
("kernel trap doesn't have ucred"));
}
@@ -595,7 +593,7 @@ trap(a0, a1, a2, entry, framep)
out:
if (user) {
framep->tf_regs[FRAME_SP] = alpha_pal_rdusp();
- userret(td, framep, sticks);
+ userret(td, framep);
mtx_assert(&Giant, MA_NOTOWNED);
}
return;
@@ -632,7 +630,6 @@ syscall(code, framep)
struct proc *p;
int error = 0;
u_int64_t opc;
- u_int sticks;
u_int64_t args[10]; /* XXX */
u_int hidden = 0, nargs;
#ifdef SMP
@@ -664,7 +661,7 @@ syscall(code, framep)
PCPU_LAZY_INC(cnt.v_syscall);
td->td_frame = framep;
opc = framep->tf_regs[FRAME_PC] - 4;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
if (p->p_flag & P_SA)
@@ -773,7 +770,7 @@ syscall(code, framep)
if ((callp->sy_narg & SYF_MPSAFE) == 0)
mtx_unlock(&Giant);
- userret(td, framep, sticks);
+ userret(td, framep);
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSRET))
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index d0d111b..7beea88 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -162,7 +162,6 @@ trap(frame)
{
struct thread *td = curthread;
struct proc *p = td->td_proc;
- u_int sticks = 0;
int i = 0, ucode = 0, type, code;
register_t addr = 0;
ksiginfo_t ksi;
@@ -254,7 +253,7 @@ trap(frame)
if (ISPL(frame.tf_cs) == SEL_UPL) {
/* user trap */
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = &frame;
addr = frame.tf_rip;
if (td->td_ucred != p->p_ucred)
@@ -524,7 +523,7 @@ trap(frame)
#endif
user:
- userret(td, &frame, sticks);
+ userret(td, &frame);
mtx_assert(&Giant, MA_NOTOWNED);
userout:
out:
@@ -731,7 +730,6 @@ syscall(frame)
struct thread *td = curthread;
struct proc *p = td->td_proc;
register_t orig_tf_rflags;
- u_int sticks;
int error;
int narg;
register_t args[8];
@@ -757,7 +755,7 @@ syscall(frame)
reg = 0;
regcnt = 6;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = &frame;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -885,7 +883,7 @@ syscall(frame)
/*
* Handle reschedule and other end-of-syscall issues
*/
- userret(td, &frame, sticks);
+ userret(td, &frame);
CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
td->td_proc->p_pid, td->td_proc->p_comm, code);
diff --git a/sys/amd64/ia32/ia32_syscall.c b/sys/amd64/ia32/ia32_syscall.c
index d8c16eb..8e67939 100644
--- a/sys/amd64/ia32/ia32_syscall.c
+++ b/sys/amd64/ia32/ia32_syscall.c
@@ -96,7 +96,6 @@ ia32_syscall(struct trapframe frame)
struct thread *td = curthread;
struct proc *p = td->td_proc;
register_t orig_tf_rflags;
- u_int sticks;
int error;
int narg;
u_int32_t args[8];
@@ -110,7 +109,7 @@ ia32_syscall(struct trapframe frame)
*/
PCPU_LAZY_INC(cnt.v_syscall);
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = &frame;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -241,7 +240,7 @@ ia32_syscall(struct trapframe frame)
/*
* Handle reschedule and other end-of-syscall issues
*/
- userret(td, &frame, sticks);
+ userret(td, &frame);
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSRET))
diff --git a/sys/arm/arm/trap.c b/sys/arm/arm/trap.c
index bfde9c6..2fc7205 100644
--- a/sys/arm/arm/trap.c
+++ b/sys/arm/arm/trap.c
@@ -234,7 +234,6 @@ data_abort_handler(trapframe_t *tf)
vm_prot_t ftype;
void *onfault;
vm_offset_t va;
- u_int sticks = 0;
int error = 0;
struct ksig ksig;
struct proc *p;
@@ -261,7 +260,8 @@ data_abort_handler(trapframe_t *tf)
user = TRAP_USERMODE(tf);
if (user) {
- sticks = td->td_sticks; td->td_frame = tf;
+ td->td_pticks = 0;
+ td->td_frame = tf;
if (td->td_ucred != td->td_proc->p_ucred)
cred_update_thread(td);
if (td->td_pflags & TDP_SA)
@@ -465,7 +465,7 @@ do_trapsignal:
out:
/* If returning to user mode, make sure to invoke userret() */
if (user)
- userret(td, tf, sticks);
+ userret(td, tf);
}
/*
@@ -707,7 +707,6 @@ prefetch_abort_handler(trapframe_t *tf)
struct vm_map *map;
vm_offset_t fault_pc, va;
int error = 0;
- u_int sticks = 0;
struct ksig ksig;
@@ -754,7 +753,7 @@ prefetch_abort_handler(trapframe_t *tf)
/* Prefetch aborts cannot happen in kernel mode */
if (__predict_false(!TRAP_USERMODE(tf)))
dab_fatal(tf, 0, tf->tf_pc, NULL, &ksig);
- sticks = td->td_sticks;
+ td->td_pticks = 0;
/* Ok validate the address, can only execute in USER space */
@@ -809,7 +808,7 @@ do_trapsignal:
call_trapsignal(td, ksig.signb, ksig.code);
out:
- userret(td, tf, sticks);
+ userret(td, tf);
}
@@ -871,10 +870,9 @@ syscall(struct thread *td, trapframe_t *frame, u_int32_t insn)
register_t *ap, *args, copyargs[MAXARGS];
struct sysent *callp;
int locked = 0;
- u_int sticks = 0;
PCPU_LAZY_INC(cnt.v_syscall);
- sticks = td->td_sticks;
+ td->td_pticks = 0;
if (td->td_ucred != td->td_proc->p_ucred)
cred_update_thread(td);
switch (insn & SWI_OS_MASK) {
@@ -883,11 +881,11 @@ syscall(struct thread *td, trapframe_t *frame, u_int32_t insn)
break;
default:
call_trapsignal(td, SIGILL, 0);
- userret(td, frame, td->td_sticks);
+ userret(td, frame);
return;
}
code = insn & 0x000fffff;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
ap = &frame->tf_r0;
if (code == SYS_syscall) {
code = *ap++;
@@ -973,7 +971,7 @@ bad:
mtx_unlock(&Giant);
- userret(td, frame, sticks);
+ userret(td, frame);
CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
td->td_proc->p_pid, td->td_proc->p_comm, code);
@@ -995,6 +993,7 @@ swi_handler(trapframe_t *frame)
td->td_frame = frame;
+ td->td_pticks = 0;
if (td->td_proc->p_flag & P_SA)
thread_user_enter(td);
/*
@@ -1003,7 +1002,7 @@ swi_handler(trapframe_t *frame)
*/
if (__predict_false(((frame->tf_pc - INSN_SIZE) & 3) != 0)) {
call_trapsignal(td, SIGILL, 0);
- userret(td, frame, td->td_sticks);
+ userret(td, frame);
return;
}
insn = *(u_int32_t *)(frame->tf_pc - INSN_SIZE);
diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c
index 6bf16c2..6e1aec2 100644
--- a/sys/i386/i386/trap.c
+++ b/sys/i386/i386/trap.c
@@ -176,7 +176,6 @@ trap(frame)
{
struct thread *td = curthread;
struct proc *p = td->td_proc;
- u_int sticks = 0;
int i = 0, ucode = 0, type, code;
register_t addr = 0;
vm_offset_t eva;
@@ -287,7 +286,7 @@ trap(frame)
!(PCPU_GET(curpcb)->pcb_flags & PCB_VM86CALL))) {
/* user trap */
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = &frame;
addr = frame.tf_eip;
if (td->td_ucred != p->p_ucred)
@@ -684,7 +683,7 @@ trap(frame)
#endif
user:
- userret(td, &frame, sticks);
+ userret(td, &frame);
mtx_assert(&Giant, MA_NOTOWNED);
userout:
out:
@@ -914,7 +913,6 @@ syscall(frame)
struct thread *td = curthread;
struct proc *p = td->td_proc;
register_t orig_tf_eflags;
- u_int sticks;
int error;
int narg;
int args[8];
@@ -936,7 +934,7 @@ syscall(frame)
}
#endif
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = &frame;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -1070,7 +1068,7 @@ syscall(frame)
/*
* Handle reschedule and other end-of-syscall issues
*/
- userret(td, &frame, sticks);
+ userret(td, &frame);
CTR4(KTR_SYSC, "syscall exit thread %p pid %d proc %s code %d", td,
td->td_proc->p_pid, td->td_proc->p_comm, code);
diff --git a/sys/ia64/ia32/ia32_trap.c b/sys/ia64/ia32/ia32_trap.c
index d93722e..29357f1 100644
--- a/sys/ia64/ia32/ia32_trap.c
+++ b/sys/ia64/ia32/ia32_trap.c
@@ -205,7 +205,6 @@ ia32_trap(int vector, struct trapframe *tf)
struct thread *td;
uint64_t ucode;
int sig;
- u_int sticks;
ksiginfo_t ksi;
KASSERT(TRAPF_USERMODE(tf), ("%s: In kernel mode???", __func__));
@@ -215,7 +214,7 @@ ia32_trap(int vector, struct trapframe *tf)
td = curthread;
td->td_frame = tf;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
p = td->td_proc;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -297,7 +296,7 @@ ia32_trap(int vector, struct trapframe *tf)
trapsignal(td, &ksi);
out:
- userret(td, tf, sticks);
+ userret(td, tf);
mtx_assert(&Giant, MA_NOTOWNED);
do_ast(tf);
}
diff --git a/sys/ia64/ia64/trap.c b/sys/ia64/ia64/trap.c
index 432ac69..96c03de 100644
--- a/sys/ia64/ia64/trap.c
+++ b/sys/ia64/ia64/trap.c
@@ -360,7 +360,6 @@ trap(int vector, struct trapframe *tf)
struct thread *td;
uint64_t ucode;
int error, sig, user;
- u_int sticks;
ksiginfo_t ksi;
user = TRAPF_USERMODE(tf) ? 1 : 0;
@@ -373,12 +372,11 @@ trap(int vector, struct trapframe *tf)
if (user) {
ia64_set_fpsr(IA64_FPSR_DEFAULT);
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = tf;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
} else {
- sticks = 0; /* XXX bogus -Wuninitialized warning */
KASSERT(cold || td->td_ucred != NULL,
("kernel trap doesn't have ucred"));
#ifdef KDB
@@ -877,7 +875,7 @@ trap(int vector, struct trapframe *tf)
out:
if (user) {
- userret(td, tf, sticks);
+ userret(td, tf);
mtx_assert(&Giant, MA_NOTOWNED);
do_ast(tf);
}
@@ -943,7 +941,6 @@ syscall(struct trapframe *tf)
struct thread *td;
uint64_t *args;
int code, error;
- u_int sticks;
ia64_set_fpsr(IA64_FPSR_DEFAULT);
@@ -956,7 +953,7 @@ syscall(struct trapframe *tf)
td->td_frame = tf;
p = td->td_proc;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
if (p->p_flag & P_SA)
@@ -1030,7 +1027,7 @@ syscall(struct trapframe *tf)
}
}
- userret(td, tf, sticks);
+ userret(td, tf);
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSRET))
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index 33336b9..0316c3e 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -440,7 +440,7 @@ statclock(int usermode)
} else {
if (p->p_flag & P_SA)
thread_statclock(0);
- td->td_sticks++;
+ td->td_pticks++;
p->p_rux.rux_sticks++;
if (td != PCPU_GET(idlethread))
cp_time[CP_SYS]++;
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index bbaac6c..dfbd315 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -825,7 +825,7 @@ fork_return(td, frame)
struct trapframe *frame;
{
- userret(td, frame, 0);
+ userret(td, frame);
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSRET))
ktrsysret(SYS_fork, 0, 0);
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index f4e0a53..686f613 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -74,10 +74,7 @@ __FBSDID("$FreeBSD$");
* MPSAFE
*/
void
-userret(td, frame, oticks)
- struct thread *td;
- struct trapframe *frame;
- u_int oticks;
+userret(struct thread *td, struct trapframe *frame)
{
struct proc *p = td->td_proc;
@@ -127,10 +124,8 @@ userret(td, frame, oticks)
* Charge system time if profiling.
*/
if (p->p_flag & P_PROFIL) {
- quad_t ticks;
- ticks = td->td_sticks - oticks;
- addupc_task(td, TRAPF_PC(frame), (u_int)ticks * psratio);
+ addupc_task(td, TRAPF_PC(frame), td->td_pticks * psratio);
}
/*
@@ -153,7 +148,6 @@ ast(struct trapframe *framep)
struct proc *p;
struct ksegrp *kg;
struct rlimit rlim;
- u_int sticks;
int sflag;
int flags;
int sig;
@@ -173,7 +167,7 @@ ast(struct trapframe *framep)
mtx_assert(&Giant, MA_NOTOWNED);
mtx_assert(&sched_lock, MA_NOTOWNED);
td->td_frame = framep;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
if ((p->p_flag & P_SA) && (td->td_mailbox == NULL))
thread_user_enter(td);
@@ -276,6 +270,6 @@ ast(struct trapframe *framep)
PROC_UNLOCK(p);
}
- userret(td, framep, sticks);
+ userret(td, framep);
mtx_assert(&Giant, MA_NOTOWNED);
}
diff --git a/sys/powerpc/aim/trap.c b/sys/powerpc/aim/trap.c
index 72da805..7d3deba 100644
--- a/sys/powerpc/aim/trap.c
+++ b/sys/powerpc/aim/trap.c
@@ -143,7 +143,7 @@ trap(struct trapframe *frame)
struct thread *td;
struct proc *p;
int sig, type, user;
- u_int sticks, ucode;
+ u_int ucode;
ksiginfo_t ksi;
PCPU_LAZY_INC(cnt.v_trap);
@@ -154,13 +154,12 @@ trap(struct trapframe *frame)
type = ucode = frame->exc;
sig = 0;
user = frame->srr1 & PSL_PR;
- sticks = 0;
CTR3(KTR_TRAP, "trap: %s type=%s (%s)", p->p_comm,
trapname(type), user ? "user" : "kernel");
if (user) {
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = frame;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -263,7 +262,7 @@ trap(struct trapframe *frame)
trapsignal(td, &ksi);
}
- userret(td, frame, sticks);
+ userret(td, frame);
mtx_assert(&Giant, MA_NOTOWNED);
}
diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c
index 72da805..7d3deba 100644
--- a/sys/powerpc/powerpc/trap.c
+++ b/sys/powerpc/powerpc/trap.c
@@ -143,7 +143,7 @@ trap(struct trapframe *frame)
struct thread *td;
struct proc *p;
int sig, type, user;
- u_int sticks, ucode;
+ u_int ucode;
ksiginfo_t ksi;
PCPU_LAZY_INC(cnt.v_trap);
@@ -154,13 +154,12 @@ trap(struct trapframe *frame)
type = ucode = frame->exc;
sig = 0;
user = frame->srr1 & PSL_PR;
- sticks = 0;
CTR3(KTR_TRAP, "trap: %s type=%s (%s)", p->p_comm,
trapname(type), user ? "user" : "kernel");
if (user) {
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = frame;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -263,7 +262,7 @@ trap(struct trapframe *frame)
trapsignal(td, &ksi);
}
- userret(td, frame, sticks);
+ userret(td, frame);
mtx_assert(&Giant, MA_NOTOWNED);
}
diff --git a/sys/sparc64/sparc64/trap.c b/sys/sparc64/sparc64/trap.c
index fb67479..c38f72a 100644
--- a/sys/sparc64/sparc64/trap.c
+++ b/sys/sparc64/sparc64/trap.c
@@ -230,7 +230,6 @@ trap(struct trapframe *tf)
{
struct thread *td;
struct proc *p;
- u_int sticks;
int error;
int sig;
ksiginfo_t ksi;
@@ -248,7 +247,7 @@ trap(struct trapframe *tf)
KASSERT(td->td_proc != NULL, ("trap: curproc NULL"));
p = td->td_proc;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = tf;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -293,7 +292,7 @@ trap(struct trapframe *tf)
trapsignal(td, &ksi);
}
- userret(td, tf, sticks);
+ userret(td, tf);
mtx_assert(&Giant, MA_NOTOWNED);
} else {
KASSERT((tf->tf_type & T_KERNEL) != 0,
@@ -502,7 +501,6 @@ syscall(struct trapframe *tf)
register_t args[8];
register_t *argp;
struct proc *p;
- u_int sticks;
u_long code;
u_long tpc;
int reg;
@@ -523,7 +521,7 @@ syscall(struct trapframe *tf)
reg = 0;
regcnt = REG_MAXARGS;
- sticks = td->td_sticks;
+ td->td_pticks = 0;
td->td_frame = tf;
if (td->td_ucred != p->p_ucred)
cred_update_thread(td);
@@ -646,7 +644,7 @@ syscall(struct trapframe *tf)
/*
* Handle reschedule and other end-of-syscall issues
*/
- userret(td, tf, sticks);
+ userret(td, tf);
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSRET))
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index d2a0727..3643672 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -282,7 +282,7 @@ struct thread {
struct ucred *td_ucred; /* (k) Reference to credentials. */
struct thread *td_standin; /* (k + a) Use this for an upcall. */
struct kse_upcall *td_upcall; /* (k + j) Upcall structure. */
- u_int64_t td_sticks; /* (k) Statclock hits in system mode. */
+ u_int td_pticks; /* (k) Statclock hits for profiling */
u_int td_uuticks; /* (k) Statclock hits (usr), for UTS. */
u_int td_usticks; /* (k) Statclock hits (sys), for UTS. */
int td_intrval; /* (j) Return value of TDF_INTERRUPT. */
@@ -902,7 +902,7 @@ extern void (*cpu_idle_hook)(void); /* Hook to machdep CPU idler. */
void cpu_switch(struct thread *old, struct thread *new);
void cpu_throw(struct thread *old, struct thread *new) __dead2;
void unsleep(struct thread *);
-void userret(struct thread *, struct trapframe *, u_int);
+void userret(struct thread *, struct trapframe *);
void cpu_exit(struct thread *);
void exit1(struct thread *, int) __dead2;
OpenPOWER on IntegriCloud