* Eric Dumazet <[EMAIL PROTECTED]> wrote: > Please test that len is a constant, or else the inlining is too large > for the non constant case.
yeah. fix below. Ingo ----- noticed by Eric Dumazet: unrolling should be dependent on a constant length, otherwise inlining gets too large. Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]> include/linux/prefetch.h | 128 ++++++++++++++++++++++++----------------------- 1 files changed, 66 insertions(+), 62 deletions(-) Index: linux-prefetch-task/include/linux/prefetch.h =================================================================== --- linux-prefetch-task.orig/include/linux/prefetch.h +++ linux-prefetch-task/include/linux/prefetch.h @@ -64,37 +64,39 @@ static inline void prefetch_range(void * /* * 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 if (len <= 6*PREFETCH_STRIDE) { - prefetch(cp); - prefetch(cp + PREFETCH_STRIDE); - prefetch(cp + 2*PREFETCH_STRIDE); - prefetch(cp + 3*PREFETCH_STRIDE); - prefetch(cp + 4*PREFETCH_STRIDE); - prefetch(cp + 5*PREFETCH_STRIDE); + if (__builtin_constant_p(len) && (len <= 6*PREFETCH_STRIDE)) { + 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 if (len <= 6*PREFETCH_STRIDE) { + prefetch(cp); + prefetch(cp + PREFETCH_STRIDE); + prefetch(cp + 2*PREFETCH_STRIDE); + prefetch(cp + 3*PREFETCH_STRIDE); + prefetch(cp + 4*PREFETCH_STRIDE); + prefetch(cp + 5*PREFETCH_STRIDE); + } } else for (; cp < end; cp += PREFETCH_STRIDE) prefetch(cp); @@ -110,37 +112,39 @@ static inline void prefetchw_range(void /* * Unroll agressively: */ - if (len <= PREFETCH_STRIDE) - prefetchw(cp); - else if (len <= 2*PREFETCH_STRIDE) { - prefetchw(cp); - prefetchw(cp + PREFETCH_STRIDE); - } - else if (len <= 3*PREFETCH_STRIDE) { - prefetchw(cp); - prefetchw(cp + PREFETCH_STRIDE); - prefetchw(cp + 2*PREFETCH_STRIDE); - } - else if (len <= 4*PREFETCH_STRIDE) { - prefetchw(cp); - prefetchw(cp + PREFETCH_STRIDE); - prefetchw(cp + 2*PREFETCH_STRIDE); - prefetchw(cp + 3*PREFETCH_STRIDE); - } - else if (len <= 5*PREFETCH_STRIDE) { - prefetchw(cp); - prefetchw(cp + PREFETCH_STRIDE); - prefetchw(cp + 2*PREFETCH_STRIDE); - prefetchw(cp + 3*PREFETCH_STRIDE); - prefetchw(cp + 4*PREFETCH_STRIDE); - } - else if (len <= 6*PREFETCH_STRIDE) { - prefetchw(cp); - prefetchw(cp + PREFETCH_STRIDE); - prefetchw(cp + 2*PREFETCH_STRIDE); - prefetchw(cp + 3*PREFETCH_STRIDE); - prefetchw(cp + 4*PREFETCH_STRIDE); - prefetchw(cp + 5*PREFETCH_STRIDE); + if (__builtin_constant_p(len) && (len <= 6*PREFETCH_STRIDE)) { + if (len <= PREFETCH_STRIDE) + prefetchw(cp); + else if (len <= 2*PREFETCH_STRIDE) { + prefetchw(cp); + prefetchw(cp + PREFETCH_STRIDE); + } + else if (len <= 3*PREFETCH_STRIDE) { + prefetchw(cp); + prefetchw(cp + PREFETCH_STRIDE); + prefetchw(cp + 2*PREFETCH_STRIDE); + } + else if (len <= 4*PREFETCH_STRIDE) { + prefetchw(cp); + prefetchw(cp + PREFETCH_STRIDE); + prefetchw(cp + 2*PREFETCH_STRIDE); + prefetchw(cp + 3*PREFETCH_STRIDE); + } + else if (len <= 5*PREFETCH_STRIDE) { + prefetchw(cp); + prefetchw(cp + PREFETCH_STRIDE); + prefetchw(cp + 2*PREFETCH_STRIDE); + prefetchw(cp + 3*PREFETCH_STRIDE); + prefetchw(cp + 4*PREFETCH_STRIDE); + } + else if (len <= 6*PREFETCH_STRIDE) { + prefetchw(cp); + prefetchw(cp + PREFETCH_STRIDE); + prefetchw(cp + 2*PREFETCH_STRIDE); + prefetchw(cp + 3*PREFETCH_STRIDE); + prefetchw(cp + 4*PREFETCH_STRIDE); + prefetchw(cp + 5*PREFETCH_STRIDE); + } } else for (; cp < end; cp += PREFETCH_STRIDE) prefetchw(cp); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/