From patchwork Tue Sep 13 16:09:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 669471 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 3sYVZX6hL6z9ryv for ; Wed, 14 Sep 2016 02:32:20 +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=xfM+DcRz; dkim-atps=neutral Received: from localhost ([::1]:50127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqd8-0004Zc-Fx for incoming@patchwork.ozlabs.org; Tue, 13 Sep 2016 12:32:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqIp-0003Pd-Ts for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:11:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjqIj-00022e-Fp for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:11:19 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqIj-00021T-7Q for qemu-devel@nongnu.org; Tue, 13 Sep 2016 12:11:13 -0400 Received: by mail-wm0-f68.google.com with SMTP id b184so3071266wma.3 for ; Tue, 13 Sep 2016 09:11:13 -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=v94+REsKEtLR3zmrnjznJsm1eOG95XQjyq4jw1KG2Ko=; b=xfM+DcRzTPqNlTMbbYTEjFejd8h+9IGD4ZXjgLr6Xj0cqQ6x9UKJfLffevw6k1NMBn wEe/Uccff2/B0Kwj5eTADjs9/8Pa5cswlQb9bM6B00ddFNA/yPjPHNLKf8Bkmt+P5sBH Pz94fmmhIsOLJSd7pQmC6DjOQkBdoobXPs3p8GUPMYeqNDhmXff1YsyDDoyPujkeLNDp djJsnQlulCrR2qaviuJUn9Xr2OX0GSPdfgdJvp5BSQFEuX4QGNLh+Ig/maXytUFuItiM i5SOGqj0wbCL6dJa8pwqBhf+pmdxI67FLP+xXkUchdC4QI5ewJU/2L6TbQH10CNopZMk Ezig== 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=v94+REsKEtLR3zmrnjznJsm1eOG95XQjyq4jw1KG2Ko=; b=HOcoklrK9qIGNdJJ4mKG8FAGF7STu2dD0DAGonwdg/GFzCIutcIvi1Ly4o0ckQPdNb KuLBH5SHWZCwjwjpZbHVRbivbHZ2Eb6bYHFlWF2WJKSY+mgADpxYmOoO5vT0z637xyCe 4d+7aCptssZVpZtECiKDIeBTwGwfCFBA++3Z6CLkDFwRg9V4JOGVkLy6/6b8QIFMgyzZ RQTc1HyKAIhGUdLpSGkg1WJBW6JKOnxcfgiKj+q9o5Lux5J2MT0nWkYKnezZAAubkUuk 9wZz6tuDKu56sGLv/AVuqqw/Nw86okas0uUxN/KYqTWj0wbNQvRSH8qAohYgJIA/oxYm cvTg== X-Gm-Message-State: AE9vXwNk4cojBW74ofgUklDgRpfxfB6iYcS7f3givixnynDNDrN8RGNJCQEaFWr6IMV+3w== X-Received: by 10.194.73.9 with SMTP id h9mr19678199wjv.21.1473783012618; Tue, 13 Sep 2016 09:10:12 -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.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2016 09:10:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 13 Sep 2016 18:09:58 +0200 Message-Id: <1473783005-113609-4-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.68 Subject: [Qemu-devel] [PATCH 03/10] cutils: Export only buffer_is_zero 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 Since the two users don't make use of the returned offset, beyond ensuring that the entire buffer is zero, consider the can_use_buffer_find_nonzero_offset and buffer_find_nonzero_offset functions internal. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Richard Henderson Message-Id: <1472496380-19706-4-git-send-email-rth@twiddle.net> Signed-off-by: Paolo Bonzini --- include/qemu/cutils.h | 2 -- migration/ram.c | 2 +- migration/rdma.c | 5 +---- util/bufferiszero.c | 8 ++++---- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 3e4ea23..ca58577 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -168,8 +168,6 @@ int64_t qemu_strtosz_suffix_unit(const char *nptr, char **end, /* used to print char* safely */ #define STR_OR_NULL(str) ((str) ? (str) : "null") -bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len); -size_t buffer_find_nonzero_offset(const void *buf, size_t len); bool buffer_is_zero(const void *buf, size_t len); /* diff --git a/migration/ram.c b/migration/ram.c index a3d70c4..a6e1c63 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -73,7 +73,7 @@ static const uint8_t ZERO_TARGET_PAGE[TARGET_PAGE_SIZE]; static inline bool is_zero_range(uint8_t *p, uint64_t size) { - return buffer_find_nonzero_offset(p, size) == size; + return buffer_is_zero(p, size); } /* struct contains XBZRLE cache and a static page diff --git a/migration/rdma.c b/migration/rdma.c index 5110ec8..88bdb64 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1934,10 +1934,7 @@ retry: * memset() + madvise() the entire chunk without RDMA. */ - if (can_use_buffer_find_nonzero_offset((void *)(uintptr_t)sge.addr, - length) - && buffer_find_nonzero_offset((void *)(uintptr_t)sge.addr, - length) == length) { + if (buffer_is_zero((void *)(uintptr_t)sge.addr, length)) { RDMACompress comp = { .offset = current_addr, .value = 0, diff --git a/util/bufferiszero.c b/util/bufferiszero.c index 067d08f..0cf8b6e 100644 --- a/util/bufferiszero.c +++ b/util/bufferiszero.c @@ -192,9 +192,9 @@ static bool avx2_support(void) return b & bit_AVX2; } -bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len) \ +static bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len) \ __attribute__ ((ifunc("can_use_buffer_find_nonzero_offset_ifunc"))); -size_t buffer_find_nonzero_offset(const void *buf, size_t len) \ +static size_t buffer_find_nonzero_offset(const void *buf, size_t len) \ __attribute__ ((ifunc("buffer_find_nonzero_offset_ifunc"))); static void *buffer_find_nonzero_offset_ifunc(void) @@ -215,12 +215,12 @@ static void *can_use_buffer_find_nonzero_offset_ifunc(void) } #pragma GCC pop_options #else -bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len) +static bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len) { return can_use_buffer_find_nonzero_offset_inner(buf, len); } -size_t buffer_find_nonzero_offset(const void *buf, size_t len) +static size_t buffer_find_nonzero_offset(const void *buf, size_t len) { return buffer_find_nonzero_offset_inner(buf, len); }