From patchwork Tue Sep 13 16:10:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 669473 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 3sYVfw6gj6z9sC4 for ; Wed, 14 Sep 2016 02:36:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=W3wh3176; dkim-atps=neutral Received: from localhost ([::1]:50172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqgo-0007Mj-FG for incoming@patchwork.ozlabs.org; Tue, 13 Sep 2016 12:36:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqIv-0003Tr-9P for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:11:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjqIq-0002Ei-2R for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:11:24 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqIp-0002EP-Sd for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:11:19 -0400 Received: by mail-wm0-f65.google.com with SMTP id b187so18957088wme.0 for ; Tue, 13 Sep 2016 09:11:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=qUarqONH3T6Y1MPZ8q/wc5cmYLskUKgz9zk5yYRXD+A=; b=W3wh3176aCrhlgn+iLzMY8ynrThgg+4170OUGXSJ3Sl9hLln0vofdNSFBIT+pvirV9 wHSXS+nIweZDchGfWNo7x1+qcvs6SsUdjYAVIRJ7olza6phPOyN36b+7Mo5AG7bxIgx7 l0ETOq5tK0j9W5DHJBt1fMNW19SQUlOLm6wbT8uV9pbeAO4BtzyA1YH6HAumRZptitz0 Oa4ArkQoC048luZuPBLQT4ZPMUYDEh0emLW19L0a54uoqvIVEVtVTdQIO/A+uVlwYNiC kiFNw2PnxX2kWucSwMU2nW0tiYrlv4y0jv5NmCrgqJKB3Rp2plZC62XppekvhLjP5RvE TERA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=qUarqONH3T6Y1MPZ8q/wc5cmYLskUKgz9zk5yYRXD+A=; b=VmXYXndomzAj0Zwt/gki/rdCvt99ygpMxucxXcxc72xLOIwXyiFisu5G17uoNtpO1M nekwGXm0BArwXoAXUReK5zSp6UBecmXOr1ZcaEc7y0Cx9iv1t8LMQBLaGFrjv8aoDO8s ONcAzKhvicOx2T5euFXH2o3PPP64V3veHZgOlvKvf3kUA+pmmZogcoO4yjlt+GSpjPB7 sQlEMQPRdIL/uL+492tc2XqHuIoaHe4AF9gyxotrfwkNI0ngdkGOSp4D1BYm50p9De+0 5BXu/G8rHBmJn7QC43XD8Q/UWcfvJuMPwNrkiUUHyuaHZZ4VVg3fDMY33GuteGEArMMo eX/A== X-Gm-Message-State: AE9vXwOIw/IBw6Q6gd2Q6zO5x/4du4AwwmoTTYq21maJR6997qNLLHqSPUz96Enalkz0YQ== X-Received: by 10.28.156.144 with SMTP id f138mr6366937wme.86.1473783019156; Tue, 13 Sep 2016 09:10:19 -0700 (PDT) Received: from 640k.lan (94-39-180-254.adsl-ull.clienti.tiscali.it. [94.39.180.254]) by smtp.gmail.com with ESMTPSA id o5sm23667155wmg.16.2016.09.13.09.10.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2016 09:10:18 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Sep 2016 18:10:04 +0200 Message-Id: <1473783005-113609-10-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1473783005-113609-1-git-send-email-pbonzini@redhat.com> References: <1473783005-113609-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.65 Subject: [Qemu-devel] [PATCH 09/10] cutils: Add generic prefetch 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: rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson There's no real knowledge of the cacheline size, just prefetching one loop ahead. Signed-off-by: Richard Henderson Message-Id: <1472496380-19706-7-git-send-email-rth@twiddle.net> Signed-off-by: Paolo Bonzini --- util/bufferiszero.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/bufferiszero.c b/util/bufferiszero.c index 932b809..4d8a8c8 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) { \ @@ -210,6 +212,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);