From patchwork Wed Sep 26 18:36:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147630 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1066600lji; Wed, 26 Sep 2018 11:37:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63sTyI8LhObx50S1TpC1mBSDt0dMkFYaOWtp0Qf6FRjvKjjWAxkvJEvqMMTVSJsiQHSI2W6 X-Received: by 2002:a0c:ec47:: with SMTP id n7-v6mr1757522qvq.56.1537987068762; Wed, 26 Sep 2018 11:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987068; cv=none; d=google.com; s=arc-20160816; b=rtOO4mKgAL9bVp2gp1C4ur2vsSPf+hdnFBQDz7RjbWd7m+jzmZCksYBir0i+GWfqIV DPTkJGMAAD7zlS8vqDHW/ApXOKcYes8O5NgWHpRAWCBmbdCX1W7en0YlD676MjyQdnA5 sZ4yF3EtTzHghNA2QrSyzlwUWX8nZMxDZOd05T1KXSDjWuRJj5BUgDj7E90eMJcaKwnh 7S9UH2ixzhTyNh1p3nundZftCW7eb5CZh9xB3afM69oVIw+oyg4WkMj0Z1U2KdXyXY9i /OORGbvK/JrRBWC3L96h30edNyXD0fvRIzfpvMOgAja5XAH7hyLoBlIWmT+OKr/yN2Io Iv5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=DzNemCflqvfNAtAYsmACDL1RY7fZHGvm7UAXMK9Epso=; b=ClwCHp+98FAT2+hKvBsexnEB5aVFmOCGK7OVhAM6vzqB+DBXHVTPk9Ip+4M899EFum Ij0/0EM62CzXratnP8edcFKrjwMRUmp9ZulZx0vqghyilIu7DGV0q3741sWMUOo5YUNK TXlz1GnGwH7meCPswbJ+zL+X+SnK2wXzAZyEraiGehnFnZpaBpLZ2TKUrGWfvAto5dLi UX1sYEn/X4in7NFT4qXq4RXmJqghNi5uT04H8zNgFkC115kzUfsB1PCmsUmVT8/0MZVr akLhfKc7ZVp5VdVTuT658Ec+U2CyA+UA/kcv9b9Phb3nQMv+iAWPqTDAtaM0ikSPJECh baAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KKOIJDvr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id p79-v6si1956029qki.58.2018.09.26.11.37.48 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:37:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KKOIJDvr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eh2-0001MB-4S for patch@linaro.org; Wed, 26 Sep 2018 14:37:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Ege-0001Lg-OM for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Ega-0007Ax-Cd for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:22 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:38351) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5EgW-00078X-IS for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:17 -0400 Received: by mail-pf1-x443.google.com with SMTP id x17-v6so13885152pfh.5 for ; Wed, 26 Sep 2018 11:37:15 -0700 (PDT) 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=DzNemCflqvfNAtAYsmACDL1RY7fZHGvm7UAXMK9Epso=; b=KKOIJDvrUh2Ou5pBR2mTbYJMYOTmvckprwun3YQLBnZ31EH/toL9O1XUksBV1vc778 5n4k195kt8B7fJGUvPDBPtGhIi+SzKlR2EuDWuo6vMZwgJoqiKxKb99S6btypS05s7na WZkN4zTmo3BrvvOvpxeezuo411SlBN6/GWYgM= 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=DzNemCflqvfNAtAYsmACDL1RY7fZHGvm7UAXMK9Epso=; b=hC6uMBbo8C1kIRrg/3IGbC2jl41AGMii3ZuPsftagDK2C9J+AMmc4lvuK6RQSwtb/z Y1MezvarYXCS4IqT4WNZyycHzkfjRU3FqAJ8YC7H556sx4EAJ995887Ux+cmsnIN8zg8 ojVuvotSe6ItQef6qwWulhacjfH8axaYVgWaZjZvST/aV8PKUN7y8e2cNXiCZqEc1GTG snhLwIqoqithXsV8i67K3a8kk78Zh1NSB5RWScpB8ug2fJA4GCugkrZPWXJKl2jSoVKc 9BL8tXDvTDfl/NQwxMaWt1vYy2Cu2o+HCXpNZV4BTJDX6ExaitV4hgMob7ZAWt2muBoa jBhw== X-Gm-Message-State: ABuFfohqUbJ2MnVodEtMOR1yhtgkHYOYbHMhygCQY7NfRcDOm6pr8G70 zlDvRooekiR1LTYo035ajICdowPxDow= X-Received: by 2002:a17:902:44:: with SMTP id 62-v6mr7370351pla.181.1537987033749; Wed, 26 Sep 2018 11:37:13 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:36:57 -0700 Message-Id: <20180926183709.21293-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PULL 01/13] qht: remove unused map param from qht_remove__locked 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- util/qht.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/util/qht.c b/util/qht.c index 1e3a072e25..28d9273371 100644 --- a/util/qht.c +++ b/util/qht.c @@ -692,8 +692,7 @@ static inline void qht_bucket_remove_entry(struct qht_bucket *orig, int pos) /* call with b->lock held */ static inline -bool qht_remove__locked(struct qht_map *map, struct qht_bucket *head, - const void *p, uint32_t hash) +bool qht_remove__locked(struct qht_bucket *head, const void *p, uint32_t hash) { struct qht_bucket *b = head; int i; @@ -728,7 +727,7 @@ bool qht_remove(struct qht *ht, const void *p, uint32_t hash) qht_debug_assert(p); b = qht_bucket_lock__no_stale(ht, hash, &map); - ret = qht_remove__locked(map, b, p, hash); + ret = qht_remove__locked(b, p, hash); qht_bucket_debug__locked(b); qemu_spin_unlock(&b->lock); return ret; From patchwork Wed Sep 26 18:36:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147631 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1066784lji; Wed, 26 Sep 2018 11:38:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV62/XeQVDdjID6/+8SxWTGTx9xI241dP2n8rMFdCFCSx71AP/nlU0+ax3PM/49uIva5nx7jr X-Received: by 2002:a0c:ec8e:: with SMTP id u14-v6mr5261064qvo.173.1537987080928; Wed, 26 Sep 2018 11:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987080; cv=none; d=google.com; s=arc-20160816; b=yfDnKUUcyNbKc+vHDQNBteys653OF3Hc5UDRLTnBs8KcKNHZvmwy9vG7nq2h+jUY12 cz0NhKJl3EEQ9ZgsdhpRESoxzo3RLdTC/6Xxx8mon76cwsjP2rQN+f2lbdziiY5dUILY APK6JxOQyy8V0UFtir1uIy4Om+YjAPa5eZpL7PAKe5KXXjLaZypWtKSq0WKJRXLXQWgv c/Kq3xFqV7U0AdoWmDw6B9dX4LAiCZjKV94Vxa+jTj8te4ObYYjx/G2CbpKPwUlx63Jm UO7cLNOl+zgbi80vNHRg3XrkTb+bQTLY0YxzxzNIQWGE82zrQ2yWaa/CZLmyvp04mThQ iNfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=fWoa1Zi9X4ZzdLHzaNha+kvw53UENpeP3xojdxN2gO0=; b=v0+gtVHICurRCUWh4VhUCme04WqQG4XCGXKFYtOfn+L4WJopZVK4XQaQfeoqeQbQme JmeE+h577UoCD5D3Z2Wn9GNKXwesDSPaHVes69Jlddu5Z7FwTPdtf8D4yQ2TGRo4+J1d 5Jf2EMC74yI2DoEIBN3Ngr4DFWABkxlVZGCrcqKQMho+FQGKOV1np5m5PnPl5xYX5GG7 mZQQjsQEmTwihW52WJ6H0Ag4RQ9mT0wdHrn+/KBv/28MbMv2dWdimBUz/I154jO5SMA7 4O+xkMuEZ8u/B+8SeSdg29anmbECJZ05bgIPq71l9GWOauxHd98S/TlvBEmey99kXEfV nYoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LFW4ZT8H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x9-v6si4366357qkl.52.2018.09.26.11.38.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:38:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LFW4ZT8H; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EhE-0001eo-BC for patch@linaro.org; Wed, 26 Sep 2018 14:38:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egj-0001SH-SC for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Ege-0007Iz-UC for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:27 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:41407) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egc-000799-9h for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:24 -0400 Received: by mail-pg1-x543.google.com with SMTP id z3-v6so9436213pgv.8 for ; Wed, 26 Sep 2018 11:37:16 -0700 (PDT) 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=fWoa1Zi9X4ZzdLHzaNha+kvw53UENpeP3xojdxN2gO0=; b=LFW4ZT8HSXg4J3y4dY39P8jEQSSWVqPG4pgbtFSWEwSlP0ayD7mhetnqlkwTiJp1lp Xab1ivLod54l1ILb4WLwFP5T+uXOCA517DH59tUdKGmqPMYhSuE8pDunmUMf+T+ta2TN jH1aJHn8rS+kQFLVfsme6+1tfKR/Y+KHvMOgs= 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=fWoa1Zi9X4ZzdLHzaNha+kvw53UENpeP3xojdxN2gO0=; b=cqMg8JeJPSoDs37RroiPsk5guUBa0Ecaymy641ZZXVxt/cfd8CU4H0S5p/Z1kB55c1 YZVDWkL1oHkXdW1RiEvc/ywHSKkTWg4Y4LYQHq4ZFNxQ98Pvu9GFzCFesoOCwc5bFOTi jNT7dp81zmwWT2Yu6TrAtToAPNfsF62iqT7RBkM8/95U/xnrwcYjI3yBkcCMH5zKtG7Q IH479DUbi40ADE5hFap+rqWnTzKsxZ0HSbsh1yk/68Hb6nw/GujQj0UwZOi6d0sQP1Xo Brhl/P83cfBAA39I+4J+OnKDU1yvxIEYM3O/nykwpWvpgcjq3CaR3S0ph82cRfTpyEGn lFgw== X-Gm-Message-State: ABuFfoiMG91I79Hp0zp0Ta/7mdrz1D8EM8IQrAYk3GVxm/TwPlsKFXOt eEgEBsT3qP3w5Z43BQBm7/JKQXFN/ys= X-Received: by 2002:a63:c046:: with SMTP id z6-v6mr6849275pgi.114.1537987035271; Wed, 26 Sep 2018 11:37:15 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:36:58 -0700 Message-Id: <20180926183709.21293-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PULL 02/13] qht: add qht_iter_remove 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This currently has no users, but the use case is so common that I think we must support it. Note that without the appended we cannot safely remove a set of elements; a 2-step approach (i.e. qht_iter first, keep track of the to-be-deleted elements, and then a bunch of qht_remove calls) would be racy, since between the iteration and the removals other threads might insert additional elements. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/qemu/qht.h | 19 ++++++++++++ util/qht.c | 74 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/include/qemu/qht.h b/include/qemu/qht.h index c9a11cc29a..3a9618db69 100644 --- a/include/qemu/qht.h +++ b/include/qemu/qht.h @@ -44,6 +44,8 @@ struct qht_stats { typedef bool (*qht_lookup_func_t)(const void *obj, const void *userp); typedef void (*qht_iter_func_t)(struct qht *ht, void *p, uint32_t h, void *up); +typedef bool (*qht_iter_bool_func_t)(struct qht *ht, void *p, uint32_t h, + void *up); #define QHT_MODE_AUTO_RESIZE 0x1 /* auto-resize when heavily loaded */ #define QHT_MODE_RAW_MUTEXES 0x2 /* bypass the profiler (QSP) */ @@ -179,9 +181,26 @@ bool qht_resize(struct qht *ht, size_t n_elems); * * Each time it is called, user-provided @func is passed a pointer-hash pair, * plus @userp. + * + * Note: @ht cannot be accessed from @func + * See also: qht_iter_remove() */ void qht_iter(struct qht *ht, qht_iter_func_t func, void *userp); +/** + * qht_iter_remove - Iterate over a QHT, optionally removing entries + * @ht: QHT to be iterated over + * @func: function to be called for each entry in QHT + * @userp: additional pointer to be passed to @func + * + * Each time it is called, user-provided @func is passed a pointer-hash pair, + * plus @userp. If @func returns true, the pointer-hash pair is removed. + * + * Note: @ht cannot be accessed from @func + * See also: qht_iter() + */ +void qht_iter_remove(struct qht *ht, qht_iter_bool_func_t func, void *userp); + /** * qht_statistics_init - Gather statistics from a QHT * @ht: QHT to gather statistics from diff --git a/util/qht.c b/util/qht.c index 28d9273371..c190e89f5b 100644 --- a/util/qht.c +++ b/util/qht.c @@ -89,6 +89,19 @@ #define QHT_BUCKET_ENTRIES 4 #endif +enum qht_iter_type { + QHT_ITER_VOID, /* do nothing; use retvoid */ + QHT_ITER_RM, /* remove element if retbool returns true */ +}; + +struct qht_iter { + union { + qht_iter_func_t retvoid; + qht_iter_bool_func_t retbool; + } f; + enum qht_iter_type type; +}; + /* * Do _not_ use qemu_mutex_[try]lock directly! Use these macros, otherwise * the profiler (QSP) will deadlock. @@ -733,9 +746,10 @@ bool qht_remove(struct qht *ht, const void *p, uint32_t hash) return ret; } -static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *b, - qht_iter_func_t func, void *userp) +static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *head, + const struct qht_iter *iter, void *userp) { + struct qht_bucket *b = head; int i; do { @@ -743,7 +757,25 @@ static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *b, if (b->pointers[i] == NULL) { return; } - func(ht, b->pointers[i], b->hashes[i], userp); + switch (iter->type) { + case QHT_ITER_VOID: + iter->f.retvoid(ht, b->pointers[i], b->hashes[i], userp); + break; + case QHT_ITER_RM: + if (iter->f.retbool(ht, b->pointers[i], b->hashes[i], userp)) { + /* replace i with the last valid element in the bucket */ + seqlock_write_begin(&head->sequence); + qht_bucket_remove_entry(b, i); + seqlock_write_end(&head->sequence); + qht_bucket_debug__locked(b); + /* reevaluate i, since it just got replaced */ + i--; + continue; + } + break; + default: + g_assert_not_reached(); + } } b = b->next; } while (b); @@ -751,26 +783,48 @@ static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *b, /* call with all of the map's locks held */ static inline void qht_map_iter__all_locked(struct qht *ht, struct qht_map *map, - qht_iter_func_t func, void *userp) + const struct qht_iter *iter, + void *userp) { size_t i; for (i = 0; i < map->n_buckets; i++) { - qht_bucket_iter(ht, &map->buckets[i], func, userp); + qht_bucket_iter(ht, &map->buckets[i], iter, userp); } } -void qht_iter(struct qht *ht, qht_iter_func_t func, void *userp) +static inline void +do_qht_iter(struct qht *ht, const struct qht_iter *iter, void *userp) { struct qht_map *map; map = atomic_rcu_read(&ht->map); qht_map_lock_buckets(map); /* Note: ht here is merely for carrying ht->mode; ht->map won't be read */ - qht_map_iter__all_locked(ht, map, func, userp); + qht_map_iter__all_locked(ht, map, iter, userp); qht_map_unlock_buckets(map); } +void qht_iter(struct qht *ht, qht_iter_func_t func, void *userp) +{ + const struct qht_iter iter = { + .f.retvoid = func, + .type = QHT_ITER_VOID, + }; + + do_qht_iter(ht, &iter, userp); +} + +void qht_iter_remove(struct qht *ht, qht_iter_bool_func_t func, void *userp) +{ + const struct qht_iter iter = { + .f.retbool = func, + .type = QHT_ITER_RM, + }; + + do_qht_iter(ht, &iter, userp); +} + static void qht_map_copy(struct qht *ht, void *p, uint32_t hash, void *userp) { struct qht_map *new = userp; @@ -787,6 +841,10 @@ static void qht_map_copy(struct qht *ht, void *p, uint32_t hash, void *userp) static void qht_do_resize_reset(struct qht *ht, struct qht_map *new, bool reset) { struct qht_map *old; + const struct qht_iter iter = { + .f.retvoid = qht_map_copy, + .type = QHT_ITER_VOID, + }; old = ht->map; qht_map_lock_buckets(old); @@ -801,7 +859,7 @@ static void qht_do_resize_reset(struct qht *ht, struct qht_map *new, bool reset) } g_assert(new->n_buckets != old->n_buckets); - qht_map_iter__all_locked(ht, old, qht_map_copy, new); + qht_map_iter__all_locked(ht, old, &iter, new); qht_map_debug__all_locked(new); atomic_rcu_set(&ht->map, new); From patchwork Wed Sep 26 18:36:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147635 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071223lji; Wed, 26 Sep 2018 11:42:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV60S4PHXBGnqPN7KsdoXM+FYJAf/rFKtxmF3ozlovmdpqA4V0oul5TRBfrLRnJ5ds2z2qD1u X-Received: by 2002:a0c:d6c3:: with SMTP id l3-v6mr5180863qvi.154.1537987372850; Wed, 26 Sep 2018 11:42:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987372; cv=none; d=google.com; s=arc-20160816; b=VEBfv/hhVAl0loTZJ7/n4MmgsQF03RnMG1JV5ZDx7h3k7iXYFL1z9I4/rQNhsxPILt vIMA0+wCBFrI7p4n2w/7Mkix3lIQFyylwJRw/kiTmROTwkDua6NC+WT1US+wwY+rinz4 TUs5tz+PNOneEUdsDBu958AThBieWtReyLebsXCw9keAvPA86WwYqkcO2jwIDbXUxWtM FR4RrEk9LsnwT4R83Hcz92P9C59S/WCWBY1tnwUoCDj2PXhFhcfuRB2TsSlcL1Ef6ypV eq+sgJRmB0KCCwbdNNPptBe/fK6AThQfIKOHqpIgBbupxp/AyKkkXUuH5dPebnvsEsrp RR2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=HlAdm22NwgWiCMqOGDVe9uJhUUayKuKdvSW/1SB+VTA=; b=u8lFOoUUk4+/0mUAN5GXmjToo0fS8eJf/cvwewO2gXHb1OLsWr4cj18XjuRLH1Wgd3 R+peaUCqpv0wpgNhf78rlAsdEK8A4VYnz0CtHenxyMaPsuNziQj0nXwpx+hU9WwywMlP Tsbkju0o9CEBNK9AyVnfbebNYziwH4GV/PKYXvN3w8yk+uBAE8x2WBbxSkeG/FH6ZNGX gQ32Z49JuzrIrmzYmEwnb8S8qD5d1iAwoziYwP9zhCghDaliXG5SjtT4fziCJhKWR+Fj +Q1bndAOR2/rtn/vqpy+TzJKX5dAcwyUXN4pAEEFBS+oeR6mT4jMrlJX6gOGiO9uFWdF q0Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bWLWVMwK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k93-v6si46161qtd.396.2018.09.26.11.42.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:42:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bWLWVMwK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Elw-0007w2-81 for patch@linaro.org; Wed, 26 Sep 2018 14:42:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egj-0001Q8-05 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Ege-0007IH-PI for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:26 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:37387) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egb-00079k-1u for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:22 -0400 Received: by mail-pg1-x535.google.com with SMTP id c10-v6so7418125pgq.4 for ; Wed, 26 Sep 2018 11:37:18 -0700 (PDT) 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=HlAdm22NwgWiCMqOGDVe9uJhUUayKuKdvSW/1SB+VTA=; b=bWLWVMwKf87yTnhnsKc/EgN8CG3nGaErIM7IE19ze/m6mw3zhmXpFNtsn3o3iCwcX4 VTEE9Bs70DNSUEZai3S3UV7N4F5l0FunNDaXnfO0tAe7eJ5Q/er5n5Ol5Hz00vicuvZF q7iJl99RgjlSjeQWgsAClFvwsbjG7Q+Rq/eKk= 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=HlAdm22NwgWiCMqOGDVe9uJhUUayKuKdvSW/1SB+VTA=; b=ku8OHHsywIcQ2GhQHLgDIDd5oAl3wocos1ci+QNxXxO/nJEQhdcQffda06zLFYX2Xc gTFZcMMm9gozxLkwMe7xJ7IqQBqX/bopNCkX7Lk46Pu8DPPYPcZlXRyLogENYk+8OBaD mHt9QS84f8D5fkrkkTF9vyr4ZS8xhgHY2+GxQL+MPzVhlljWfqXnllsSKibMxtet1nf2 AzmARDWfiihjItFunHNONTVvzJgzKOv+dzcjoFlA1PZmSS5oZSUS6iZiPXAhHh6t3IZj D3MDaKynYAWW03ShFyQaOnS+d572ZpWqOZ4vtRCTyWBoTkhuiifvVAh7zxMMVconNPAn 3Rhg== X-Gm-Message-State: ABuFfohMXE4Vos4pJ5Xe3ip53vKeTJaq5z+UgvbtHatHfona9HlQBS4X 9Of1h2ToSgndiardOQAtOfEG4N5arCk= X-Received: by 2002:a62:aa17:: with SMTP id e23-v6mr7481020pff.211.1537987036881; Wed, 26 Sep 2018 11:37:16 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:36:59 -0700 Message-Id: <20180926183709.21293-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::535 Subject: [Qemu-devel] [PULL 03/13] test-qht: test qht_iter_remove 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/tests/test-qht.c b/tests/test-qht.c index dda6a067be..283fb3db39 100644 --- a/tests/test-qht.c +++ b/tests/test-qht.c @@ -108,6 +108,49 @@ static void iter_check(unsigned int count) g_assert_cmpuint(curr, ==, count); } +static void sum_func(struct qht *ht, void *p, uint32_t hash, void *userp) +{ + uint32_t *sum = userp; + uint32_t a = *(uint32_t *)p; + + *sum += a; +} + +static void iter_sum_check(unsigned int expected) +{ + unsigned int sum = 0; + + qht_iter(&ht, sum_func, &sum); + g_assert_cmpuint(sum, ==, expected); +} + +static bool rm_mod_func(struct qht *ht, void *p, uint32_t hash, void *userp) +{ + uint32_t a = *(uint32_t *)p; + unsigned int mod = *(unsigned int *)userp; + + return a % mod == 0; +} + +static void iter_rm_mod(unsigned int mod) +{ + qht_iter_remove(&ht, rm_mod_func, &mod); +} + +static void iter_rm_mod_check(unsigned int mod) +{ + unsigned int expected = 0; + unsigned int i; + + for (i = 0; i < N; i++) { + if (i % mod == 0) { + continue; + } + expected += i; + } + iter_sum_check(expected); +} + static void qht_do_test(unsigned int mode, size_t init_entries) { /* under KVM we might fetch stats from an uninitialized qht */ @@ -138,8 +181,11 @@ static void qht_do_test(unsigned int mode, size_t init_entries) insert(10, 150); check_n(N); - rm(1, 2); - check_n(N - 1); + qht_reset(&ht); + insert(0, N); + iter_rm_mod(10); + iter_rm_mod_check(10); + check_n(N * 9 / 10); qht_reset_size(&ht, 0); check_n(0); check(0, N, false); From patchwork Wed Sep 26 18:37:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147636 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071374lji; Wed, 26 Sep 2018 11:43:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV60TB4ke5qEgdklleyr4PPsAu5TQs5Le2gyjoCWX2IV2ERrsjDipzLKBLUKBcKQ71XHIUAaG X-Received: by 2002:a37:4150:: with SMTP id o77-v6mr5330623qka.78.1537987383759; Wed, 26 Sep 2018 11:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987383; cv=none; d=google.com; s=arc-20160816; b=PdKiE+Ob5VSnGCg2r7vZTBz2qljBB9c4bUkLSCnlGbMnBkSFxxsxxog2V380BWj2C3 Liiqzj0FE5IknJ3DPGQKk29s3M7S9w2IDHm5oqvJJvFxGFq88VOkA23QpE2gv8KVhGER jy185HZOjBp7Afz9XC0iStDAE4E0eBUUtxH4PYpMimuUPo5qc7kyixMCyMlWtkTzW/0h 72JF4J09aASMLCpZPqGj3NmA+AdTJWRIwF/IxErYB/jtwMx3N9ROKvWBRi9Rd2e0Xsl/ pMvFEGestIncxWJnd0eoK/CWD1GV2+pPvvWKuc6LpZ9a0WORfz3uENulqyhwtAmFl//+ BrhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=X2FKDRjB8W9M0bK6Iox54anHPpZi7j/uqOqhTSev0ZY=; b=MKB15j+pD4cjyFDCKqt23JNOH4Rf2BOhValbZU4EyL4KOhyxedHKa2YPXWPsj6dcm6 LkXqrYkQ70hU0RhdnHtEbh3XQVy+kFzOn234EmDuza67eW/Jq4iGy9shd2XlJIPUnzov ibeLaV5K0wFRPRtYQOTglz2c7ZVVePm5ljE9p+EbZIpYJbnsmb0DhCgQbgygmsgGZ37z gGdx95i3MHdHTtOElbvqnVyRcxi6aVrz9CwTdvg20ce8PVT7+u3qVAK6xqEGCQIetRm7 uXB17ppXG/r5SE1za7GsfllrB3jtXu3v4Rad263ionBfB4te1oz2LGPt3iq1/Wi3DcNQ rj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LT7zp/HB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g38-v6si4605180qve.248.2018.09.26.11.43.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LT7zp/HB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Em7-00085L-3Y for patch@linaro.org; Wed, 26 Sep 2018 14:43:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egm-0001b5-El for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007PF-CF for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:34444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egj-0007AE-WE for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x52b.google.com with SMTP id d19-v6so14418418pgv.1 for ; Wed, 26 Sep 2018 11:37:19 -0700 (PDT) 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=X2FKDRjB8W9M0bK6Iox54anHPpZi7j/uqOqhTSev0ZY=; b=LT7zp/HBP63TW4VXWORBVjhcCF3rhIttOI7bJ//cakG+BbK++ezA2blVaC1mGcOMG5 HFy7RigV/d8nfujkvTfvEGGJmPqAcu38O6fkuVKg7Wua4NC2jgi6Dyfp4lBV2bxjvcQ5 MYy7IEvnkZjwf0gLAOW2Fc19U8+QFHX26ETtA= 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=X2FKDRjB8W9M0bK6Iox54anHPpZi7j/uqOqhTSev0ZY=; b=n4zhgyjrCG5UrJ1hsawRnaHiCquZZF88vHKif1EswjaqRePQlQixuq86C920Z78yU8 IJQGPutKltp5e0NlxGAG6kkLcoO5queBwgAfuOcOLtg+qoyPVcF0mMQuBNwPjc3zxmlJ 1lRULLh05+UBn4AqOfrhNgZTwQ4LreGhfLJ+dBHyYA5bMKbgpcsdUdFqJYBX5hNfSKu/ bc8h9WDWcR3HZ1tUrm7hWsqmOHwJrqeKngX/r29a5SXF3Y1Lkwuu0fGp+dB790CVzMUY TF5uP2uOHDFp3iTVZSHfUrtlwCKYvoVCuFtcgt1Vb9yhGj7o/9KdTtw3SZUqM2cXytn7 ReDg== X-Gm-Message-State: ABuFfohh55YD+5FMiQuz2Yyoum6WeED40H3KMd3QAO31MN1ECtAHexcZ tMGGSOlffQWfCmIIMxgtHPGWHvTkfgA= X-Received: by 2002:a62:9042:: with SMTP id a63-v6mr7579903pfe.52.1537987038339; Wed, 26 Sep 2018 11:37:18 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:00 -0700 Message-Id: <20180926183709.21293-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PULL 04/13] test-qht: test removal of non-existent entries 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This improves qht.c code coverage from 89.44% to 90.00%. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/tests/test-qht.c b/tests/test-qht.c index 283fb3db39..05b1d6807a 100644 --- a/tests/test-qht.c +++ b/tests/test-qht.c @@ -41,7 +41,7 @@ static void insert(int a, int b) } } -static void rm(int init, int end) +static void do_rm(int init, int end, bool exist) { int i; @@ -49,10 +49,24 @@ static void rm(int init, int end) uint32_t hash; hash = arr[i]; - g_assert_true(qht_remove(&ht, &arr[i], hash)); + if (exist) { + g_assert_true(qht_remove(&ht, &arr[i], hash)); + } else { + g_assert_false(qht_remove(&ht, &arr[i], hash)); + } } } +static void rm(int init, int end) +{ + do_rm(init, end, true); +} + +static void rm_nonexist(int init, int end) +{ + do_rm(init, end, false); +} + static void check(int a, int b, bool expected) { struct qht_stats stats; @@ -157,8 +171,15 @@ static void qht_do_test(unsigned int mode, size_t init_entries) check_n(0); qht_init(&ht, is_equal, 0, mode); + rm_nonexist(0, 4); + insert(0, 4); + rm_nonexist(5, 6); + insert(4, 6); + rm_nonexist(7, 8); + iter_rm_mod(1); check_n(0); + rm_nonexist(0, 10); insert(0, N); check(0, N, true); check_n(N); @@ -183,6 +204,7 @@ static void qht_do_test(unsigned int mode, size_t init_entries) qht_reset(&ht); insert(0, N); + rm_nonexist(N, N + 32); iter_rm_mod(10); iter_rm_mod_check(10); check_n(N * 9 / 10); From patchwork Wed Sep 26 18:37:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147638 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071594lji; Wed, 26 Sep 2018 11:43:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV63PAioCa8mVC3SvRCviwU8cp/o55yp/WDq9ZXwWmnqmOP0udfL07wBVYMQysoPTpHkhEUwi X-Received: by 2002:ac8:2672:: with SMTP id v47-v6mr5414235qtv.287.1537987401141; Wed, 26 Sep 2018 11:43:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987401; cv=none; d=google.com; s=arc-20160816; b=H+/a8+cmQtGKVGHt1MxutESC9bOjCAxJ+AtvLq4jVXx4qzXuF1e0BgPwv/1iq8wJuS axyuCQuJ/lg5mpzQ0O+/8k5JeWq9jf40VN/pb4EWTmaSYT4T/W0zWTJSa2AerjSpQig2 KmCpilU8A4kO73UmxqtZ/sNT2oZXzAOvL8BntCy4cV3YaVPpPxwsmLbdFvjgAaDb5+Ja Us4oGhHlAQms/noj/zxrGkfi6dJ2hC5p5f+xzTurjmNjClapyB8O6SlEX5gkutYsnTMr g2Jo9A1Fx3dnBjwJBhXOw+3kfE7Wiermsn8U9QXTq4sgZag02z1kcNBDRHjGweNVkGpt zU+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=xGHpKrwH+jjwj6RmMlOM/uJwPpjT2p+YT13/rULknRA=; b=K0VwUPzcP0qp1mMXDx8rcW02M4waQf7INQboLSGQ5D5EFp6LfP9H3MbysmGcnBebJR URop8WQ3QILBYnI0XFBNqYfJcoIN7m68FI5mdvs6hYYOFlEk6ZqNcnHmAHqpRnwFp9yL HAST75mk6JaRyPi8A3EaGeYI1cyR7V+EtcWtUR7Al4zR7gZcTz3NbLgqGLN5WmyTNki0 u2m7ROsjD9qgTAFbjTLJp6ERm5Gp/US0jUBmh2pFrQlmGSa/vbP+OeCSFEG735+zLHuP jYl/L1n0t2e5Ab1xAYyRM5S32pSKQl6a6CoAOVtlm/Bm7Po+gOBGUoPPxMhfBGldK/08 tpiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F6VaH81X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g28-v6si1264937qta.395.2018.09.26.11.43.20 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:43:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F6VaH81X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60190 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EmO-0007zf-Kj for patch@linaro.org; Wed, 26 Sep 2018 14:43:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53668) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egn-0001gy-Oo for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007Ph-KW for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:46882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egk-0007B6-9v for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x529.google.com with SMTP id b129-v6so14389048pga.13 for ; Wed, 26 Sep 2018 11:37:21 -0700 (PDT) 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=xGHpKrwH+jjwj6RmMlOM/uJwPpjT2p+YT13/rULknRA=; b=F6VaH81XgNFY16uXz36jUD742QRpBOAPuTwPUp27QQoygs65Q5WHnLsV1OmMygQYud ivMFfAXNIs4SHcp8FkLbKdOAog5M+dNcelTZZV9XhJrB71bK/QgGJuS43klpZSPeFQsT +3L/pm4JL4EuOSAwfI6YgGWXUmz0dDTQc3iPg= 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=xGHpKrwH+jjwj6RmMlOM/uJwPpjT2p+YT13/rULknRA=; b=hFin9S0f8aK0UUbsG3qTdRStgLb5mccNYqJWPqu5v4sau3xfZOFL6BBBtPrM7w6Tom pVVe7WTOkSc0GSarGS/B7PnariooamogK93oMUJTz6CuuPSf3RPtHvz38NTphEc+2ed4 U/EI/tyDhl7cOW3nZBujW1zwb7mLTQjSOq/H197jH/xBK6MP/LTteRCzYHdTKAuzcGp4 SKPyPLKkeO+VX7u9L4hw0tm2q/B3KuXiUG7enJg/O5VE4SoB8NHM787/y80mWTqhyqF4 1AsorO53JjbaOmV+ypW2eqex1MPpqnFZX3xkoAhRqBlAhk5GfBCt1QOQKjPmJBJCzXnr TWLQ== X-Gm-Message-State: ABuFfoghPCaY0Ouw+ww3O53UpCZPWy7YsG+KrrcX6FtylLAeqiCNy8tj x3kF5WigqHQoq+ks1pl2OfK7ldqzaB0= X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr7154155pld.43.1537987039876; Wed, 26 Sep 2018 11:37:19 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:01 -0700 Message-Id: <20180926183709.21293-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::529 Subject: [Qemu-devel] [PULL 05/13] test-qht: test deletion of the last entry in a bucket 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This improves coverage by one (!) LoC in qht.c, bringing the coverage rate up from 90.00% to 90.28%. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/tests/test-qht.c b/tests/test-qht.c index 05b1d6807a..77666e8c5f 100644 --- a/tests/test-qht.c +++ b/tests/test-qht.c @@ -172,9 +172,20 @@ static void qht_do_test(unsigned int mode, size_t init_entries) qht_init(&ht, is_equal, 0, mode); rm_nonexist(0, 4); + /* + * Test that we successfully delete the last element in a bucket. + * This is a hard-to-reach code path when resizing is on, but without + * resizing we can easily hit it if init_entries <= 1. + * Given that the number of elements per bucket can be 4 or 6 depending on + * the host's pointer size, test the removal of the 4th and 6th elements. + */ insert(0, 4); rm_nonexist(5, 6); - insert(4, 6); + rm(3, 4); + check_n(3); + insert(3, 6); + rm(5, 6); + check_n(5); rm_nonexist(7, 8); iter_rm_mod(1); From patchwork Wed Sep 26 18:37:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147637 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071377lji; Wed, 26 Sep 2018 11:43:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV60d3YiN64afsdEOz/eRfwFB4YjKRE6H4F4qIrB6B3j8DwU4EhcLV1L8O7Qq511jzXa2IaLz X-Received: by 2002:ae9:ebce:: with SMTP id b197-v6mr2220266qkg.169.1537987384169; Wed, 26 Sep 2018 11:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987384; cv=none; d=google.com; s=arc-20160816; b=NN2FcK7xo3FLpPp0G7xbBqtHfNFEEjVnM/LZmTbHqxe01/ruwsnuas9AgHDLAZO1K5 pk82CulQMm4WGxG6KobLN0IWKKJNleopUtIfiPuy0hoHLJwP9E9AEipNIsh+Ryb2BuYz KPs1IFQRepy2tTYMFdHFd+hm0ijYB6CqIRuC+63AAmtQEnk4SpYZkfnxvJywqMmbskHf ts20RztRoU4e2rZP9pxiydAF6x3d+jCC/NuqQPpXYakiq9Dx97TzktC4bYqtasimNNZi S0wE/lj5Q8GDbyQazs0v9AGcSDwlFebb0jK3foAUxUOdpngZlFr71DSf+nEhvqJXdxlf s2WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=ebrH3/WC1cnAKldKn/Zvg23FIfD9KDexrgYk70Bbezs=; b=HTDhu7rErnPBdb5xNMpothnjxqo9a5U96IKNNtHFpPEbRKIvfqWTv0ambD2TAo1G+d QH86G7Ae2CTTBIx0yJ8Yj91Z6D+ev0lW1pkUCobkYYt5OVI4WBL7AELf6Pc8A37xw7wm OPf9ecu3bTtTly+uvgMvISQdSTrORU79zwvg73eUrtVRW8uktBYQGcycTg8Ks0jyBmoN nctd8iip6xWtZDiYMybtUT9cwASjQFcunxsE7Fdvy+EE8S1ImrGjVszPiz5OnyWWG6R8 ZC7BnHV91qSLbsjpyvf9DZAYLmfqLf//AY0DeoxQHUKOK8I4E9jyyFfLHtExW71cf5I/ APiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JI4lMkFv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y49-v6si5111439qtj.67.2018.09.26.11.43.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:43:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=JI4lMkFv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Em7-00085u-Hc for patch@linaro.org; Wed, 26 Sep 2018 14:43:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egm-0001b3-Eg for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egj-0007O3-0s for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:38085) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egf-0007H3-B8 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:26 -0400 Received: by mail-pf1-x432.google.com with SMTP id x17-v6so13885368pfh.5 for ; Wed, 26 Sep 2018 11:37:22 -0700 (PDT) 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=ebrH3/WC1cnAKldKn/Zvg23FIfD9KDexrgYk70Bbezs=; b=JI4lMkFvJ+HDRmoymUuA/sPQySJy9X9UKG9c6cQwOyhmLGZs0/k8B+FiQh6DrdwKx9 1/fVAwKPT+IVRzM0DP8HsUshxXIB7f8KlDqZej0+zRkZ0/3nhRkpRFraOnf2CKxaZOuN CSFidrwDkA0SDbX8IntZ4xOvtDoRQUyTJe/3I= 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=ebrH3/WC1cnAKldKn/Zvg23FIfD9KDexrgYk70Bbezs=; b=ObMzaHpHTMZYaCKa2+fE8OLmSIt9RBHfce3FJVfbiZ6r262vb2EyCv5v1FIUkbDlay spPbsAiFJTR8cvFlcFMOx0vMySKEUmtV5df8MCOBr8ygJMOwoZu8qpJj7ZgfkPQuGDSa i5Ln7SasMl6gmFpAQLTJFWg3MrCrb5r0Lmzsga2iHfJzFfguIJo0QTjN46BxKygscb42 ZLlZnwkrjyhxAo2QRn3+Xuo5KShTPFp9I9gXeD9MhyQce2uOc7saU9cAI/zsysjsCCSm g6sx5acLetVus0ddRb9aK9mLDqDaPSF74GG+TMSGbnoZ+/dcPAVHdiJfPP2uPeC2rwKh 4Uhw== X-Gm-Message-State: ABuFfogL8g06RBoPA3tqgXmQ5qxL9FIEtC3MWNZilZVxRQv3tjEiKkuX ZtFH1dO263G9CWyEADq7+6RGg8Xo6fM= X-Received: by 2002:a63:5558:: with SMTP id f24-v6mr6883346pgm.37.1537987041284; Wed, 26 Sep 2018 11:37:21 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:02 -0700 Message-Id: <20180926183709.21293-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::432 Subject: [Qemu-devel] [PULL 06/13] test-qht: speed up + test qht_resize 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Perform first the tests that exercise code paths that are easier to hit at small table sizes, and then resize the table to speed up subsequent tests. If this resize is not too large, we can make the test faster with no code coverage loss. - With gcov enabled: Before: 20.568s, 90.28% qht.c coverage After: 5.168s, 93.06% qht.c coverage The coverage increase is entirely due to calling qht_resize, which we weren't calling before. Note that the code paths that remain to be tested are either error handling or can only occur when several threads are accessing the hash table concurrently (e.g. seqlock retry, trylock fail). - Without gcov: Before: 1.987s After: 0.528s The speedup is almost the same as with gcov, although the "before" run is a lot faster. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 4 ++++ 1 file changed, 4 insertions(+) -- 2.17.1 diff --git a/tests/test-qht.c b/tests/test-qht.c index 77666e8c5f..1ec039d636 100644 --- a/tests/test-qht.c +++ b/tests/test-qht.c @@ -189,6 +189,10 @@ static void qht_do_test(unsigned int mode, size_t init_entries) rm_nonexist(7, 8); iter_rm_mod(1); + if (!(mode & QHT_MODE_AUTO_RESIZE)) { + qht_resize(&ht, init_entries * 4 + 4); + } + check_n(0); rm_nonexist(0, 10); insert(0, N); From patchwork Wed Sep 26 18:37:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147640 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1073592lji; Wed, 26 Sep 2018 11:45:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV626iujCiKOy7v8Nn89UbG1tgDRNrnjJTkXUD8kgIvBEQCqlx4esdcvKzIJnlBe9tj7uoT9N X-Received: by 2002:a0c:919d:: with SMTP id n29-v6mr5339045qvn.142.1537987533627; Wed, 26 Sep 2018 11:45:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987533; cv=none; d=google.com; s=arc-20160816; b=LDeCfUmgW8Pt2Doj5hdNt39uoaDmfuyJAO8em7t73HGZGJfwn/YGiyO425xGnXD0L9 cdiC8NXB2d6k8RQZuOjJ+HexoScCk3eYdi+Afs1cFGVZt19x6Fw6zkGQh1Q87gV7D7QN p/7E3h72t67TDHCPueamVvY+Mhhw4yR1JMWlzGNQtWWPT+CAS1TsEh8Fq+G9VCt4b/lr i/mZ+yvoaeYhoh9R/e+RDa5dR3jDydMhWXIf244cs/+akd8DTESMy8b2Dmn92VKDMcWx 9pCtyGYDJYw7/xYqi+OzrEkMGf+GNBhiNYJtHpCe9D1pod0LUwQZow9BTh4eQs5VeVE+ HnZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=6O3y7EPp0gLOEI+mDlJAklujfyitZj2fuA3k8uoUzr8=; b=xWfJ8xNaKtynawh4UDyf/FoBiQpQczB73dJn/MrqBLU/ZkVWL/7m0U6ltN4wSA4dGY DYn2tnXvUG/1Je9x8BAvozuVG//ZHQy4Fx3MMqgVbWVMvMU7VWnDPdFfG7Rw17OFqbiV 7yCNwBRtaR462fY4D8C6U1Sn1tBOPXVjhOYuxWzWqnj/rNcijfTX8Fgkw/ioWa4AFGiO j4DXheRLCDTvVPEmeLg0SqGsH3P0CEEU2z5sJsEgC3fLrH5qvYNhs1zuaYL4wSh2EwTR cnwzsNeF2NiOMQJIZhuD9Pos66huXczRxHEL/oCkrBqi/OI/yRCsqGBJ5q1oqgpaIL9z NDpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kvqGDCLz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l189-v6si4655211qkd.32.2018.09.26.11.45.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:45:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kvqGDCLz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EoX-0001sP-0g for patch@linaro.org; Wed, 26 Sep 2018 14:45:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egm-0001ax-B5 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egj-0007Of-Sr for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]:42882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egg-0007Hv-33 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:27 -0400 Received: by mail-pf1-x443.google.com with SMTP id l9-v6so13887066pff.9 for ; Wed, 26 Sep 2018 11:37:24 -0700 (PDT) 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=6O3y7EPp0gLOEI+mDlJAklujfyitZj2fuA3k8uoUzr8=; b=kvqGDCLzSZuGxLbzv8TA+HeX1tgA5ftS2s1apwwpWIeHtBdQ8YWoLhFMxBtVv64EtH LyYXKT7l/pURaIMnNRSYhzgXrSQaphu2k60REPxl14ZoJiUfiqAC0JltI32FCOCS1t19 CMrmxWP+pAxS4vGoYhNMC4VNAhRVL3+vakpfU= 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=6O3y7EPp0gLOEI+mDlJAklujfyitZj2fuA3k8uoUzr8=; b=lAFDU8ntrC4pBvM46wVChFtrk0o+Xb0+ecKCfU1LrcFTT95NSIAd+GPpWD9tE+TLJg km+X+tcQJ3udxj7I8mguBK4ExrPqGx3zXknjTK25c/sdr0yj199n33xbE5NpcARhGz+A uwJSrhy2zXzMgZaewEHlqSdINw72CsiKkJsrhN2UULiqJCUJQZ64pNaMXppEk6KrMJmj ePividzLLkzwqyiovw4pbymhajudyBI46oixlws6zjCHtaSTd/zyVusuw95g4qq+cC8U R79Dc91Xyh6wnQz81CDRRQVNTRRnNKE7ETfeKQyrapdk2VHXcvKX+luzaTWfFowFoUeY /kjw== X-Gm-Message-State: ABuFfohLgc9z3CQbr/6x+n9gIcAQJqVvk56kyGDDGNC6yO/HMLcwiOH5 ww3V3v7rfy6eyXP6w3Q6z9XnIrZ/KmU= X-Received: by 2002:a17:902:4e:: with SMTP id 72-v6mr7275285pla.318.1537987042845; Wed, 26 Sep 2018 11:37:22 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:03 -0700 Message-Id: <20180926183709.21293-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::443 Subject: [Qemu-devel] [PULL 07/13] qht: drop ht argument from qht iterators 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Accessing the HT from an iterator results almost always in a deadlock. Given that only one qht-internal function uses this argument, drop it from the interface. Suggested-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/qemu/qht.h | 5 ++--- accel/tcg/translate-all.c | 6 ++---- tests/test-qht.c | 6 +++--- util/qht.c | 29 +++++++++++++++++++---------- util/qsp.c | 11 +++++------ 5 files changed, 31 insertions(+), 26 deletions(-) -- 2.17.1 diff --git a/include/qemu/qht.h b/include/qemu/qht.h index 3a9618db69..6484837487 100644 --- a/include/qemu/qht.h +++ b/include/qemu/qht.h @@ -43,9 +43,8 @@ struct qht_stats { }; typedef bool (*qht_lookup_func_t)(const void *obj, const void *userp); -typedef void (*qht_iter_func_t)(struct qht *ht, void *p, uint32_t h, void *up); -typedef bool (*qht_iter_bool_func_t)(struct qht *ht, void *p, uint32_t h, - void *up); +typedef void (*qht_iter_func_t)(void *p, uint32_t h, void *up); +typedef bool (*qht_iter_bool_func_t)(void *p, uint32_t h, void *up); #define QHT_MODE_AUTO_RESIZE 0x1 /* auto-resize when heavily loaded */ #define QHT_MODE_RAW_MUTEXES 0x2 /* bypass the profiler (QSP) */ diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 898c3bb3d1..9ffbbc2fbd 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1282,8 +1282,7 @@ void tb_flush(CPUState *cpu) */ #ifdef CONFIG_USER_ONLY -static void -do_tb_invalidate_check(struct qht *ht, void *p, uint32_t hash, void *userp) +static void do_tb_invalidate_check(void *p, uint32_t hash, void *userp) { TranslationBlock *tb = p; target_ulong addr = *(target_ulong *)userp; @@ -1304,8 +1303,7 @@ static void tb_invalidate_check(target_ulong address) qht_iter(&tb_ctx.htable, do_tb_invalidate_check, &address); } -static void -do_tb_page_check(struct qht *ht, void *p, uint32_t hash, void *userp) +static void do_tb_page_check(void *p, uint32_t hash, void *userp) { TranslationBlock *tb = p; int flags1, flags2; diff --git a/tests/test-qht.c b/tests/test-qht.c index 1ec039d636..4d23cefab6 100644 --- a/tests/test-qht.c +++ b/tests/test-qht.c @@ -98,7 +98,7 @@ static void check(int a, int b, bool expected) qht_statistics_destroy(&stats); } -static void count_func(struct qht *ht, void *p, uint32_t hash, void *userp) +static void count_func(void *p, uint32_t hash, void *userp) { unsigned int *curr = userp; @@ -122,7 +122,7 @@ static void iter_check(unsigned int count) g_assert_cmpuint(curr, ==, count); } -static void sum_func(struct qht *ht, void *p, uint32_t hash, void *userp) +static void sum_func(void *p, uint32_t hash, void *userp) { uint32_t *sum = userp; uint32_t a = *(uint32_t *)p; @@ -138,7 +138,7 @@ static void iter_sum_check(unsigned int expected) g_assert_cmpuint(sum, ==, expected); } -static bool rm_mod_func(struct qht *ht, void *p, uint32_t hash, void *userp) +static bool rm_mod_func(void *p, uint32_t hash, void *userp) { uint32_t a = *(uint32_t *)p; unsigned int mod = *(unsigned int *)userp; diff --git a/util/qht.c b/util/qht.c index c190e89f5b..50ed7a2102 100644 --- a/util/qht.c +++ b/util/qht.c @@ -746,7 +746,7 @@ bool qht_remove(struct qht *ht, const void *p, uint32_t hash) return ret; } -static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *head, +static inline void qht_bucket_iter(struct qht_bucket *head, const struct qht_iter *iter, void *userp) { struct qht_bucket *b = head; @@ -759,10 +759,10 @@ static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *head, } switch (iter->type) { case QHT_ITER_VOID: - iter->f.retvoid(ht, b->pointers[i], b->hashes[i], userp); + iter->f.retvoid(b->pointers[i], b->hashes[i], userp); break; case QHT_ITER_RM: - if (iter->f.retbool(ht, b->pointers[i], b->hashes[i], userp)) { + if (iter->f.retbool(b->pointers[i], b->hashes[i], userp)) { /* replace i with the last valid element in the bucket */ seqlock_write_begin(&head->sequence); qht_bucket_remove_entry(b, i); @@ -782,14 +782,14 @@ static inline void qht_bucket_iter(struct qht *ht, struct qht_bucket *head, } /* call with all of the map's locks held */ -static inline void qht_map_iter__all_locked(struct qht *ht, struct qht_map *map, +static inline void qht_map_iter__all_locked(struct qht_map *map, const struct qht_iter *iter, void *userp) { size_t i; for (i = 0; i < map->n_buckets; i++) { - qht_bucket_iter(ht, &map->buckets[i], iter, userp); + qht_bucket_iter(&map->buckets[i], iter, userp); } } @@ -800,8 +800,7 @@ do_qht_iter(struct qht *ht, const struct qht_iter *iter, void *userp) map = atomic_rcu_read(&ht->map); qht_map_lock_buckets(map); - /* Note: ht here is merely for carrying ht->mode; ht->map won't be read */ - qht_map_iter__all_locked(ht, map, iter, userp); + qht_map_iter__all_locked(map, iter, userp); qht_map_unlock_buckets(map); } @@ -825,9 +824,16 @@ void qht_iter_remove(struct qht *ht, qht_iter_bool_func_t func, void *userp) do_qht_iter(ht, &iter, userp); } -static void qht_map_copy(struct qht *ht, void *p, uint32_t hash, void *userp) +struct qht_map_copy_data { + struct qht *ht; + struct qht_map *new; +}; + +static void qht_map_copy(void *p, uint32_t hash, void *userp) { - struct qht_map *new = userp; + struct qht_map_copy_data *data = userp; + struct qht *ht = data->ht; + struct qht_map *new = data->new; struct qht_bucket *b = qht_map_to_bucket(new, hash); /* no need to acquire b->lock because no thread has seen this map yet */ @@ -845,6 +851,7 @@ static void qht_do_resize_reset(struct qht *ht, struct qht_map *new, bool reset) .f.retvoid = qht_map_copy, .type = QHT_ITER_VOID, }; + struct qht_map_copy_data data; old = ht->map; qht_map_lock_buckets(old); @@ -859,7 +866,9 @@ static void qht_do_resize_reset(struct qht *ht, struct qht_map *new, bool reset) } g_assert(new->n_buckets != old->n_buckets); - qht_map_iter__all_locked(ht, old, &iter, new); + data.ht = ht; + data.new = new; + qht_map_iter__all_locked(old, &iter, &data); qht_map_debug__all_locked(new); atomic_rcu_set(&ht->map, new); diff --git a/util/qsp.c b/util/qsp.c index b0c2575d10..2de3a97594 100644 --- a/util/qsp.c +++ b/util/qsp.c @@ -533,7 +533,7 @@ static gint qsp_tree_cmp(gconstpointer ap, gconstpointer bp, gpointer up) } } -static void qsp_sort(struct qht *ht, void *p, uint32_t h, void *userp) +static void qsp_sort(void *p, uint32_t h, void *userp) { QSPEntry *e = p; GTree *tree = userp; @@ -541,7 +541,7 @@ static void qsp_sort(struct qht *ht, void *p, uint32_t h, void *userp) g_tree_insert(tree, e, NULL); } -static void qsp_aggregate(struct qht *global_ht, void *p, uint32_t h, void *up) +static void qsp_aggregate(void *p, uint32_t h, void *up) { struct qht *ht = up; const QSPEntry *e = p; @@ -553,7 +553,7 @@ static void qsp_aggregate(struct qht *global_ht, void *p, uint32_t h, void *up) qsp_entry_aggregate(agg, e); } -static void qsp_iter_diff(struct qht *orig, void *p, uint32_t hash, void *htp) +static void qsp_iter_diff(void *p, uint32_t hash, void *htp) { struct qht *ht = htp; QSPEntry *old = p; @@ -583,8 +583,7 @@ static void qsp_diff(struct qht *orig, struct qht *new) qht_iter(orig, qsp_iter_diff, new); } -static void -qsp_iter_callsite_coalesce(struct qht *orig, void *p, uint32_t h, void *htp) +static void qsp_iter_callsite_coalesce(void *p, uint32_t h, void *htp) { struct qht *ht = htp; QSPEntry *old = p; @@ -603,7 +602,7 @@ qsp_iter_callsite_coalesce(struct qht *orig, void *p, uint32_t h, void *htp) e->n_acqs += old->n_acqs; } -static void qsp_ht_delete(struct qht *ht, void *p, uint32_t h, void *htp) +static void qsp_ht_delete(void *p, uint32_t h, void *htp) { g_free(p); } From patchwork Wed Sep 26 18:37:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147634 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071197lji; Wed, 26 Sep 2018 11:42:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV635hyISBpU2IMPYcj0ldV1AN5eXs4Hk5j/8+1UB7aFN3iX4MOAw6t88BLHjWIlGSIbYDvhU X-Received: by 2002:ac8:3261:: with SMTP id y30-v6mr5506691qta.175.1537987370884; Wed, 26 Sep 2018 11:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987370; cv=none; d=google.com; s=arc-20160816; b=zCtQOptvg7VKlSV8zxTRb2awFIuDIOuvPmh8l1hUKHpEPzcPWElGjynlHeokZK+yMQ YPaTYOLf6/hbThvwc2eUjlv+kShzDDMbIiC85VLgmBQd/PYDrmGDA0ULW/kurSqWp2MT /LyCiMHhkTOuxNqYvBaqCpvqmdQCTUidatupOWIynFa1tLPsvjvFukl0JMAW22xUDOOv 7hfhSOnRT9lqhLHI9kc8VFWP7DWk35WGA43pD/atodXMi67vZp3aVV0dyuiYiybB3kRV /cDCrsptPUSPlM4+Q4+tN1PFTUTwu4icplmpI2TYbH8TNmqDsHBnfAPd0kPYs1FMNFK3 bYnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=AnCH50U7I6tXeQtvHhpIdu3fLssyQjo4EKeF42v2kqA=; b=B7vPlN4sNbQf65Fnkl+mYIWcOfcBQKj8wWdxmke1dRShEAG/C+ttARjlLaP2H0TL4Q 6IdvW0cP6dm1oZprcrTvdOPyVQXEkTPn24QZWoMB0vGyNxAsarH4t6KXUTHhzHuTo5YO Xi2jtvAW9gs6eiHuTw/fxHkVXw7BflLf8Te2fG6MILd5gDxD6YXMVaVNzDqZRxAis3Wb ngXVlufYpHjkkErPj5WZVy3fLAglLyMhrmG0Qw8pqHSYfByOePfHAiN6NIfaFk4qHh5r whPx6IRNHjiFf3StepXy87Pm8OWlTGSlNz4ISWlv7bqTbxt6cKoyBX3juPv7I7SH2T0Z X6LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g+3g78+s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s35-v6si4588979qvj.130.2018.09.26.11.42.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:42:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=g+3g78+s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Elu-0007u8-8v for patch@linaro.org; Wed, 26 Sep 2018 14:42:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egm-0001b4-Eh for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007P7-Aa for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:37377) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egj-0007K7-VP for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x52a.google.com with SMTP id c10-v6so7418355pgq.4 for ; Wed, 26 Sep 2018 11:37:25 -0700 (PDT) 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; bh=AnCH50U7I6tXeQtvHhpIdu3fLssyQjo4EKeF42v2kqA=; b=g+3g78+sIsSL71L685lDfBffI59HMjmej/hYltWHel6cldwdPPuwwpauPag+8skk6A hkSP4TXbjdMw0ZncovYNpKkrsmwFtSaENeeMEsWIUyYMjFsOURQnStYCjhKLIogtHEAn KMo9TiKBtcUaKlEEjio7Zl6pkH6AvuVBrszl4= 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; bh=AnCH50U7I6tXeQtvHhpIdu3fLssyQjo4EKeF42v2kqA=; b=CKmlIOI/rZjfrWoykk1OKT25RYN0kl44cDw5R98K/tve6Cknes4KwdJSP7PZ7miFSf gEvtJ6nmimus9tLEbMSIDaejWcnSJDPcaxikWs5SqYJ4mE1l+ISdClXPpEOhsEEvA2hV +RdR67GyhyThBO5RpkI9csPQ1XFsRe/WSD/V1LB5dG+s8xNsLpGCJvLorKfAGKClVrWS tEhlSCoV03YX7QpHUBpng3A8QYux9x8QcAG+oxecljLxqueSKCiqNJGhtPkvH39w4B3H ziKOnwjV2Tr9UnWMTnifsGIfR4L1RIj2+XrwkxAFw9n4CkdYpgy4KDey+PUGU4HxWXgl YKiw== X-Gm-Message-State: ABuFfoj63xNNvc2bKkYdR+jDUjELz22Xy4eUIF9fB29P0Uv+ZGx6858j YDzgTkq8LBg++zj/tSbm4XpnBbcK2gw= X-Received: by 2002:a17:902:b90b:: with SMTP id bf11-v6mr7414692plb.52.1537987044350; Wed, 26 Sep 2018 11:37:24 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:23 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:04 -0700 Message-Id: <20180926183709.21293-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52a Subject: [Qemu-devel] [PULL 08/13] qht: fix comment in qht_bucket_remove_entry 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- util/qht.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/util/qht.c b/util/qht.c index 50ed7a2102..3564a7e20f 100644 --- a/util/qht.c +++ b/util/qht.c @@ -671,7 +671,7 @@ qht_entry_move(struct qht_bucket *to, int i, struct qht_bucket *from, int j) } /* - * Find the last valid entry in @head, and swap it with @orig[pos], which has + * Find the last valid entry in @orig, and swap it with @orig[pos], which has * just been invalidated. */ static inline void qht_bucket_remove_entry(struct qht_bucket *orig, int pos) From patchwork Wed Sep 26 18:37:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147642 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1073987lji; Wed, 26 Sep 2018 11:45:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV63PzZmCrSXGSPClVrqGVzCAoNmRZ2+CWVsD1m2jM1FyZ8eqRkb1GH3NniUPOygox+qOvp7t X-Received: by 2002:a37:1413:: with SMTP id e19-v6mr5117636qkh.295.1537987559520; Wed, 26 Sep 2018 11:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987559; cv=none; d=google.com; s=arc-20160816; b=HtZctp2lwXwVb2b900O9prAjmDudwoQlZuPAGRyRPzGo2iSYBGTpcAu9iYrt/fB55d myiM6rfyRpU7A95AO91tWoCgMLPt1PvifwFidcxde6MCfbpBbf9noXizGPB83E2wloU8 cgcoAgCXX9FFZ0d1ooKDQyOngufO8wVXTI2zffYzkEue0+eAPu9t4Rendp3IMmwYFqwp al0fIkhCuxwivv17i8ACei8Vt3hL3bGlge0f2u25SXYegkHhifpSV/NuHFRVHMGFenUW hcX0k6CbaV26pWAMVRYOMx3VocF14owip82i6LNsondpwsKkh8a3P+bOA7cfXQ/nIlQt X2xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=0BtRPf/GqT2Gcz1kpvT8HmkgarCmz1fRFhyUubjsPFc=; b=j3IoTOV+u5aYecG4qvgX2y29+Axhegr4r8W6ufdWqtsE95oosWRP2b4EjfGEsqnMuM P+0y5oJhdeXowvciy1kLi4drt/khuli2A0fEJx2Td8kP9vtKdnQGbFak5L0nPW1sImcN NXlIB+pfbz7KhADNMVyFplS9FbLluzA2k2UJyvgeAJMN6GJuBkZ9nrflMXvM+6irH0TK QSMEVQP9nFQ3SvYo2LliZKk3/MjDy25RTTV88+Znw3gQrDiT0XGrLGXlbNr9KJWbALV2 NWicqXPVKMfrh6K44X6Bn+4pITwsJE+jmmJopwXr5V5BHWp21sWh9Qtnc8W5517YZDzr 7HMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jeWBsXWZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k79-v6si2368938qke.129.2018.09.26.11.45.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:45:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jeWBsXWZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eow-0001xc-V3 for patch@linaro.org; Wed, 26 Sep 2018 14:45:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egn-0001hE-QT for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007Pt-Nb for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:40831) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egk-0007Mf-Dt for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x543.google.com with SMTP id n31-v6so7527749pgm.7 for ; Wed, 26 Sep 2018 11:37:27 -0700 (PDT) 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; bh=0BtRPf/GqT2Gcz1kpvT8HmkgarCmz1fRFhyUubjsPFc=; b=jeWBsXWZP4y0nToQs5ITONjrl06hO7Tt8rzyjVyFzWTBfEQxg8Ew9q8Mbu1F7Mt0Ia 6dVnw/FR3CoRzKMJcfGipHHCgkyj2/8ISH62T5biUmWuZbQM66J9zjLhZH4/UXIhM0tB 21Htme5xQEB7wAgIW4EumzecpUdSrQIfDRm2M= 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; bh=0BtRPf/GqT2Gcz1kpvT8HmkgarCmz1fRFhyUubjsPFc=; b=UlWdnCT40FUM1y3f7fV/tUasFB5Dcu+xsGHlYfBmfBDn4y6FGBWcbZTwINPEAIk2ut CfxKu+ogeBHWwQHe+hhk0kqBDst8Ms6mWEkNm+Rrr4rvmqFW9iFVIwPgUl/uQpxIcyNT kdXTFzqs3bfe4JM1OB2ZQ7o8z5Q6utQRbaBcva7gCqR6TiQ6rX5g1e33HK3ROynOhu5h tMxH137bQ7OWF+rDMeKITFYY6BDfayYTydbfId8s3sDnv1DidmCaP/kpSa/g6BcBUmb+ 2/hZnXb3vdNkkCB2ULJXjCtsYnSzJ3hdOUsFD9DNd/62FVrUamdi7fPclbCh/fqjKRAs 2zkg== X-Gm-Message-State: ABuFfoj3dK/Yd2ERGWUFbNCohNCryWe6RUCEMVxS6UAHUCyuEDSDjdd6 1eC6uq85XHTgmlDhExsb2QRjen/WdRU= X-Received: by 2002:a62:20d8:: with SMTP id m85-v6mr7573490pfj.74.1537987046016; Wed, 26 Sep 2018 11:37:26 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:05 -0700 Message-Id: <20180926183709.21293-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 Subject: [Qemu-devel] [PULL 09/13] qht: constify qht_lookup 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" seqlock_read_begin takes a const param since c04649eeea ("seqlock: constify seqlock_read_begin", 2018-08-23), so we can constify the entire lookup. Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/qemu/qht.h | 4 ++-- util/qht.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/include/qemu/qht.h b/include/qemu/qht.h index 6484837487..2e2d6bca93 100644 --- a/include/qemu/qht.h +++ b/include/qemu/qht.h @@ -104,7 +104,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash, void **existing); * Returns the corresponding pointer when a match is found. * Returns NULL otherwise. */ -void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, +void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t hash, qht_lookup_func_t func); /** @@ -115,7 +115,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, * * Calls qht_lookup_custom() using @ht's default comparison function. */ -void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash); +void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash); /** * qht_remove - remove a pointer from the hash table diff --git a/util/qht.c b/util/qht.c index 3564a7e20f..020dfe6912 100644 --- a/util/qht.c +++ b/util/qht.c @@ -236,7 +236,7 @@ static inline void qht_head_init(struct qht_bucket *b) } static inline -struct qht_bucket *qht_map_to_bucket(struct qht_map *map, uint32_t hash) +struct qht_bucket *qht_map_to_bucket(const struct qht_map *map, uint32_t hash) { return &map->buckets[hash & (map->n_buckets - 1)]; } @@ -482,10 +482,10 @@ bool qht_reset_size(struct qht *ht, size_t n_elems) } static inline -void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, +void *qht_do_lookup(const struct qht_bucket *head, qht_lookup_func_t func, const void *userp, uint32_t hash) { - struct qht_bucket *b = head; + const struct qht_bucket *b = head; int i; do { @@ -509,7 +509,7 @@ void *qht_do_lookup(struct qht_bucket *head, qht_lookup_func_t func, } static __attribute__((noinline)) -void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, +void *qht_lookup__slowpath(const struct qht_bucket *b, qht_lookup_func_t func, const void *userp, uint32_t hash) { unsigned int version; @@ -522,11 +522,11 @@ void *qht_lookup__slowpath(struct qht_bucket *b, qht_lookup_func_t func, return ret; } -void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, +void *qht_lookup_custom(const struct qht *ht, const void *userp, uint32_t hash, qht_lookup_func_t func) { - struct qht_bucket *b; - struct qht_map *map; + const struct qht_bucket *b; + const struct qht_map *map; unsigned int version; void *ret; @@ -545,7 +545,7 @@ void *qht_lookup_custom(struct qht *ht, const void *userp, uint32_t hash, return qht_lookup__slowpath(b, func, userp, hash); } -void *qht_lookup(struct qht *ht, const void *userp, uint32_t hash) +void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash) { return qht_lookup_custom(ht, userp, hash, ht->cmp); } From patchwork Wed Sep 26 18:37:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147639 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071781lji; Wed, 26 Sep 2018 11:43:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV60OhTW3Sqyx32X4kTBCsnB0bBwIqpVqojQcAwXL2IXekj5/YVLkS7rd+ECvxriTms/3VyjB X-Received: by 2002:a0c:e3d0:: with SMTP id e16-v6mr3855279qvl.243.1537987413883; Wed, 26 Sep 2018 11:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987413; cv=none; d=google.com; s=arc-20160816; b=W+BopEYVYBhSmaSiEV44KO2hLEMaurzucmPb9hQG5bRfBc4lriXGcb0bG2UHBN6DEy ydkYyj6AF0YICIRHTebS1nAWb1RIZQ0E5fFvN9sbvDBrMkLCHDJUyPFuVpy0XpEtKH3w iD6KJIw6q3jC8+1jQzeElQgGx2MTMbVRf2DjZ7Vb0rRSR0Gbkh2CvTWQpyddEKwcuxiV Q59mlNfmok7ebovB5noVCJBVjw4fPD7eqf7BhdGs3nRSoVqW7UT3e+ImoBkfLdHh7IJz t93unMBW23DdVFZLzTNs4u3Xnb2d6xAyYDGPva0vCBXXq5NAethwKZWE5DHqvJSMqYx1 LJdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=2f+ugjPHLeSDiiV6/XWDzcoxvvv3dDlF86QnrCsUJ/k=; b=FnO7OOhxk/Si2hFx7yy2wMZLyr3EnTDS5M8NRQE5Xc+WODPwQqsc3lkJdescRq/7v7 6pyD4tdybCeXPtvIOTHpzl7ojTaTCVHmWoHUeZI48k9k/kiWI1uxWfNBl9VZYh1bPjMW 2dcyauOHsMTjjdi3br8mOYsJBVehEq8pBHWhgnh8gGCoIqdhWg1+csXmGDE9gEE23vzW oA+/MrV0m4FBvYNYKbgBSO3YjCQQHKz7Ge5jtq78XaJ35TXVCD5q9viXog/Q6hNaCX9L m3JiyHpAw/f7cqxdLi8BfFlwh+ryChm9uj3sR6W3gExi3EL397VE1MKCeuEuifNCEP55 SVDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B+vSnhvD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d8-v6si2335541qtg.271.2018.09.26.11.43.33 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=B+vSnhvD; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Ema-00089f-N3 for patch@linaro.org; Wed, 26 Sep 2018 14:43:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egm-0001b7-Fw for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007P1-8w for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:46887) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egj-0007Np-UQ for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x52e.google.com with SMTP id b129-v6so14389290pga.13 for ; Wed, 26 Sep 2018 11:37:28 -0700 (PDT) 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; bh=2f+ugjPHLeSDiiV6/XWDzcoxvvv3dDlF86QnrCsUJ/k=; b=B+vSnhvDxrIswzM9anfSrZi4PwRbyjNkYEHn2hYsnmgatP8ECngmkXm8yzvqrG+2Sf BKfPNkj3woTdXUWTfJSVFIr/WUYffT7z3UTze2fHmiY7OHrYSdS5cBCpS5zB2yFXdkwT njWK4UNveXr6qmuZ5y4dwizPTldnQWf7YFeA0= 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; bh=2f+ugjPHLeSDiiV6/XWDzcoxvvv3dDlF86QnrCsUJ/k=; b=NcNTURRYo7JdQXXUMjEIymlbu0Yw/gmVEbw7TQk7NOsDITI8V30Og1NdaZMiAxNmwX icjv4p3v0jVwtVtuk7InkjtA4H9najgmMA8mJEIVcYX17lTCodomtweFhDZi0ObD2fu1 0YVMeLqq1TOINEEOtlu3tphdegm34fboC/zSe/oHUgLKZIij6d9vHgok28pvtXlY3dzJ nkbNcOIsfyqr8PNg/Gr1PtwAaFTSvpQCzs3TQqZo9M7sfeFWc44e0OQDn80ZWm70NvMQ 7FryLa8hXskqeLvcl5sfVCvYlEVk7qTswOTeHpToaCDllSVoMxiU8K0s9hqrK8laFcLf rH8A== X-Gm-Message-State: ABuFfohTACXR4geKNpd7E1bZktnvlTdVLUBDdz9NIqEaBYmuPFjWRPnd p2K3NBrA3NRsgtEumhKumjJG3LczRjM= X-Received: by 2002:a63:7b09:: with SMTP id w9-v6mr6926880pgc.385.1537987047747; Wed, 26 Sep 2018 11:37:27 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:06 -0700 Message-Id: <20180926183709.21293-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52e Subject: [Qemu-devel] [PULL 10/13] qht: constify qht_statistics_init 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- include/qemu/qht.h | 2 +- util/qht.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) -- 2.17.1 diff --git a/include/qemu/qht.h b/include/qemu/qht.h index 2e2d6bca93..758c7ac6c8 100644 --- a/include/qemu/qht.h +++ b/include/qemu/qht.h @@ -211,7 +211,7 @@ void qht_iter_remove(struct qht *ht, qht_iter_bool_func_t func, void *userp); * When done with @stats, pass the struct to qht_statistics_destroy(). * Failing to do this will leak memory. */ -void qht_statistics_init(struct qht *ht, struct qht_stats *stats); +void qht_statistics_init(const struct qht *ht, struct qht_stats *stats); /** * qht_statistics_destroy - Destroy a &struct qht_stats diff --git a/util/qht.c b/util/qht.c index 020dfe6912..4378775d68 100644 --- a/util/qht.c +++ b/util/qht.c @@ -895,9 +895,9 @@ bool qht_resize(struct qht *ht, size_t n_elems) } /* pass @stats to qht_statistics_destroy() when done */ -void qht_statistics_init(struct qht *ht, struct qht_stats *stats) +void qht_statistics_init(const struct qht *ht, struct qht_stats *stats) { - struct qht_map *map; + const struct qht_map *map; int i; map = atomic_rcu_read(&ht->map); @@ -914,8 +914,8 @@ void qht_statistics_init(struct qht *ht, struct qht_stats *stats) stats->head_buckets = map->n_buckets; for (i = 0; i < map->n_buckets; i++) { - struct qht_bucket *head = &map->buckets[i]; - struct qht_bucket *b; + const struct qht_bucket *head = &map->buckets[i]; + const struct qht_bucket *b; unsigned int version; size_t buckets; size_t entries; From patchwork Wed Sep 26 18:37:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147643 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1076028lji; Wed, 26 Sep 2018 11:48:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61GTGQlL02Dt5DkpTmn1o0LZFOBffGLjgOtRg0HKljKuhVZawCPXynkoOu62O75ZY47CjoC X-Received: by 2002:a37:30d4:: with SMTP id w203-v6mr1921156qkw.106.1537987688010; Wed, 26 Sep 2018 11:48:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987688; cv=none; d=google.com; s=arc-20160816; b=i010Ir19AO9sCBt98M/j5yctH4kNNKiyGGYgbpOpeji9D6OXPKKow9h8UIF8vKAu6c ssBwTQJ07fehF/lwoGb3Gddu8jMh2TymHrxsecWtWuEaGBLw8zHpT425i+dxHGEyNx9o XCb05IKLVtyNfO+ZflKtJMgjICdCdgdYOVI+bPOt3KJKEMAifPM27fUxdIUuVvuZ+4D3 BuAkGNwD2jS67Xodo3070n3bu11YL9qxafQcjJpVGd1NV6/CrUg7zGjEn8d2x+QLdND6 nUpc2hVrN/6nl9wjnPi2ip641cCzwTu0OMrRLPfIIw6+rNbkpCTe3Wy26prAsWDg37T6 nFuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=NsLRvw3oSN4zNqSaCRSuQqfhIZk6bHPznmlpK7l1Nmw=; b=P15U9O5e7GWez7Bi0VACkU9Rw44hGf6ncAiEPqCXuR+AxFgnDqj4tGj9CqrfkDfZj8 thP0r8wHtlDc10mk2hsd6UKAKNyhMzavodnX2PRXJJBrfitQb3wsuH6BYDCz/oz0sbR9 HdbbfoqU5ALKOBybzEsgLtvO7huYANzZf47bfE3L1WcZ9ZlxRF+xs1QNrmGGpbVQhG/E e4pWf0hBNAqG0J7wiqrpXZ2A5KfAQQfH266BsM3D0WG47FjJfPdOE8HB3izAOAJjx8Dv +22p+jYn+fmJoqv6wfrmE0vVfHRXcl0tEu5G4Z1VGrtG7ZDZoeOuGSZhHZ3Oyvb6L8Wq e2lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="VXQ/AaSx"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r46-v6si1609413qtc.338.2018.09.26.11.48.07 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:48:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="VXQ/AaSx"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60220 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Er1-0003gB-GH for patch@linaro.org; Wed, 26 Sep 2018 14:48:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egn-0001g5-Gy for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007Q8-TP for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:42882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egk-0007Or-N8 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pf1-x442.google.com with SMTP id l9-v6so13887252pff.9 for ; Wed, 26 Sep 2018 11:37:30 -0700 (PDT) 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; bh=NsLRvw3oSN4zNqSaCRSuQqfhIZk6bHPznmlpK7l1Nmw=; b=VXQ/AaSxIiMzQwfNiRydv8m4LPJanJjjsGrF9OOtxAo4Jd+iKydaDHLhF37o15d4CP kbtMKaMlGZUInRaS+LPPwigul6jPx3q9JSzecr/rMlaPHq5ScaXGQHafgeDhfKlSH3kF izPxYOLbIJKG34qyYcNuepIdVvKKTN9Wsnhk0= 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; bh=NsLRvw3oSN4zNqSaCRSuQqfhIZk6bHPznmlpK7l1Nmw=; b=B6kEXhYwhCTGOe4auXi825Jkieti6HkolU1hIANs5207Tehp4c6yJ3gBAmOzJe+W/O qvQ1M+27qfLcS8Dk/k0/6ntRhtT6smhr0b2OSE0VaovJqCriZ+x7Qg4EwL6gmonoUQYU jvxEvjjIm5OdU4Piuyvyts4LXWKM+2LIsdyOMOO9s9tqObscgcDrE7I5Y/gee/btEkcl 5ZGFb8XLqOBBab7sQQoIt+CQ8DRTgMxQzSbElWx3Wow1b7deRPYga23yEoufT/pD6EQD EW0bqGut7tfpQfpXN9wOtALHzfvh5AAT0YzsFfKU5xqXMy4oXkpoufU7/PP/76xYhLZy pmgA== X-Gm-Message-State: ABuFfohNP1e9L+LVU7dUTgcgZYq5orowyEuYWnZxEtjT75av1Kej6wFz 6WqzL/hxJBdZsDB8cpq7blKjX9jeAkA= X-Received: by 2002:a62:ac15:: with SMTP id v21-v6mr7641529pfe.126.1537987049339; Wed, 26 Sep 2018 11:37:29 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:07 -0700 Message-Id: <20180926183709.21293-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PULL 11/13] qht: constify arguments to some internal functions 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" These functions do not modify their @ht or @bucket arguments. Constify those arguments. Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- util/qht.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/util/qht.c b/util/qht.c index 4378775d68..aa51be3c52 100644 --- a/util/qht.c +++ b/util/qht.c @@ -268,7 +268,8 @@ static void qht_map_unlock_buckets(struct qht_map *map) * Call with at least a bucket lock held. * @map should be the value read before acquiring the lock (or locks). */ -static inline bool qht_map_is_stale__locked(struct qht *ht, struct qht_map *map) +static inline bool qht_map_is_stale__locked(const struct qht *ht, + const struct qht_map *map) { return map != ht->map; } @@ -337,12 +338,12 @@ struct qht_bucket *qht_bucket_lock__no_stale(struct qht *ht, uint32_t hash, return b; } -static inline bool qht_map_needs_resize(struct qht_map *map) +static inline bool qht_map_needs_resize(const struct qht_map *map) { return atomic_read(&map->n_added_buckets) > map->n_added_buckets_threshold; } -static inline void qht_chain_destroy(struct qht_bucket *head) +static inline void qht_chain_destroy(const struct qht_bucket *head) { struct qht_bucket *curr = head->next; struct qht_bucket *prev; @@ -550,8 +551,11 @@ void *qht_lookup(const struct qht *ht, const void *userp, uint32_t hash) return qht_lookup_custom(ht, userp, hash, ht->cmp); } -/* call with head->lock held */ -static void *qht_insert__locked(struct qht *ht, struct qht_map *map, +/* + * call with head->lock held + * @ht is const since it is only used for ht->cmp() + */ +static void *qht_insert__locked(const struct qht *ht, struct qht_map *map, struct qht_bucket *head, void *p, uint32_t hash, bool *needs_resize) { @@ -645,7 +649,7 @@ bool qht_insert(struct qht *ht, void *p, uint32_t hash, void **existing) return false; } -static inline bool qht_entry_is_last(struct qht_bucket *b, int pos) +static inline bool qht_entry_is_last(const struct qht_bucket *b, int pos) { if (pos == QHT_BUCKET_ENTRIES - 1) { if (b->next == NULL) { From patchwork Wed Sep 26 18:37:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147632 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1066829lji; Wed, 26 Sep 2018 11:38:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV61yJ+dBB5paCz/nKJRkjPQDYPj5lE/e9FABUJtdm1jsRP3+7rxLw2f8VuAoEqDQarFdi/6z X-Received: by 2002:a0c:d2b4:: with SMTP id q49-v6mr5453299qvh.46.1537987083487; Wed, 26 Sep 2018 11:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987083; cv=none; d=google.com; s=arc-20160816; b=GVuEEEkNxqpnVcCqNpbhZJ5yyEaFSsCsmv7Mm87Ayy/whWBdvbKVDRnv/9QAWNAq+y Z6ejxGN8Izt6g21d0uNOdv6LdAv5BT+YnuqYnhP4fAifhrsDndwt9RaLPsHQ88s8d7QO FtpOY/5S2Cov4m8Y7Ud5S+5xnvo9bxGv39wcXDwcQjosqbfWZ4VktzXjnrDSW2EVAFFP irenn/B0PCi4kvkNMWZBpFDKGPTp8VNNzY0Rlx4fyaWL9b+Q1bAMdGcTeSteHowCF7Av NhgPX7tFBdlAB8fJ4R+RctC6i8m+x4l9W8x2YysaG6d7SWCEn3txJj7HuFdYxmkFy/ja vQBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=gUr4Rg30kEa57DsN+a3e5NMAEgxvwTzfEYRCfyICEQw=; b=Hf9j1qoJh+vltoM8pSDStr4HomCdFL/f1cWw/VcTV8Fe/tOqocAXsoY6CWVthsIQ9v E6eFzqwW8N1yV5zE244Ffej0Ql/YulqFNQVMzg9cBE2xJvCl13DZcQNBk18HG+T0hiKx 1seHIf47y+T84CeC9EmMHWU8wLVjg2Fd4U9nKwweqm6v5wnYYFVb+Ssswz+0qtOtn05f KnDj33rZJTDpFVoeBgMT107r/lUXslClbPyquVBZQHcBAcYnufvPTmvpamyA8R5UB8aN j1NZ0o/mBpCB4jR0Q+cMFiZ0mTCOb8YxMP/hyjqqEFmEzUnVzNf07g+hf+uBOKRZIRL4 M2Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G464ZV8e; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k7-v6si595255qke.215.2018.09.26.11.38.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:38:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=G464ZV8e; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EhG-0001tt-TU for patch@linaro.org; Wed, 26 Sep 2018 14:38:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Ego-0001ip-4e for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egm-0007R3-LO for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:34 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:46617) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egm-0007QT-Az for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: by mail-pf1-x431.google.com with SMTP id d8-v6so6931572pfo.13 for ; Wed, 26 Sep 2018 11:37:32 -0700 (PDT) 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; bh=gUr4Rg30kEa57DsN+a3e5NMAEgxvwTzfEYRCfyICEQw=; b=G464ZV8e20L2YVHWR7RatP/R8NfmkPYLSHM+PbuHSVbqb6OUVWqx2QZIDWjonPxaeF ztNhvEwJEexjIwGvtDdgvCxOdWmXMbIoaURgLhMUBev6EFo2zG9P/PHd3V3SS2xZU13x ZUsxoaELB86KaIQtezhKMJXtAMlSLXujPBkto= 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; bh=gUr4Rg30kEa57DsN+a3e5NMAEgxvwTzfEYRCfyICEQw=; b=lYmjQKY+zDdrcnfNNCzQWJshkAPFM3gFYQ1IDqAWzj1/3mBRPuR+Kzym4KwiWWTwDM DxeSy7BvaBz/aA6QKakilwB16fGDZLYhAygjPrNgEMilS00HVwtGvVAK2QpaBinz71EM PA0ufDrp2YB043qGaHmp5rSZOXUlv7hGvC0KEVckAoPrE37+ED/WUUctY+LBfPiFATKJ 6qCfB3d8y3ZSwvUxRYWjeElvS7qShqJM8YNNSUkgiexI4aGMKL7bRlcRp6MYNEIWRmVo JuNOUnujK4N0FvLBfVftnUX+OKY4j+KmQr4jmKrt0a0PwbN6sSHmHoc3ktHf28JK310p ZdDw== X-Gm-Message-State: ABuFfogwUsYx9dLmVgEFJ9kmMp0mDHDQlLgd2NRXWrj4+Cd6OHskNtZL hwqU+VKH1KS++60u0jNHNtMLl4O2cEQ= X-Received: by 2002:a17:902:40d:: with SMTP id 13-v6mr7288339ple.257.1537987050911; Wed, 26 Sep 2018 11:37:30 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:08 -0700 Message-Id: <20180926183709.21293-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::431 Subject: [Qemu-devel] [PULL 12/13] qht-bench: add -p flag to precompute hash values 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Precomputing the hash values allows us to perform more frequent accesses to the hash table, thereby reaching higher throughputs. We keep the old behaviour by default, since (1) we might confuse users if they measured a speedup without changing anything in the QHT implementation, and (2) benchmarking the hash function "on line" is also valuable. Before: $ taskset -c 0 tests/qht-bench -n 1 Throughput: 38.18 MT/s After: $ taskset -c 0 tests/qht-bench -n 1 Throughput: 38.16 MT/s After (with precomputing): $ taskset -c 0 tests/qht-bench -n 1 -p Throughput: 50.87 MT/s Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/qht-bench.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/tests/qht-bench.c b/tests/qht-bench.c index f492b3a20a..2089e2bed1 100644 --- a/tests/qht-bench.c +++ b/tests/qht-bench.c @@ -53,6 +53,7 @@ static unsigned long resize_delay = 1000; static double resize_rate; /* 0.0 to 1.0 */ static unsigned int n_rz_threads = 1; static QemuThread *rz_threads; +static bool precompute_hash; static double update_rate; /* 0.0 to 1.0 */ static uint64_t update_threshold; @@ -101,11 +102,18 @@ static bool is_equal(const void *ap, const void *bp) return *a == *b; } -static inline uint32_t h(unsigned long v) +static uint32_t h(unsigned long v) { return tb_hash_func7(v, 0, 0, 0, 0); } +static uint32_t hval(unsigned long v) +{ + return v; +} + +static uint32_t (*hfunc)(unsigned long v) = h; + /* * From: https://en.wikipedia.org/wiki/Xorshift * This is faster than rand_r(), and gives us a wider range (RAND_MAX is only @@ -149,7 +157,7 @@ static void do_rw(struct thread_info *info) bool read; p = &keys[info->r & (lookup_range - 1)]; - hash = h(*p); + hash = hfunc(*p); read = qht_lookup(&ht, p, hash); if (read) { stats->rd++; @@ -158,7 +166,7 @@ static void do_rw(struct thread_info *info) } } else { p = &keys[info->r & (update_range - 1)]; - hash = h(*p); + hash = hfunc(*p); if (info->write_op) { bool written = false; @@ -289,7 +297,9 @@ static void htable_init(void) /* avoid allocating memory later by allocating all the keys now */ keys = g_malloc(sizeof(*keys) * n); for (i = 0; i < n; i++) { - keys[i] = populate_offset + i; + long val = populate_offset + i; + + keys[i] = precompute_hash ? h(val) : hval(val); } /* some sanity checks */ @@ -321,7 +331,7 @@ static void htable_init(void) r = xorshift64star(r); p = &keys[r & (init_range - 1)]; - hash = h(*p); + hash = hfunc(*p); if (qht_insert(&ht, p, hash, NULL)) { break; } @@ -412,7 +422,7 @@ static void parse_args(int argc, char *argv[]) int c; for (;;) { - c = getopt(argc, argv, "d:D:g:k:K:l:hn:N:o:r:Rs:S:u:"); + c = getopt(argc, argv, "d:D:g:k:K:l:hn:N:o:pr:Rs:S:u:"); if (c < 0) { break; } @@ -451,6 +461,10 @@ static void parse_args(int argc, char *argv[]) case 'o': populate_offset = atol(optarg); break; + case 'p': + precompute_hash = true; + hfunc = hval; + break; case 'r': update_range = pow2ceil(atol(optarg)); break; From patchwork Wed Sep 26 18:37:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147641 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1073758lji; Wed, 26 Sep 2018 11:45:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV63nvyJFz5g9pNKYVN33wwmaxSA8yr6cntxJi9caZik+raFqmdJnM7b9ruFOvt70CVRBeugp X-Received: by 2002:a0c:bfbc:: with SMTP id s57-v6mr5355364qvj.44.1537987544660; Wed, 26 Sep 2018 11:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987544; cv=none; d=google.com; s=arc-20160816; b=cNEErIUTz8pCwIbukuqhkLil4QSSNTSbrVn6OpWFs16YBn4VaggsYtfXuDjGEhYMvh 1w7w4rzcJlTGFaqCdQUld3HDDeQ5E8QeZ/45zAd/Y97yqZRAY1g4VAtoEKUITOeIpxfp avafe59r+GAy2BmoLWYRNNoenwRj8RAQ0IjhdM8MQDVlD2wqOcNHcB9cVFcFDg+BUvuw fA+c/WfrE6tW/+80wzrMm/VRZaCh1ZienMkZ/6SYk7nAzU1ZVTwXWVFbd+FW5Q40sG/L XZWC17xHnyc57C3/W8W+ZiFvrInLHyO5BWA6LBx8VM5+mgA3KQB2IsqV6LSkCYRUtkfU DjMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=YZC9mv0HnfVgp/zXAld8xc3LjAS9qjJ1UQMlv8Ifo0c=; b=n23fjeJHDYvc2JMRiMwI5hWZlJFqW9IZjBnlYfAqaSPAKlL68eK2aBVwJad8EdmCpF JrBUslLQ3ph0JgXaOJBv17xNkWn8ZZwX58bAzhh8OZCUuwt7pzWsVIg7C7tfAGsm0YSZ vDiOmGDetU+BHrPeCDeebVksD6D2xYRLJ9WNQdXmA210EtQgz6B1QRMKkI/xM866satt I4zxJLMAGr6q0k0jCTT2josXHlFl0udU2sLP8bHQxCci3sVueJV1QZPzUUW747Uu1cND kPMJWHbhZAMTGRllVqvMrPVFApRdQ3KywjxmAjnUHBfv511Res8IC3VC6yxkLeKyzMlS EQnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KDH+uIN9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x7-v6si2603797qtr.195.2018.09.26.11.45.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:45:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=KDH+uIN9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eoh-00022i-1r for patch@linaro.org; Wed, 26 Sep 2018 14:45:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egp-0001la-7x for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Ego-0007S8-4d for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:35 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egn-0007RY-T6 for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:34 -0400 Received: by mail-pg1-x544.google.com with SMTP id d1-v6so14410261pgo.3 for ; Wed, 26 Sep 2018 11:37:33 -0700 (PDT) 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; bh=YZC9mv0HnfVgp/zXAld8xc3LjAS9qjJ1UQMlv8Ifo0c=; b=KDH+uIN9FChrbei8qidGivlzLqR3i2YcI8qFX3b+B6OsR5K535XGDfrWTnQ1cj3kQz vnTyz9/qiVK2XTgWm8Plv3nhP2ocay6z76NhFDxbZG9i2KXyKRDwHiJVQJ9c1/OIP+TX MA0VXqF7xp4CF14Wx6oB6MVq44zGkj1R+Nxsw= 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; bh=YZC9mv0HnfVgp/zXAld8xc3LjAS9qjJ1UQMlv8Ifo0c=; b=gKgB7LllGrxLPixaj/ip2LJeAY7jBJtjJVIEX56LKBiVv5z/pMLPN3SGbCv1oDn+Ju MjS7PutvFUMCACasMM4D2ho0HUZed0cOcSYyW8LdwXv9W6CQb/s6WYWqKAYLAW/7DQi1 RMkVzApmiJJfckKfYEtOL6oEHdS5VReXRZjSMPbATvuZRoaefrYrnrqWvMkzsNT/F5YW 79gUHGgy6tJztYxJf3RTLLH2VKrDs07Je3K0IOqRP4AUT7N0zPYfzIKjQZkdQ7mlK18f D0alXhOQ5gImvFUWmRGa685OImnMCjvqGxEzo/ib1WXgAA6ffhuZRSkAXsecPAiteQUU pYLQ== X-Gm-Message-State: ABuFfohWEZKFepqrk0boHxXUG2lXb77Jj63bp2ynJN4DA6D4woHlmp/j gQZhfwEU56pktVZHjq++yKwe//INgTk= X-Received: by 2002:a17:902:b40c:: with SMTP id x12-v6mr7230730plr.163.1537987052552; Wed, 26 Sep 2018 11:37:32 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:09 -0700 Message-Id: <20180926183709.21293-14-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PULL 13/13] tcg/i386: fix vector operations on 32-bit hosts 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, Roman Kapl Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Roman Kapl The TCG backend uses LOWREGMASK to get the low 3 bits of register numbers. This was defined as no-op for 32-bit x86, with the assumption that we have eight registers anyway. This assumption is not true once we have xmm regs. Since LOWREGMASK was a no-op, xmm register indidices were wrong in opcodes and have overflown into other opcode fields, wreaking havoc. To trigger these problems, you can try running the "movi d8, #0x0" AArch64 instruction on 32-bit x86. "vpxor %xmm0, %xmm0, %xmm0" should be generated, but instead TCG generated "vpxor %xmm0, %xmm0, %xmm2". Fixes: 770c2fc7bb ("Add vector operations") Signed-off-by: Roman Kapl Message-Id: <20180824131734.18557-1-rka@sysgo.com> Signed-off-by: Richard Henderson --- tcg/i386/tcg-target.inc.c | 4 ---- 1 file changed, 4 deletions(-) -- 2.17.1 diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c index a91e4f1313..436195894b 100644 --- a/tcg/i386/tcg-target.inc.c +++ b/tcg/i386/tcg-target.inc.c @@ -302,11 +302,7 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, return 0; } -#if TCG_TARGET_REG_BITS == 64 # define LOWREGMASK(x) ((x) & 7) -#else -# define LOWREGMASK(x) (x) -#endif #define P_EXT 0x100 /* 0x0f opcode prefix */ #define P_EXT38 0x200 /* 0x0f 0x38 opcode prefix */