RE: Add prefetch switch stack hook in scheduler function

From: Chen, Kenneth W
Date: Fri Jul 29 2005 - 02:26:29 EST


Ingo Molnar wrote on Friday, July 29, 2005 12:05 AM
> --- 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,
> + MIN_KERNEL_STACK_FOOTPRINT + L1_CACHE_BYTES);
> prefetch(next->mm);


Doctor, it still hurts :-(

On ia64, we have two kernel stacks, one for outgoing task, and one for
incoming task. for outgoing task, we haven't called switch_to() yet.
So the switch stack structure for 'current' will be allocated immediately
below current 'sp' pointer. For the incoming task, it was fully ctx'ed out
previously, so switch stack structure is immediate above kernel_stack(next).
It Would be beneficial to prefetch both stacks.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/