* 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/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
|
|