[PATCH] Make runqueues a per-cpu variable

From: Rusty Russell (rusty@rustcorp.com.au)
Date: Tue Jul 01 2003 - 00:49:55 EST

Linus, please apply.

Makes scheduler use per-cpu variables for the runqueues.

Name: Make Scheduler Use per-cpu
Author: Rusty Russell
Status: Tested on 2.5.73-bk8

D: Makes scheduler use per-cpu variables for the runqueues.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .27023-linux-2.5.73-bk4/kernel/sched.c .27023-linux-2.5.73-bk4.updated/kernel/sched.c
--- .27023-linux-2.5.73-bk4/kernel/sched.c 2003-06-27 12:48:17.000000000 +1000
+++ .27023-linux-2.5.73-bk4.updated/kernel/sched.c 2003-06-27 14:59:00.000000000 +1000
@@ -33,6 +33,7 @@
 #include <linux/timer.h>
 #include <linux/rcupdate.h>
 #include <linux/cpu.h>
+#include <linux/percpu.h>
 #define cpu_to_node_mask(cpu) node_to_cpumask(cpu_to_node(cpu))
@@ -170,12 +171,12 @@ struct runqueue {
         struct list_head migration_queue;
         atomic_t nr_iowait;
-} ____cacheline_aligned;
-static struct runqueue runqueues[NR_CPUS] __cacheline_aligned;
+static DEFINE_PER_CPU(struct runqueue, runqueues);
-#define cpu_rq(cpu) (runqueues + (cpu))
-#define this_rq() cpu_rq(smp_processor_id())
+#define cpu_rq(cpu) (&per_cpu(runqueues, (cpu)))
+#define this_rq() (&__get_cpu_var(runqueues))
 #define task_rq(p) cpu_rq(task_cpu(p))
 #define cpu_curr(cpu) (cpu_rq(cpu)->curr)
 #define rt_task(p) ((p)->prio < MAX_RT_PRIO)

  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

This archive was generated by hypermail 2b29 : Mon Jul 07 2003 - 22:00:12 EST