From d624e113b0ce84e371a65fa5285d02714cfed918 Mon Sep 17 00:00:00 2001 From: cheloha Date: Tue, 25 Apr 2023 00:58:47 +0000 Subject: [PATCH] addupc_intr: support adding multiple profiling ticks at once Add a third parameter to addupc_intr(), "u_long nticks". This will allow us to credit more than one profiling tick to the thread at once. Should be useful in the unusual case where the clock interrupt is masked for an extended period. --- sys/kern/kern_clock.c | 6 +++--- sys/kern/subr_prof.c | 6 +++--- sys/sys/resourcevar.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 1265d740dea..4bc588d03ba 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.107 2023/03/03 20:16:44 cheloha Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.108 2023/04/25 00:58:47 cheloha Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -315,7 +315,7 @@ statclock(struct clockframe *frame) if (CLKF_USERMODE(frame)) { pr = p->p_p; if (pr->ps_flags & PS_PROFIL) - addupc_intr(p, CLKF_PC(frame)); + addupc_intr(p, CLKF_PC(frame), 1); if (--spc->spc_pscnt > 0) return; /* @@ -342,7 +342,7 @@ statclock(struct clockframe *frame) } #endif if (p != NULL && p->p_p->ps_flags & PS_PROFIL) - addupc_intr(p, PROC_PC(p)); + addupc_intr(p, PROC_PC(p), 1); if (--spc->spc_pscnt > 0) return; /* diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index 344af4e1c72..5f944cf6a4e 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_prof.c,v 1.31 2021/09/03 16:45:45 jasper Exp $ */ +/* $OpenBSD: subr_prof.c,v 1.32 2023/04/25 00:58:47 cheloha Exp $ */ /* $NetBSD: subr_prof.c,v 1.12 1996/04/22 01:38:50 christos Exp $ */ /*- @@ -269,7 +269,7 @@ sys_profil(struct proc *p, void *v, register_t *retval) * Trap will then call addupc_task(). */ void -addupc_intr(struct proc *p, u_long pc) +addupc_intr(struct proc *p, u_long pc, u_long nticks) { struct uprof *prof; @@ -278,7 +278,7 @@ addupc_intr(struct proc *p, u_long pc) return; /* out of range; ignore */ p->p_prof_addr = pc; - p->p_prof_ticks++; + p->p_prof_ticks += nticks; atomic_setbits_int(&p->p_flag, P_OWEUPC); need_proftick(p); } diff --git a/sys/sys/resourcevar.h b/sys/sys/resourcevar.h index 74b994e4db3..a17302d9338 100644 --- a/sys/sys/resourcevar.h +++ b/sys/sys/resourcevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: resourcevar.h,v 1.25 2022/03/18 14:45:39 visa Exp $ */ +/* $OpenBSD: resourcevar.h,v 1.26 2023/04/25 00:58:47 cheloha Exp $ */ /* $NetBSD: resourcevar.h,v 1.12 1995/11/22 23:01:53 cgd Exp $ */ /* @@ -60,7 +60,7 @@ do { \ #include /* for KASSERT() */ -void addupc_intr(struct proc *, u_long); +void addupc_intr(struct proc *, u_long, u_long); void addupc_task(struct proc *, u_long, u_int); void tuagg_unlocked(struct process *, struct proc *); void tuagg(struct process *, struct proc *); -- 2.20.1