From 7927db41a2d789927ae4967cdc221c4b69be78c4 Mon Sep 17 00:00:00 2001 From: claudio Date: Sat, 19 Aug 2023 11:14:11 +0000 Subject: [PATCH] Refetch the spc pointer after cpu_switchto() since the value is stale after the proc switch. With the value refetched the rest of the code can be simplified. Input guenther@, OK cheloha@, miod@ --- sys/kern/sched_bsd.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c index e06aa801d98..f9f2b7d76bd 100644 --- a/sys/kern/sched_bsd.c +++ b/sys/kern/sched_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sched_bsd.c,v 1.82 2023/08/18 09:18:52 claudio Exp $ */ +/* $OpenBSD: sched_bsd.c,v 1.83 2023/08/19 11:14:11 claudio Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /*- @@ -442,26 +442,23 @@ mi_switch(void) /* * We're running again; record our new start time. We might - * be running on a new CPU now, so don't use the cache'd - * schedstate_percpu pointer. + * be running on a new CPU now, so refetch the schedstate_percpu + * pointer. */ KASSERT(p->p_cpu == curcpu()); + spc = &p->p_cpu->ci_schedstate; /* Start any optional clock interrupts needed by the thread. */ if (ISSET(p->p_p->ps_flags, PS_ITIMER)) { - atomic_setbits_int(&p->p_cpu->ci_schedstate.spc_schedflags, - SPCF_ITIMER); - clockintr_advance(p->p_cpu->ci_schedstate.spc_itimer, - hardclock_period); + atomic_setbits_int(&spc->spc_schedflags, SPCF_ITIMER); + clockintr_advance(spc->spc_itimer, hardclock_period); } if (ISSET(p->p_p->ps_flags, PS_PROFIL)) { - atomic_setbits_int(&p->p_cpu->ci_schedstate.spc_schedflags, - SPCF_PROFCLOCK); - clockintr_advance(p->p_cpu->ci_schedstate.spc_profclock, - profclock_period); + atomic_setbits_int(&spc->spc_schedflags, SPCF_PROFCLOCK); + clockintr_advance(spc->spc_profclock, profclock_period); } - nanouptime(&p->p_cpu->ci_schedstate.spc_runtime); + nanouptime(&spc->spc_runtime); #ifdef MULTIPROCESSOR /* -- 2.20.1