summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2019-01-28 11:48:13 +0000
committermpi <mpi@openbsd.org>2019-01-28 11:48:13 +0000
commit56497060ba0a309af7ab87135350e84ae2143cd7 (patch)
tree4cd96a541fdf17d3bcc5f89516695c5e40ff18f5
parentImplement breaking into ddb on imxuart(4). When a break is detected, (diff)
downloadwireguard-openbsd-56497060ba0a309af7ab87135350e84ae2143cd7.tar.xz
wireguard-openbsd-56497060ba0a309af7ab87135350e84ae2143cd7.zip
Stop accounting/updating priorities for Idle threads.
Idle threads are never placed on the runqueue so their priority doesn't matter. This fixes an accounting bug where top(1) would report a high CPU usage for Idle threads of secondary CPUs right after booting. That's because schedcpu() would give 100% CPU time to the Idle thread until "real" threads get scheduled on the corresponding CPU. Issue reported by bluhm@, ok visa@, kettenis@
-rw-r--r--sys/kern/sched_bsd.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/sched_bsd.c b/sys/kern/sched_bsd.c
index 1fa5d319988..635f10664a5 100644
--- a/sys/kern/sched_bsd.c
+++ b/sys/kern/sched_bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched_bsd.c,v 1.48 2019/01/06 12:59:45 visa Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.49 2019/01/28 11:48:13 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@@ -218,6 +218,13 @@ schedcpu(void *arg)
LIST_FOREACH(p, &allproc, p_list) {
/*
+ * Idle threads are never placed on the runqueue,
+ * therefore computing their priority is pointless.
+ */
+ if (p->p_cpu != NULL &&
+ p->p_cpu->ci_schedstate.spc_idleproc == p)
+ continue;
+ /*
* Increment sleep time (if sleeping). We ignore overflow.
*/
if (p->p_stat == SSLEEP || p->p_stat == SSTOP)
@@ -528,8 +535,13 @@ resetpriority(struct proc *p)
void
schedclock(struct proc *p)
{
+ struct cpu_info *ci = curcpu();
+ struct schedstate_percpu *spc = &ci->ci_schedstate;
int s;
+ if (p == spc->spc_idleproc)
+ return;
+
SCHED_LOCK(s);
p->p_estcpu = ESTCPULIM(p->p_estcpu + 1);
resetpriority(p);