diff options
author | Richard Henderson <rth@twiddle.net> | 2016-08-29 11:46:17 -0700 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-09-13 19:13:32 +0200 |
commit | 083d012a388e7e2a8bfd9144c2c9bcceb29a78fc (patch) | |
tree | f9f373d968fa12484fbdfb8f7d1c4f408ca370ae | |
parent | 86444f084b23c967d556039b22a67d80a72725ca (diff) |
cutils: Add generic prefetch
There's no real knowledge of the cacheline size,
just prefetching one loop ahead.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Message-Id: <1472496380-19706-7-git-send-email-rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | util/bufferiszero.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/bufferiszero.c b/util/bufferiszero.c index bafd3d159c..abe65f9d88 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -38,6 +38,8 @@ static bool NAME(const void *buf, size_t len) \ do { \ const VECTYPE *p = buf; \ VECTYPE t; \ + __builtin_prefetch(buf + SIZE); \ + barrier(); \ if (SIZE == sizeof(VECTYPE) * 4) { \ t = (p[0] | p[1]) | (p[2] | p[3]); \ } else if (SIZE == sizeof(VECTYPE) * 8) { \ @@ -219,6 +221,9 @@ bool buffer_is_zero(const void *buf, size_t len) return true; } + /* Fetch the beginning of the buffer while we select the accelerator. */ + __builtin_prefetch(buf); + /* Use an optimized zero check if possible. Note that this also includes a check for an unrolled loop over 64-bit integers. */ return select_accel_fn(buf, len); |