diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index cf9d6a8ef6f4..fdc1302429dd 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -483,7 +483,7 @@ hardclock(int usermode, uintfptr_t pc) } void -hardclock_anycpu(int cnt, int usermode) +hardclock_cnt(int cnt, int usermode) { struct pstats *pstats; struct thread *td = curthread; @@ -687,6 +687,13 @@ stopprofclock(p) */ void statclock(int usermode) +{ + + statclock_cnt(1, usermode); +} + +void +statclock_cnt(int cnt, int usermode) { struct rusage *ru; struct vmspace *vm; @@ -703,11 +710,11 @@ statclock(int usermode) /* * Charge the time as appropriate. */ - td->td_uticks++; + td->td_uticks += cnt; if (p->p_nice > NZERO) - cp_time[CP_NICE]++; + cp_time[CP_NICE] += cnt; else - cp_time[CP_USER]++; + cp_time[CP_USER] += cnt; } else { /* * Came from kernel mode, so we were: @@ -723,15 +730,15 @@ statclock(int usermode) */ if ((td->td_pflags & TDP_ITHREAD) || td->td_intr_nesting_level >= 2) { - td->td_iticks++; - cp_time[CP_INTR]++; + td->td_iticks += cnt; + cp_time[CP_INTR] += cnt; } else { - td->td_pticks++; - td->td_sticks++; + td->td_pticks += cnt; + td->td_sticks += cnt; if (!TD_IS_IDLETHREAD(td)) - cp_time[CP_SYS]++; + cp_time[CP_SYS] += cnt; else - cp_time[CP_IDLE]++; + cp_time[CP_IDLE] += cnt; } } @@ -739,21 +746,29 @@ statclock(int usermode) MPASS(p->p_vmspace != NULL); vm = p->p_vmspace; ru = &td->td_ru; - ru->ru_ixrss += pgtok(vm->vm_tsize); - ru->ru_idrss += pgtok(vm->vm_dsize); - ru->ru_isrss += pgtok(vm->vm_ssize); + ru->ru_ixrss += pgtok(vm->vm_tsize) * cnt; + ru->ru_idrss += pgtok(vm->vm_dsize) * cnt; + ru->ru_isrss += pgtok(vm->vm_ssize) * cnt; rss = pgtok(vmspace_resident_count(vm)); if (ru->ru_maxrss < rss) ru->ru_maxrss = rss; KTR_POINT2(KTR_SCHED, "thread", sched_tdname(td), "statclock", "prio:%d", td->td_priority, "stathz:%d", (stathz)?stathz:hz); thread_lock_flags(td, MTX_QUIET); - sched_clock(td); + for ( ; cnt > 0; cnt--) + sched_clock(td); thread_unlock(td); } void profclock(int usermode, uintfptr_t pc) +{ + + profclock_cnt(1, usermode, pc); +} + +void +profclock_cnt(int cnt, int usermode, uintfptr_t pc) { struct thread *td; #ifdef GPROF @@ -770,7 +785,7 @@ profclock(int usermode, uintfptr_t pc) * bother trying to count it. */ if (td->td_proc->p_flag & P_PROFIL) - addupc_intr(td, pc, 1); + addupc_intr(td, pc, cnt); } #ifdef GPROF else { @@ -781,7 +796,7 @@ profclock(int usermode, uintfptr_t pc) if (g->state == GMON_PROF_ON && pc >= g->lowpc) { i = PC_TO_I(g, pc); if (i < g->textsize) { - KCOUNT(g, i)++; + KCOUNT(g, i) += cnt; } } } diff --git a/sys/kern/kern_clocksource.c b/sys/kern/kern_clocksource.c index d94157cbdb0d..2217610e0de8 100644 --- a/sys/kern/kern_clocksource.c +++ b/sys/kern/kern_clocksource.c @@ -195,28 +195,34 @@ handleevents(struct bintime *now, int fake) pc = TRAPF_PC(frame); } - runs = 0; state = DPCPU_PTR(timerstate); + runs = 0; while (bintime_cmp(now, &state->nexthard, >=)) { bintime_add(&state->nexthard, &hardperiod); runs++; } if (runs && fake < 2) { - hardclock_anycpu(runs, usermode); + hardclock_cnt(runs, usermode); done = 1; } + runs = 0; while (bintime_cmp(now, &state->nextstat, >=)) { - if (fake < 2) - statclock(usermode); bintime_add(&state->nextstat, &statperiod); + runs++; + } + if (runs && fake < 2) { + statclock_cnt(runs, usermode); done = 1; } if (profiling) { + runs = 0; while (bintime_cmp(now, &state->nextprof, >=)) { - if (!fake) - profclock(usermode, pc); bintime_add(&state->nextprof, &profperiod); + runs++; + } + if (runs && !fake) { + profclock_cnt(runs, usermode, pc); done = 1; } } else diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 2773da80bd94..5375ec4f8993 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -247,12 +247,14 @@ void realitexpire(void *); int sysbeep(int hertz, int period); void hardclock(int usermode, uintfptr_t pc); -void hardclock_anycpu(int cnt, int usermode); +void hardclock_cnt(int cnt, int usermode); void hardclock_cpu(int usermode); void hardclock_sync(int cpu); void softclock(void *); void statclock(int usermode); +void statclock_cnt(int cnt, int usermode); void profclock(int usermode, uintfptr_t pc); +void profclock_cnt(int cnt, int usermode, uintfptr_t pc); int hardclockintr(void);