From c9003b50c37ae389c00c2c679ef66128e37bec89 Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 15 Oct 2024 12:26:53 +0000 Subject: [PATCH] Fix runtime calculation. Assiging ts to spc_runtime does not work if ts is modified. OK tb@ jca@ --- sys/kern/kern_resource.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index bd2c5468fba..56dc366f5e5 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.91 2024/10/08 11:57:59 claudio Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.92 2024/10/15 12:26:53 claudio Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -448,7 +448,7 @@ tuagg_add_runtime(void) { struct schedstate_percpu *spc = &curcpu()->ci_schedstate; struct proc *p = curproc; - struct timespec ts; + struct timespec ts, delta; /* * Compute the amount of time during which the current @@ -463,14 +463,14 @@ tuagg_add_runtime(void) (long long)spc->spc_runtime.tv_sec, spc->spc_runtime.tv_nsec); #endif - timespecclear(&ts); + timespecclear(&delta); } else { - timespecsub(&ts, &spc->spc_runtime, &ts); + timespecsub(&ts, &spc->spc_runtime, &delta); } /* update spc_runtime */ spc->spc_runtime = ts; tu_enter(&p->p_tu); - timespecadd(&p->p_tu.tu_runtime, &ts, &p->p_tu.tu_runtime); + timespecadd(&p->p_tu.tu_runtime, &delta, &p->p_tu.tu_runtime); tu_leave(&p->p_tu); } -- 2.20.1