summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sched.c
diff options
context:
space:
mode:
authorart <art@openbsd.org>2009-04-20 08:48:17 +0000
committerart <art@openbsd.org>2009-04-20 08:48:17 +0000
commit25a90001359e034406cc5220b299558bbb680c74 (patch)
tree8c4e84c8cd78bcc099a51ba05c0a0a57cfbbb6f5 /sys/kern/kern_sched.c
parentrestore tagged user packages to functionality (for now) (diff)
downloadwireguard-openbsd-25a90001359e034406cc5220b299558bbb680c74.tar.xz
wireguard-openbsd-25a90001359e034406cc5220b299558bbb680c74.zip
Make pegging a proc work when there are idle cpus that are looking for
something to do. Walk the highest priority queue looking for a proc to steal and skip those that are pegged. We could consider walking the other queues in the future too, but this should do for now. kettenis@ guenther@ ok
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r--sys/kern/kern_sched.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 7205832b79f..f7b58cd0b43 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.11 2009/04/14 09:13:25 art Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.12 2009/04/20 08:48:17 art Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -407,19 +407,24 @@ sched_steal_proc(struct cpu_info *self)
while ((ci = cpuset_first(&set)) != NULL) {
struct proc *p;
+ int queue;
int cost;
cpuset_del(&set, ci);
spc = &ci->ci_schedstate;
- p = TAILQ_FIRST(&spc->spc_qs[ffs(spc->spc_whichqs) - 1]);
- KASSERT(p);
- cost = sched_proc_to_cpu_cost(self, p);
+ queue = ffs(spc->spc_whichqs) - 1;
+ TAILQ_FOREACH(p, &spc->spc_qs[queue], p_runq) {
+ if (p->p_flag & P_CPUPEG)
+ continue;
- if (best == NULL || cost < bestcost) {
- best = p;
- bestcost = cost;
+ cost = sched_proc_to_cpu_cost(self, p);
+
+ if (best == NULL || cost < bestcost) {
+ best = p;
+ bestcost = cost;
+ }
}
}
if (best == NULL)