All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, qemu-arm@nongnu.org, vijay.kilari@gmail.com,
	peter.maydell@linaro.org
Subject: [Qemu-arm] [PATCH 6/7] cutils: Rewrite aarch64 buffer zero checking
Date: Tue, 23 Aug 2016 21:17:58 -0700	[thread overview]
Message-ID: <1472012279-20581-7-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1472012279-20581-1-git-send-email-rth@twiddle.net>

Provide 64-byte and 128-byte versions.
Use dczid_el0 as a proxy for the cacheline size.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 util/cutils.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/util/cutils.c b/util/cutils.c
index ec4bd78..fe860e8 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -475,13 +475,35 @@ static bool select_accel_fn(const void *buf, size_t len)
 #include "arm_neon.h"
 
 #define DO_ZERO(X)  (vgetq_lane_u64((X), 0) | vgetq_lane_u64((X), 1))
-ACCEL_BUFFER_ZERO(buffer_zero_neon, 128, uint64x2_t, DO_ZERO)
+ACCEL_BUFFER_ZERO(buffer_zero_neon_64, 64, uint64x2_t, DO_ZERO)
+ACCEL_BUFFER_ZERO(buffer_zero_neon_128, 128, uint64x2_t, DO_ZERO)
+
+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


WARNING: multiple messages have this Message-ID (diff)
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: vijay.kilari@gmail.com, qemu-arm@nongnu.org, pbonzini@redhat.com,
	peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH 6/7] cutils: Rewrite aarch64 buffer zero checking
Date: Tue, 23 Aug 2016 21:17:58 -0700	[thread overview]
Message-ID: <1472012279-20581-7-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1472012279-20581-1-git-send-email-rth@twiddle.net>

Provide 64-byte and 128-byte versions.
Use dczid_el0 as a proxy for the cacheline size.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 util/cutils.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/util/cutils.c b/util/cutils.c
index ec4bd78..fe860e8 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -475,13 +475,35 @@ static bool select_accel_fn(const void *buf, size_t len)
 #include "arm_neon.h"
 
 #define DO_ZERO(X)  (vgetq_lane_u64((X), 0) | vgetq_lane_u64((X), 1))
-ACCEL_BUFFER_ZERO(buffer_zero_neon, 128, uint64x2_t, DO_ZERO)
+ACCEL_BUFFER_ZERO(buffer_zero_neon_64, 64, uint64x2_t, DO_ZERO)
+ACCEL_BUFFER_ZERO(buffer_zero_neon_128, 128, uint64x2_t, DO_ZERO)
+
+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

  parent reply	other threads:[~2016-08-24  4:26 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-24  4:17 [Qemu-arm] [PATCH 0/7] Improve buffer_is_zero Richard Henderson
2016-08-24  4:17 ` [Qemu-devel] " Richard Henderson
2016-08-24  4:17 ` [Qemu-devel] [PATCH 1/7] cutils: Remove SPLAT macro Richard Henderson
2016-08-24  4:17   ` Richard Henderson
2016-08-24  4:17 ` [Qemu-devel] [PATCH 2/7] cutils: Export only buffer_is_zero Richard Henderson
2016-08-24  4:17   ` Richard Henderson
2016-08-24  8:37   ` [Qemu-arm] " Dr. David Alan Gilbert
2016-08-24  8:37     ` Dr. David Alan Gilbert
2016-08-24  4:17 ` [Qemu-devel] [PATCH 3/7] cutils: Rearrange buffer_is_zero acceleration Richard Henderson
2016-08-24  4:17   ` Richard Henderson
2016-08-24  4:17 ` [Qemu-devel] [PATCH 4/7] cutils: Add generic prefetch Richard Henderson
2016-08-24  4:17   ` Richard Henderson
2016-08-24  4:17 ` [Qemu-arm] [PATCH 5/7] cutils: Rewrite x86 buffer zero checking Richard Henderson
2016-08-24  4:17   ` [Qemu-devel] " Richard Henderson
2016-08-24  4:17 ` Richard Henderson [this message]
2016-08-24  4:17   ` [Qemu-devel] [PATCH 6/7] cutils: Rewrite aarch64 " Richard Henderson
2016-08-24  4:17 ` [Qemu-arm] [PATCH 7/7] cutils: Rewrite ppc " Richard Henderson
2016-08-24  4:17   ` [Qemu-devel] " Richard Henderson
2016-08-24  4:30 ` [Qemu-arm] [Qemu-devel] [PATCH 0/7] Improve buffer_is_zero no-reply
2016-08-24  4:30   ` no-reply
2016-08-24  4:38   ` [Qemu-arm] " Paolo Bonzini
2016-08-24  4:38     ` [Qemu-devel] " Paolo Bonzini
2016-08-24 14:53     ` [Qemu-arm] " Richard Henderson
2016-08-24 14:53       ` Richard Henderson
2016-08-24 14:59       ` [Qemu-arm] " Paolo Bonzini
2016-08-24 14:59         ` Paolo Bonzini
2016-08-24  8:34 ` [Qemu-arm] " Dr. David Alan Gilbert
2016-08-24  8:34   ` Dr. David Alan Gilbert
2016-08-24 10:26   ` Adam Richter
2016-08-24 10:26     ` Adam Richter
2016-08-24 10:52     ` [Qemu-arm] " Peter Maydell
2016-08-24 10:52       ` Peter Maydell
2016-08-24 11:45       ` [Qemu-arm] " Paolo Bonzini
2016-08-24 11:45         ` Paolo Bonzini
2016-08-24 12:22         ` [Qemu-arm] " Peter Maydell
2016-08-24 12:22           ` Peter Maydell
2016-08-25  6:37 ` [Qemu-arm] " Vijay Kilari
2016-08-25  6:37   ` [Qemu-devel] " Vijay Kilari
2016-08-25  8:04   ` [Qemu-arm] " Vijay Kilari
2016-08-25  8:04     ` [Qemu-devel] " Vijay Kilari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472012279-20581-7-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vijay.kilari@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.