* [Qemu-devel] [PATCH v2 7/8] cutils: Rewrite aarch64 buffer zero checking
[not found] <1472060915-6011-1-git-send-email-rth@twiddle.net>
@ 2016-08-24 17:48 ` Richard Henderson
0 siblings, 0 replies; only message in thread
From: Richard Henderson @ 2016-08-24 17:48 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini, qemu-arm, vijay.kilari, peter.maydell
Provide 64-byte and 128-byte versions.
Use dczid_el0 as a proxy for the cacheline size.
Cc: qemu-arm@nongnu.org
Cc: vijay.kilari@gmail.com
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
util/bufferiszero.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/util/bufferiszero.c b/util/bufferiszero.c
index e5e4459..28a1419 100644
--- a/util/bufferiszero.c
+++ b/util/bufferiszero.c
@@ -340,13 +340,35 @@ static bool select_accel_fn(const void *buf, size_t len)
#include "arm_neon.h"
#define DO_NONZERO(X) (vgetq_lane_u64((X), 0) | vgetq_lane_u64((X), 1))
-ACCEL_BUFFER_ZERO(buffer_zero_neon, 128, uint64x2_t, DO_NONZERO)
+ACCEL_BUFFER_ZERO(buffer_zero_neon_64, 64, uint64x2_t, DO_NONZERO)
+ACCEL_BUFFER_ZERO(buffer_zero_neon_128, 128, uint64x2_t, DO_NONZERO)
+
+static uint32_t buffer_zero_line_mask;
+static accel_zero_fn buffer_zero_accel;
+
+static void __attribute__((constructor)) init_buffer_zero_accel(void)
+{
+ uint64_t t;
+
+ /* Use the DZP block size as a proxy for the cacheline size,
+ since the later is not available to userspace. This seems
+ to work in practice for existing implementations. */
+ asm("mrs %0, dczid_el0" : "=r"(t));
+ if ((t & 15) * 16 >= 128) {
+ buffer_zero_line_mask = 128 - 1;
+ buffer_zero_accel = buffer_zero_neon_128;
+ } else {
+ buffer_zero_line_mask = 64 - 1;
+ buffer_zero_accel = buffer_zero_neon_64;
+ }
+}
static bool select_accel_fn(const void *buf, size_t len)
{
uintptr_t ibuf = (uintptr_t)buf;
- if (len % 128 == 0 && ibuf % sizeof(uint64x2_t) == 0) {
- return buffer_zero_neon(buf, len);
+ if (likely(ibuf % sizeof(uint64_t) == 0)
+ && (len & buffer_zero_line_mask) == 0) {
+ return buffer_zero_accel(buf, len);
}
return select_accel_int(buf, len);
}
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-24 17:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1472060915-6011-1-git-send-email-rth@twiddle.net>
2016-08-24 17:48 ` [Qemu-devel] [PATCH v2 7/8] cutils: Rewrite aarch64 buffer zero checking Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).