diff options
author | jhb <jhb@FreeBSD.org> | 2005-12-22 22:16:09 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-12-22 22:16:09 +0000 |
commit | cb0d490ebe9e4d2fdb160451bfb076856c76f155 (patch) | |
tree | 5d9826b3ac47ed5cf683fc0866e2dc25566d6a56 /sys/kern/kern_clock.c | |
parent | fdec22285a69d07ca0d4320e306828b89e06a8dd (diff) | |
download | FreeBSD-src-cb0d490ebe9e4d2fdb160451bfb076856c76f155.zip FreeBSD-src-cb0d490ebe9e4d2fdb160451bfb076856c76f155.tar.gz |
Tweak how the MD code calls the fooclock() methods some. Instead of
passing a pointer to an opaque clockframe structure and requiring the
MD code to supply CLKF_FOO() macros to extract needed values out of the
opaque structure, just pass the needed values directly. In practice this
means passing the pair (usermode, pc) to hardclock() and profclock() and
passing the boolean (usermode) to hardclock_cpu() and hardclock_process().
Other details:
- Axe clockframe and CLKF_FOO() macros on all architectures. Basically,
all the archs were taking a trapframe and converting it into a clockframe
one way or another. Now they can just extract the PC and usermode values
directly out of the trapframe and pass it to fooclock().
- Renamed hardclock_process() to hardclock_cpu() as the latter is more
accurate.
- On Alpha, we now run profclock() at hz (profhz == hz) rather than at
the slower stathz.
- On Alpha, for the TurboLaser machines that don't have an 8254
timecounter, call hardclock() directly. This removes an extra
conditional check from every clock interrupt on Alpha on the BSP.
There is probably room for even further pruning here by changing Alpha
to use the simplified timecounter we use on x86 with the lapic timer
since we don't get interrupts from the 8254 on Alpha anyway.
- On x86, clkintr() shouldn't ever be called now unless using_lapic_timer
is false, so add a KASSERT() to that affect and remove a condition
to slightly optimize the non-lapic case.
- Change prototypeof arm_handler_execute() so that it's first arg is a
trapframe pointer rather than a void pointer for clarity.
- Use KCOUNT macro in profclock() to lookup the kernel profiling bucket.
Tested on: alpha, amd64, arm, i386, ia64, sparc64
Reviewed by: bde (mostly)
Diffstat (limited to 'sys/kern/kern_clock.c')
-rw-r--r-- | sys/kern/kern_clock.c | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 4ffa978..33336b9 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -65,8 +65,6 @@ __FBSDID("$FreeBSD$"); #include <sys/limits.h> #include <sys/timetc.h> -#include <machine/cpu.h> - #ifdef GPROF #include <sys/gmon.h> #endif @@ -189,12 +187,11 @@ initclocks(dummy) /* * Each time the real-time timer fires, this function is called on all CPUs. - * Note that hardclock() calls hardclock_process() for the boot CPU, so only + * Note that hardclock() calls hardclock_cpu() for the boot CPU, so only * the other CPUs in the system need to call this function. */ void -hardclock_process(frame) - register struct clockframe *frame; +hardclock_cpu(int usermode) { struct pstats *pstats; struct thread *td = curthread; @@ -208,7 +205,7 @@ hardclock_process(frame) /* XXXKSE What to do? */ } else { pstats = p->p_stats; - if (CLKF_USERMODE(frame) && + if (usermode && timevalisset(&pstats->p_timer[ITIMER_VIRTUAL].it_value) && itimerdecr(&pstats->p_timer[ITIMER_VIRTUAL], tick) == 0) { p->p_sflag |= PS_ALRMPEND; @@ -232,12 +229,11 @@ hardclock_process(frame) * The real-time timer, interrupting hz times per second. */ void -hardclock(frame) - register struct clockframe *frame; +hardclock(int usermode, uintfptr_t pc) { int need_softclock = 0; - hardclock_process(frame); + hardclock_cpu(usermode); tc_ticktock(); /* @@ -246,8 +242,8 @@ hardclock(frame) * XXX: this only works for UP */ if (stathz == 0) { - profclock(frame); - statclock(frame); + profclock(usermode, pc); + statclock(usermode); } #ifdef DEVICE_POLLING @@ -401,8 +397,7 @@ stopprofclock(p) * This should be called by all active processors. */ void -statclock(frame) - register struct clockframe *frame; +statclock(int usermode) { struct rusage *ru; struct vmspace *vm; @@ -414,7 +409,7 @@ statclock(frame) p = td->td_proc; mtx_lock_spin_flags(&sched_lock, MTX_QUIET); - if (CLKF_USERMODE(frame)) { + if (usermode) { /* * Charge the time as appropriate. */ @@ -473,8 +468,7 @@ statclock(frame) } void -profclock(frame) - register struct clockframe *frame; +profclock(int usermode, uintfptr_t pc) { struct thread *td; #ifdef GPROF @@ -483,7 +477,7 @@ profclock(frame) #endif td = curthread; - if (CLKF_USERMODE(frame)) { + if (usermode) { /* * Came from user mode; CPU was in user state. * If this process is being profiled, record the tick. @@ -491,7 +485,7 @@ profclock(frame) * bother trying to count it. */ if (td->td_proc->p_flag & P_PROFIL) - addupc_intr(td, CLKF_PC(frame), 1); + addupc_intr(td, pc, 1); } #ifdef GPROF else { @@ -499,11 +493,10 @@ profclock(frame) * Kernel statistics are just like addupc_intr, only easier. */ g = &_gmonparam; - if (g->state == GMON_PROF_ON && CLKF_PC(frame) >= g->lowpc) { - i = PC_TO_I(g, CLKF_PC(frame)); + if (g->state == GMON_PROF_ON && pc >= g->lowpc) { + i = PC_TO_I(g, pc); if (i < g->textsize) { - i /= HISTFRACTION * sizeof(*g->kcount); - g->kcount[i]++; + KCOUNT(g, i)++; } } } |