On Wed, Apr 17, 2013 at 15:39, Ted Unangst wrote:
> Some functions dealing with pegging procs to CPUs and migration costs
> are only meaningful if we are running a multiprocessor kernel. Leave
> dummy versions in to avoid ifdef mazes elsewhere.

Here's a variant that covers a bit more code, by stubbing out function
bodies where they aren't needed.

Index: kern_sched.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_sched.c,v
retrieving revision 1.27
diff -u -p -r1.27 kern_sched.c
--- kern_sched.c        10 Jul 2012 18:20:37 -0000      1.27
+++ kern_sched.c        15 Apr 2013 11:57:05 -0000
@@ -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
        }
 
        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 *
                    log2(pmap_resident_count(p->p_vmspace->vm_map.pmap));
                cost -= l2resident * sched_cost_resident;
        }
-
+#endif
        return (cost);
 }
 

Reply via email to