diff options
author | Ian Moffett <ian@osmora.org> | 2025-08-12 22:06:41 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-08-12 22:08:22 -0400 |
commit | 49e744c65c8e3d2f72357f865dbd1908796950cf (patch) | |
tree | 61e51cc9a793a14a31c08334a10f5281fb8b03f5 | |
parent | 5db972de06d6aa805c2dd6e8b1789b659ae79fcd (diff) |
kernel: proc: Improve handling of 'nswitch'
- Extend 'nswitch' to 64-bits as it increments fast
- Ensure writes to 'nswitch' are atomic
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/arch/amd64/amd64/proc_machdep.c | 2 | ||||
-rw-r--r-- | sys/include/sys/sched.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c index ad807fe..a1d6563 100644 --- a/sys/arch/amd64/amd64/proc_machdep.c +++ b/sys/arch/amd64/amd64/proc_machdep.c @@ -256,7 +256,7 @@ sched_switch_to(struct trapframe *tf, struct proc *td) /* Update stats */ cpustat = &ci->stat; - cpustat->nswitch++; + atomic_inc_64(&cpustat->nswitch); ci->curtd = td; pcbp = &td->pcb; diff --git a/sys/include/sys/sched.h b/sys/include/sys/sched.h index 19ceb7e..8b0ba02 100644 --- a/sys/include/sys/sched.h +++ b/sys/include/sys/sched.h @@ -42,7 +42,7 @@ * @idle: Number of milliseconds idle */ struct sched_cpu { - uint32_t nswitch; + uint64_t nswitch; }; /* |