summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sched.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2013-04-19 21:44:08 +0000
committertedu <tedu@openbsd.org>2013-04-19 21:44:08 +0000
commit506dbbfd2880d0ba22b4b938ede106c69849a08d (patch)
tree21bbb46ef4c77533cf6b80bbcd78a2644b04940e /sys/kern/kern_sched.c
parentLog (at LOG_INFO) which interfaces dhcpd listens to and (as suggested by (diff)
downloadwireguard-openbsd-506dbbfd2880d0ba22b4b938ede106c69849a08d.tar.xz
wireguard-openbsd-506dbbfd2880d0ba22b4b938ede106c69849a08d.zip
sprinkle ifdef MP to disable cpu migration code when not needed.
ok deraadt
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r--sys/kern/kern_sched.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 253226a8b1b..40aa5c8c163 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.27 2012/07/10 18:20:37 kettenis Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.28 2013/04/19 21:44:08 tedu Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -315,6 +315,7 @@ again:
struct cpu_info *
sched_choosecpu_fork(struct proc *parent, int flags)
{
+#ifdef MULTIPROCESSOR
struct cpu_info *choice = NULL;
fixpt_t load, best_load = ~0;
int run, best_run = INT_MAX;
@@ -362,11 +363,15 @@ sched_choosecpu_fork(struct proc *parent, int flags)
}
return (choice);
+#else
+ return (curcpu());
+#endif
}
struct cpu_info *
sched_choosecpu(struct proc *p)
{
+#ifdef MULTIPROCESSOR
struct cpu_info *choice = NULL;
int last_cost = INT_MAX;
struct cpu_info *ci;
@@ -421,6 +426,9 @@ sched_choosecpu(struct proc *p)
sched_nomigrations++;
return (choice);
+#else
+ return (curcpu());
+#endif
}
/*
@@ -429,8 +437,9 @@ sched_choosecpu(struct proc *p)
struct proc *
sched_steal_proc(struct cpu_info *self)
{
- struct schedstate_percpu *spc;
struct proc *best = NULL;
+#ifdef MULTIPROCESSOR
+ struct schedstate_percpu *spc;
int bestcost = INT_MAX;
struct cpu_info *ci;
struct cpuset set;
@@ -469,10 +478,11 @@ sched_steal_proc(struct cpu_info *self)
best->p_cpu = self;
sched_stolen++;
-
+#endif
return (best);
}
+#ifdef MULTIPROCESSOR
/*
* Base 2 logarithm of an int. returns 0 for 0 (yeye, I know).
*/
@@ -502,18 +512,18 @@ int sched_cost_load = 1;
int sched_cost_priority = 1;
int sched_cost_runnable = 3;
int sched_cost_resident = 1;
+#endif
int
sched_proc_to_cpu_cost(struct cpu_info *ci, struct proc *p)
{
+ int cost = 0;
+#ifdef MULTIPROCESSOR
struct schedstate_percpu *spc;
int l2resident = 0;
- int cost;
spc = &ci->ci_schedstate;
- cost = 0;
-
/*
* First, account for the priority of the proc we want to move.
* More willing to move, the lower the priority of the destination
@@ -541,7 +551,7 @@ sched_proc_to_cpu_cost(struct cpu_info *ci, struct proc *p)
log2(pmap_resident_count(p->p_vmspace->vm_map.pmap));
cost -= l2resident * sched_cost_resident;
}
-
+#endif
return (cost);
}