Re: Add prefetch switch stack hook in scheduler function

From: Keith Owens
Date: Fri Jul 29 2005 - 02:39:38 EST

On Fri, 29 Jul 2005 09:04:48 +0200,
Ingo Molnar <mingo@xxxxxxx> wrote:
>ok, how about the additional patch below? Does this do the trick on
>ia64? It makes complete sense on every architecture to prefetch from
>below the current kernel stack, in the expectation of the next task
>touching the stack. The only difference is that for ia64 the 'expected
>minimum stack footprint' is larger, due to the switch_stack.
>Index: linux/kernel/sched.c
>--- linux.orig/kernel/sched.c
>+++ linux/kernel/sched.c
>@@ -2869,7 +2869,14 @@ go_idle:
> * its thread_info, its kernel stack and mm:
> */
> prefetch(next->thread_info);
>- prefetch(kernel_stack(next));
>+ /*
>+ * Prefetch (at least) a cacheline below the current
>+ * kernel stack (in expectation of any new task touching
>+ * the stack at least minimally), and a cacheline above
>+ * the stack:
>+ */
>+ prefetch_range(kernel_stack(next) - MIN_KERNEL_STACK_FOOTPRINT,
> prefetch(next->mm);
> if (!rt_task(next) && next->activated > 0) {

Surely the prefetch range has to depend on which direction the stack
grows. For stacks that grow down, we want esp/ksp upwards,


For stacks that grow up, we want esp/ksp downwards

prefetch_range(kernel_stack(next) - MIN_KERNEL_STACK_FOOTPRINT,

BTW, for ia64 you may as well prefetch pt_regs, that is also quite


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