From patchwork Wed Dec 7 17:06:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vijay Kilari X-Patchwork-Id: 9464913 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D79346022E for ; Wed, 7 Dec 2016 17:08:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C122E284F9 for ; Wed, 7 Dec 2016 17:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B63142853F; Wed, 7 Dec 2016 17:08:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3BA24284F9 for ; Wed, 7 Dec 2016 17:08:36 +0000 (UTC) Received: from localhost ([::1]:40278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEfhr-0002XF-17 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Dec 2016 12:08:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEfh5-0002D2-7n for qemu-devel@nongnu.org; Wed, 07 Dec 2016 12:07:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cEfh4-0000RX-88 for qemu-devel@nongnu.org; Wed, 07 Dec 2016 12:07:47 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cEfgy-0000PC-JI; Wed, 07 Dec 2016 12:07:40 -0500 Received: by mail-pg0-f66.google.com with SMTP id p66so24030301pga.2; Wed, 07 Dec 2016 09:07:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=POiGBAAPC6SQr0UD6UwKXtKLmwvlp1eRjYEzxtpQCU4=; b=N2Vtej3CiacOvpbSet3Rn0yis1vD8tn1dJ+TNB+ZCuNW8bUlcj+lvVN3d4B1CmiEc3 lXw1n5V+RCQoCkTzkLuv3iJCy7R2KOFZja68DQjyjCyGyn9v4ehDkspTlsdvGoq+Jjt4 F+QbMP6arkaA7WvRD2PFVl2Wm9jLfTEn7Vd7Q2TYMz03am/qPXUOCNGmzNmXLcN8s3UV LfKuwRmIV5dGTRrqzkkLxX53iHDJPOlq/Lq+Av2Qge8p7iDGuVsUohg1P6q2OTGkqcR+ DGT3rfli7QJ6aTNkGmFSXvanHd29GL4mOnPlyCxTEDuC7TG5aIDYogkudv2VlIi+UL8T n4vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=POiGBAAPC6SQr0UD6UwKXtKLmwvlp1eRjYEzxtpQCU4=; b=iSJGIAOijK9HlYoX97MGLaD22GAeYV4P1YCt7aQ6syyM1G5JN16OeYKxdCRf8RsTNz x69V2whbw4A5ss5YJRsuZeQxsHc5sIXAjwoUzDpOZAuskANqA51lniOCYVLfB0M9sLWe hWDkh+DmmHJa1oxBWnwo8tZw7VntvJJrJL4a34Ead8hs0ajfhdu7qKmt9dpPXK3fgDcY KngrH63SK8R2uxj9K0AWPHIbAwMm2x+UGW8gh00Lq9AjBvDUgZAvuRg7AbzxYDQd4XC0 bzEaMTmWgWSrieiMIp9s3EtYlX3rYCGRxmJBgCQYmGk+rKCr6dNANIGsklRya0rk4766 jVZw== X-Gm-Message-State: AKaTC00EHYcWREWTpsDq0dPnupL7pvvvjvVJqUbwlw0KdFrpzyAg7MrSr1Ldv9cC3IprRg== X-Received: by 10.99.126.94 with SMTP id o30mr123417297pgn.66.1481130399712; Wed, 07 Dec 2016 09:06:39 -0800 (PST) Received: from localhost.localdomain (50-233-148-156-static.hfc.comcastbusiness.net. [50.233.148.156]) by smtp.gmail.com with ESMTPSA id u23sm43898487pfg.86.2016.12.07.09.06.36 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Dec 2016 09:06:39 -0800 (PST) From: vijay.kilari@gmail.com To: qemu-arm@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, rth@twiddle.net Date: Wed, 7 Dec 2016 22:36:11 +0530 Message-Id: <1481130374-5147-2-git-send-email-vijay.kilari@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1481130374-5147-1-git-send-email-vijay.kilari@gmail.com> References: <1481130374-5147-1-git-send-email-vijay.kilari@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.83.66 Subject: [Qemu-devel] [PATCH v5 1/3] cutils: Set __builtin_prefetch optional parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, vijay.kilari@gmail.com, Vijaya Kumar K Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Vijaya Kumar K Optional parameters of __builtin_prefetch() which specifies rw and locality to 0's. For checking buffer is zero, set rw as read and temporal locality to 0. On arm64, __builtin_prefetch(addr) generates 'prfm pldl1keep' where __builtin_prefetch(addr, 0, 0) generates 'prfm pldl1strm' instruction which is optimal for this use case Signed-off-by: Vijaya Kumar K Reviewed-by: Richard Henderson --- util/bufferiszero.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util/bufferiszero.c b/util/bufferiszero.c index eb974b7..421d945 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -49,7 +49,7 @@ buffer_zero_int(const void *buf, size_t len) const uint64_t *e = (uint64_t *)(((uintptr_t)buf + len) & -8); for (; p + 8 <= e; p += 8) { - __builtin_prefetch(p + 8); + __builtin_prefetch(p + 8, 0, 0); if (t) { return false; } @@ -86,7 +86,7 @@ buffer_zero_sse2(const void *buf, size_t len) /* Loop over 16-byte aligned blocks of 64. */ while (likely(p <= e)) { - __builtin_prefetch(p); + __builtin_prefetch(p, 0, 0); t = _mm_cmpeq_epi8(t, zero); if (unlikely(_mm_movemask_epi8(t) != 0xFFFF)) { return false; @@ -127,7 +127,7 @@ buffer_zero_sse4(const void *buf, size_t len) /* Loop over 16-byte aligned blocks of 64. */ while (likely(p <= e)) { - __builtin_prefetch(p); + __builtin_prefetch(p, 0, 0); if (unlikely(!_mm_testz_si128(t, t))) { return false; } @@ -162,7 +162,7 @@ buffer_zero_avx2(const void *buf, size_t len) if (likely(p <= e)) { /* Loop over 32-byte aligned blocks of 128. */ do { - __builtin_prefetch(p); + __builtin_prefetch(p, 0, 0); if (unlikely(!_mm256_testz_si256(t, t))) { return false; } @@ -303,7 +303,7 @@ bool buffer_is_zero(const void *buf, size_t len) } /* Fetch the beginning of the buffer while we select the accelerator. */ - __builtin_prefetch(buf); + __builtin_prefetch(buf, 0, 0); /* Use an optimized zero check if possible. Note that this also includes a check for an unrolled loop over 64-bit integers. */