Add prefetch switch stack hook in scheduler function

From: Chen, Kenneth W
Date: Wed Jul 27 2005 - 17:12:34 EST

I would like to propose adding a prefetch switch stack hook in
the scheduler function. For architecture like ia64, the switch
stack structure is fairly large (currently 528 bytes). For context
switch intensive application, we found that significant amount of
cache misses occurs in switch_to() function. The following patch
adds a hook in the schedule() function to prefetch switch stack
structure as soon as 'next' task is determined. This allows maximum
overlap in prefetch cache lines for that structure.

Signed-off-by: Ken Chen <kenneth.w.chen@xxxxxxxxx>

--- linux-2.6.12/include/linux/sched.h.orig 2005-07-27 14:43:49.321986290 -0700
+++ linux-2.6.12/include/linux/sched.h 2005-07-27 14:44:03.390345492 -0700
@@ -622,6 +622,11 @@ extern int groups_search(struct group_in
#define GROUP_AT(gi, i) \

+extern void prefetch_switch_stack(struct task_struct*);
+#define prefetch_switch_stack(task) do { } while (0)

struct audit_context; /* See audit.c */
struct mempolicy;
--- linux-2.6.12/kernel/sched.c.orig 2005-07-27 14:43:49.391322226 -0700
+++ linux-2.6.12/kernel/sched.c 2005-07-27 14:44:03.394251742 -0700
@@ -3044,6 +3044,7 @@ switch_tasks:
if (next == rq->idle)
schedstat_inc(rq, sched_goidle);
+ prefetch_switch_stack(next);

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at