From nobody Tue Apr 15 02:55:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544758938651880.3611733197721; Thu, 13 Dec 2018 19:42:18 -0800 (PST) Received: from localhost ([::1]:59179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXeMd-0000iE-KS for importer@patchew.org; Thu, 13 Dec 2018 22:42:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXe1D-0006I8-L5 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:20:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXe1C-0007ir-8X for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:20:03 -0500 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:37957) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXe1B-0007eZ-U2 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:20:02 -0500 Received: by mail-ot1-x331.google.com with SMTP id e12so4121394otl.5 for ; Thu, 13 Dec 2018 19:20:01 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id g138sm2367537oib.26.2018.12.13.19.19.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 19:19:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rSLn4sAllcbYQ44EjOT6wIuUmlyloNNdXcTUlyxEZyE=; b=fFro9Vq+AOoW9LMOCZfbmrl3QqoA8lgcu098+DIZm37CC6m6zCCyXrvhr6n4IIS69j p0V07bu12JXpCOEHCSUfImV72PSFFjM02HJLYe3v/MuQY8TUFHALL+Irjqy0aPQ4oXPc i6q+oQ5wuv2OVwuiB3PeEbFx5Kxr3kCdh4bOQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rSLn4sAllcbYQ44EjOT6wIuUmlyloNNdXcTUlyxEZyE=; b=ZHRZJ7NsPHFo04gc3Suu8kWVBpwlgJq0JvcIB+hsWPx8WGlqPck0F8oNS6bVzmu1HO RSBZgVdrrB8IRvBgzMdiWGmk7yCIXrWbQLa89oZHdKQyNGF+lQrWy7KeJOet49AYz9lN 8qMvXzRUu5fcXhK4U4E7omHW5eOHp1BuzKrO9oLRnDh8dcVnEoihtv2T9gDUVfVSUyKi wco+lkaJ5ZnLuxCHFo4FOUTn+NbMWo31dYpR0TMAFw8f2D/5O5IdQpn7xdKOZMvoJpkH sTPob5rJ+iWFEySy4LR2EvYlyTk1eWtSw62lBb8dPfGWgBGHstuyGLfajddqOVbD+Rkw neJA== X-Gm-Message-State: AA+aEWbzCo1lO97RlW7iNPVjdvDKdzPO/EXV67rfgHhsK+5xctp5MwLW B6D7dIUVnGBXyyVFk5OhmSkh4P4wIEHJKw== X-Google-Smtp-Source: AFSGD/VDUZr4VtF/2k/H6XYfAbPAM1Liik2ktYWWKK8NMilK7B44UMNE9cCKFGSKJ3EI9KNDcmWNuA== X-Received: by 2002:a9d:1c97:: with SMTP id l23mr1019753ota.276.1544757600085; Thu, 13 Dec 2018 19:20:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 21:19:21 -0600 Message-Id: <20181214031923.29527-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181214031923.29527-1-richard.henderson@linaro.org> References: <20181214031923.29527-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::331 Subject: [Qemu-devel] [PULL 30/32] exec: introduce qemu_xxhash{2,4,5,6,7} 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: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: "Emilio G. Cota" Before moving them all to include/qemu/xxhash.h. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/exec/tb-hash-xx.h | 41 +++++++++++++++++++++++++++++---------- include/exec/tb-hash.h | 2 +- tests/qht-bench.c | 2 +- util/qsp.c | 12 ++++++------ 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/include/exec/tb-hash-xx.h b/include/exec/tb-hash-xx.h index 747a9a612c..98ce4b628a 100644 --- a/include/exec/tb-hash-xx.h +++ b/include/exec/tb-hash-xx.h @@ -42,23 +42,23 @@ #define PRIME32_4 668265263U #define PRIME32_5 374761393U =20 -#define TB_HASH_XX_SEED 1 +#define QEMU_XXHASH_SEED 1 =20 /* * xxhash32, customized for input variables that are not guaranteed to be * contiguous in memory. */ static inline uint32_t -tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint32_t f, uint32_t g) +qemu_xxhash7(uint64_t ab, uint64_t cd, uint32_t e, uint32_t f, uint32_t g) { - uint32_t v1 =3D TB_HASH_XX_SEED + PRIME32_1 + PRIME32_2; - uint32_t v2 =3D TB_HASH_XX_SEED + PRIME32_2; - uint32_t v3 =3D TB_HASH_XX_SEED + 0; - uint32_t v4 =3D TB_HASH_XX_SEED - PRIME32_1; - uint32_t a =3D a0 >> 32; - uint32_t b =3D a0; - uint32_t c =3D b0 >> 32; - uint32_t d =3D b0; + uint32_t v1 =3D QEMU_XXHASH_SEED + PRIME32_1 + PRIME32_2; + uint32_t v2 =3D QEMU_XXHASH_SEED + PRIME32_2; + uint32_t v3 =3D QEMU_XXHASH_SEED + 0; + uint32_t v4 =3D QEMU_XXHASH_SEED - PRIME32_1; + uint32_t a =3D ab >> 32; + uint32_t b =3D ab; + uint32_t c =3D cd >> 32; + uint32_t d =3D cd; uint32_t h32; =20 v1 +=3D a * PRIME32_2; @@ -98,4 +98,25 @@ tb_hash_func7(uint64_t a0, uint64_t b0, uint32_t e, uint= 32_t f, uint32_t g) return h32; } =20 +static inline uint32_t qemu_xxhash2(uint64_t ab) +{ + return qemu_xxhash7(ab, 0, 0, 0, 0); +} + +static inline uint32_t qemu_xxhash4(uint64_t ab, uint64_t cd) +{ + return qemu_xxhash7(ab, cd, 0, 0, 0); +} + +static inline uint32_t qemu_xxhash5(uint64_t ab, uint64_t cd, uint32_t e) +{ + return qemu_xxhash7(ab, cd, e, 0, 0); +} + +static inline uint32_t qemu_xxhash6(uint64_t ab, uint64_t cd, uint32_t e, + uint32_t f) +{ + return qemu_xxhash7(ab, cd, e, f, 0); +} + #endif /* EXEC_TB_HASH_XX_H */ diff --git a/include/exec/tb-hash.h b/include/exec/tb-hash.h index 0526c4f678..731ba4c272 100644 --- a/include/exec/tb-hash.h +++ b/include/exec/tb-hash.h @@ -61,7 +61,7 @@ static inline uint32_t tb_hash_func(tb_page_addr_t phys_pc, target_ulong pc, uint32_t fl= ags, uint32_t cf_mask, uint32_t trace_vcpu_dstate) { - return tb_hash_func7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); + return qemu_xxhash7(phys_pc, pc, flags, cf_mask, trace_vcpu_dstate); } =20 #endif diff --git a/tests/qht-bench.c b/tests/qht-bench.c index 636750d39f..0278f4da04 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -105,7 +105,7 @@ static bool is_equal(const void *ap, const void *bp) =20 static uint32_t h(unsigned long v) { - return tb_hash_func7(v, 0, 0, 0, 0); + return qemu_xxhash2(v); } =20 static uint32_t hval(unsigned long v) diff --git a/util/qsp.c b/util/qsp.c index a848b09c6d..dc29c41fde 100644 --- a/util/qsp.c +++ b/util/qsp.c @@ -135,13 +135,13 @@ QemuCondWaitFunc qemu_cond_wait_func =3D qemu_cond_wa= it_impl; * without it we still get a pretty unique hash. */ static inline -uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t a) +uint32_t do_qsp_callsite_hash(const QSPCallSite *callsite, uint64_t ab) { - uint64_t b =3D (uint64_t)(uintptr_t)callsite->obj; + uint64_t cd =3D (uint64_t)(uintptr_t)callsite->obj; uint32_t e =3D callsite->line; uint32_t f =3D callsite->type; =20 - return tb_hash_func7(a, b, e, f, 0); + return qemu_xxhash6(ab, cd, e, f); } =20 static inline @@ -169,11 +169,11 @@ static uint32_t qsp_entry_no_thread_hash(const QSPEnt= ry *entry) static uint32_t qsp_entry_no_thread_obj_hash(const QSPEntry *entry) { const QSPCallSite *callsite =3D entry->callsite; - uint64_t a =3D g_str_hash(callsite->file); - uint64_t b =3D callsite->line; + uint64_t ab =3D g_str_hash(callsite->file); + uint64_t cd =3D callsite->line; uint32_t e =3D callsite->type; =20 - return tb_hash_func7(a, b, e, 0, 0); + return qemu_xxhash5(ab, cd, e); } =20 static bool qsp_callsite_cmp(const void *ap, const void *bp) --=20 2.17.2