lkml.org 
[lkml]   [2005]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Add prefetch switch stack hook in scheduler function
From
Date

> ---------
> unroll prefetch_range() loops manually.
>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
>
> include/linux/prefetch.h | 31 +++++++++++++++++++++++++++++--
> 1 files changed, 29 insertions(+), 2 deletions(-)
>
> Index: linux/include/linux/prefetch.h
> ===================================================================
> --- linux.orig/include/linux/prefetch.h
> +++ linux/include/linux/prefetch.h
> @@ -58,11 +58,38 @@ static inline void prefetchw(const void
> static inline void prefetch_range(void *addr, size_t len)
> {
> #ifdef ARCH_HAS_PREFETCH
> - char *cp;
> + char *cp = addr;
> char *end = addr + len;
>
> - for (cp = addr; cp < end; cp += PREFETCH_STRIDE)
> + /*
> + * Unroll agressively:
> + */
> + if (len <= PREFETCH_STRIDE)
> prefetch(cp);
> + else if (len <= 2*PREFETCH_STRIDE) {
> + prefetch(cp);
> + prefetch(cp + PREFETCH_STRIDE);
> + }
> + else if (len <= 3*PREFETCH_STRIDE) {
> + prefetch(cp);
> + prefetch(cp + PREFETCH_STRIDE);
> + prefetch(cp + 2*PREFETCH_STRIDE);
> + }
> + else if (len <= 4*PREFETCH_STRIDE) {
> + prefetch(cp);
> + prefetch(cp + PREFETCH_STRIDE);
> + prefetch(cp + 2*PREFETCH_STRIDE);
> + prefetch(cp + 3*PREFETCH_STRIDE);
> + }
> + else if (len <= 5*PREFETCH_STRIDE) {
> + prefetch(cp);
> + prefetch(cp + PREFETCH_STRIDE);
> + prefetch(cp + 2*PREFETCH_STRIDE);
> + prefetch(cp + 3*PREFETCH_STRIDE);
> + prefetch(cp + 4*PREFETCH_STRIDE);
> + } else
> + for (; cp < end; cp += PREFETCH_STRIDE)
> + prefetch(cp);
> #endif
> }
>

code like that always makes me think of duffs-device
http://www.lysator.liu.se/c/duffs-device.html

although it might be that the compiler generates better code from the
current incarnation; just my .02 ;-)

regards,

--
Peter Zijlstra <a.p.zijlstra@chello.nl>

-
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/

\
 
 \ /
  Last update: 2005-07-29 11:21    [W:0.103 / U:0.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site