From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987160795297.1241182329094; Wed, 26 Sep 2018 11:39:20 -0700 (PDT) Received: from localhost ([::1]:60166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EiV-0003NR-LO for importer@patchew.org; Wed, 26 Sep 2018 14:39:19 -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) 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) 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-Google-Smtp-Source: ACcGV60HCQpa/eHZOAvHoDrLEn4RLQELO92JgiHPta/JCyDhJIr6c2Q4MPdodgHl1OZwZGLDxbOOqQ== X-Received: by 2002:a17:902:44:: with SMTP id 62-v6mr7370351pla.181.1537987033749; Wed, 26 Sep 2018 11:37:13 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 From: "Emilio G. Cota" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- util/qht.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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_b= ucket *orig, int pos) =20 /* 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 h= ash) { struct qht_bucket *b =3D head; int i; @@ -728,7 +727,7 @@ bool qht_remove(struct qht *ht, const void *p, uint32_t= hash) qht_debug_assert(p); =20 b =3D qht_bucket_lock__no_stale(ht, hash, &map); - ret =3D qht_remove__locked(map, b, p, hash); + ret =3D qht_remove__locked(b, p, hash); qht_bucket_debug__locked(b); qemu_spin_unlock(&b->lock); return ret; --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153798717249821.33360023677642; Wed, 26 Sep 2018 11:39:32 -0700 (PDT) Received: from localhost ([::1]:60167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eih-0003W6-1R for importer@patchew.org; Wed, 26 Sep 2018 14:39:31 -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) 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) 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-Google-Smtp-Source: ACcGV63nhRbN+jaQMdgSMGtk4QWLTCOUjng1P3VsLtvvYpKJvI2xBM0aVXr+jbRRULngBeNeRuxyfQ== X-Received: by 2002:a63:c046:: with SMTP id z6-v6mr6849275pgi.114.1537987035271; Wed, 26 Sep 2018 11:37:15 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e 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(-) 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 { =20 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); =20 #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 pa= ir, * 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); =20 +/** + * 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 pa= ir, + * 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 *user= p); + /** * 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 =20 +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; } =20 -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 *user= p) { + struct qht_bucket *b =3D head; int i; =20 do { @@ -743,7 +757,25 @@ static inline void qht_bucket_iter(struct qht *ht, str= uct qht_bucket *b, if (b->pointers[i] =3D=3D 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], user= p)) { + /* 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 =3D b->next; } while (b); @@ -751,26 +783,48 @@ static inline void qht_bucket_iter(struct qht *ht, st= ruct qht_bucket *b, =20 /* 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 *us= erp) + const struct qht_iter *iter, + void *userp) { size_t i; =20 for (i =3D 0; i < map->n_buckets; i++) { - qht_bucket_iter(ht, &map->buckets[i], func, userp); + qht_bucket_iter(ht, &map->buckets[i], iter, userp); } } =20 -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; =20 map =3D atomic_rcu_read(&ht->map); qht_map_lock_buckets(map); /* Note: ht here is merely for carrying ht->mode; ht->map won't be rea= d */ - qht_map_iter__all_locked(ht, map, func, userp); + qht_map_iter__all_locked(ht, map, iter, userp); qht_map_unlock_buckets(map); } =20 +void qht_iter(struct qht *ht, qht_iter_func_t func, void *userp) +{ + const struct qht_iter iter =3D { + .f.retvoid =3D func, + .type =3D QHT_ITER_VOID, + }; + + do_qht_iter(ht, &iter, userp); +} + +void qht_iter_remove(struct qht *ht, qht_iter_bool_func_t func, void *user= p) +{ + const struct qht_iter iter =3D { + .f.retbool =3D func, + .type =3D QHT_ITER_RM, + }; + + do_qht_iter(ht, &iter, userp); +} + static void qht_map_copy(struct qht *ht, void *p, uint32_t hash, void *use= rp) { struct qht_map *new =3D userp; @@ -787,6 +841,10 @@ static void qht_map_copy(struct qht *ht, void *p, uint= 32_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 =3D { + .f.retvoid =3D qht_map_copy, + .type =3D QHT_ITER_VOID, + }; =20 old =3D 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) } =20 g_assert(new->n_buckets !=3D 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); =20 atomic_rcu_set(&ht->map, new); --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987330119139.551286637442; Wed, 26 Sep 2018 11:42:10 -0700 (PDT) Received: from localhost ([::1]:60184 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ElB-0005kZ-Fa for importer@patchew.org; Wed, 26 Sep 2018 14:42:05 -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) 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) 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-Google-Smtp-Source: ACcGV63CIE10okfSijUFm3xQkXyv14HWQvNZ7CAVjvHpH3bpLQ40r7BpThPBYwdGoCdpLJUDCIzXAA== X-Received: by 2002:a62:aa17:: with SMTP id e23-v6mr7481020pff.211.1537987036881; Wed, 26 Sep 2018 11:37:16 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 From: "Emilio G. Cota" Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) 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, =3D=3D, count); } =20 +static void sum_func(struct qht *ht, void *p, uint32_t hash, void *userp) +{ + uint32_t *sum =3D userp; + uint32_t a =3D *(uint32_t *)p; + + *sum +=3D a; +} + +static void iter_sum_check(unsigned int expected) +{ + unsigned int sum =3D 0; + + qht_iter(&ht, sum_func, &sum); + g_assert_cmpuint(sum, =3D=3D, expected); +} + +static bool rm_mod_func(struct qht *ht, void *p, uint32_t hash, void *user= p) +{ + uint32_t a =3D *(uint32_t *)p; + unsigned int mod =3D *(unsigned int *)userp; + + return a % mod =3D=3D 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 =3D 0; + unsigned int i; + + for (i =3D 0; i < N; i++) { + if (i % mod =3D=3D 0) { + continue; + } + expected +=3D 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); =20 - 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); --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987340328273.3428291621143; Wed, 26 Sep 2018 11:42:20 -0700 (PDT) Received: from localhost ([::1]:60185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ElP-0005wh-7k for importer@patchew.org; Wed, 26 Sep 2018 14:42:19 -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) 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) 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-Google-Smtp-Source: ACcGV62Eky1HoYNk5To3A7C+WqVirHNtbA0zpX65+URzME57K188Qzimko47LbVUHI6s+l1efZgFYA== X-Received: by 2002:a62:9042:: with SMTP id a63-v6mr7579903pfe.52.1537987038339; Wed, 26 Sep 2018 11:37:18 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 From: "Emilio G. Cota" This improves qht.c code coverage from 89.44% to 90.00%. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) 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) } } =20 -static void rm(int init, int end) +static void do_rm(int init, int end, bool exist) { int i; =20 @@ -49,10 +49,24 @@ static void rm(int init, int end) uint32_t hash; =20 hash =3D 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)); + } } } =20 +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); =20 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); =20 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) =20 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); --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987488797976.6560614342469; Wed, 26 Sep 2018 11:44:48 -0700 (PDT) Received: from localhost ([::1]:60196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Enn-0000fT-IK for importer@patchew.org; Wed, 26 Sep 2018 14:44:47 -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) 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) 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-Google-Smtp-Source: ACcGV63iepN9AJrtaBGK/jjhLVK4zdxm/bYWTUSwiRViMSxOvS5KiguYhvIxLBRXDalLNQKSi1di+A== X-Received: by 2002:a17:902:4324:: with SMTP id i33-v6mr7154155pld.43.1537987039876; Wed, 26 Sep 2018 11:37:19 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) =20 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 <=3D 1. + * Given that the number of elements per bucket can be 4 or 6 dependin= g on + * the host's pointer size, test the removal of the 4th and 6th elemen= ts. + */ 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); =20 --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987340005724.488906931437; Wed, 26 Sep 2018 11:42:20 -0700 (PDT) Received: from localhost ([::1]:60186 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ElO-0005y8-UG for importer@patchew.org; Wed, 26 Sep 2018 14:42:19 -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) 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) 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-Google-Smtp-Source: ACcGV62LPkeYYa2ItGpLXEnc8y3AJfrvms1TtGJ3r8STr5SSWAwjLMYxyvqLqzJ0F4l9APBBdQu0JQ== X-Received: by 2002:a63:5558:: with SMTP id f24-v6mr6883346pgm.37.1537987041284; Wed, 26 Sep 2018 11:37:21 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 4 ++++ 1 file changed, 4 insertions(+) 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); =20 + if (!(mode & QHT_MODE_AUTO_RESIZE)) { + qht_resize(&ht, init_entries * 4 + 4); + } + check_n(0); rm_nonexist(0, 10); insert(0, N); --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987491481536.9615699721525; Wed, 26 Sep 2018 11:44:51 -0700 (PDT) Received: from localhost ([::1]:60195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Enm-0000fF-6a for importer@patchew.org; Wed, 26 Sep 2018 14:44:46 -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) 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) 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-Google-Smtp-Source: ACcGV619G9EE5eAP0MCUOmuhtIG2G7YI8qqxptfvI7HBB6/sZDWcgIFmgOZjrbSVrU7Yfs8myDpCHA== X-Received: by 2002:a17:902:4e:: with SMTP id 72-v6mr7275285pla.318.1537987042845; Wed, 26 Sep 2018 11:37:22 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 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=C3=A9e 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(-) 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 { }; =20 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); =20 #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 =20 -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 =3D p; target_ulong addr =3D *(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); } =20 -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 =3D 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); } =20 -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 =3D userp; =20 @@ -122,7 +122,7 @@ static void iter_check(unsigned int count) g_assert_cmpuint(curr, =3D=3D, count); } =20 -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 =3D userp; uint32_t a =3D *(uint32_t *)p; @@ -138,7 +138,7 @@ static void iter_sum_check(unsigned int expected) g_assert_cmpuint(sum, =3D=3D, expected); } =20 -static bool rm_mod_func(struct qht *ht, void *p, uint32_t hash, void *user= p) +static bool rm_mod_func(void *p, uint32_t hash, void *userp) { uint32_t a =3D *(uint32_t *)p; unsigned int mod =3D *(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; } =20 -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 *user= p) { struct qht_bucket *b =3D head; @@ -759,10 +759,10 @@ static inline void qht_bucket_iter(struct qht *ht, st= ruct 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], user= p)) { + 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, st= ruct qht_bucket *head, } =20 /* 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; =20 for (i =3D 0; i < map->n_buckets; i++) { - qht_bucket_iter(ht, &map->buckets[i], iter, userp); + qht_bucket_iter(&map->buckets[i], iter, userp); } } =20 @@ -800,8 +800,7 @@ do_qht_iter(struct qht *ht, const struct qht_iter *iter= , void *userp) =20 map =3D atomic_rcu_read(&ht->map); qht_map_lock_buckets(map); - /* Note: ht here is merely for carrying ht->mode; ht->map won't be rea= d */ - qht_map_iter__all_locked(ht, map, iter, userp); + qht_map_iter__all_locked(map, iter, userp); qht_map_unlock_buckets(map); } =20 @@ -825,9 +824,16 @@ void qht_iter_remove(struct qht *ht, qht_iter_bool_fun= c_t func, void *userp) do_qht_iter(ht, &iter, userp); } =20 -static void qht_map_copy(struct qht *ht, void *p, uint32_t hash, void *use= rp) +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 =3D userp; + struct qht_map_copy_data *data =3D userp; + struct qht *ht =3D data->ht; + struct qht_map *new =3D data->new; struct qht_bucket *b =3D qht_map_to_bucket(new, hash); =20 /* 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 =3D qht_map_copy, .type =3D QHT_ITER_VOID, }; + struct qht_map_copy_data data; =20 old =3D 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) } =20 g_assert(new->n_buckets !=3D old->n_buckets); - qht_map_iter__all_locked(ht, old, &iter, new); + data.ht =3D ht; + data.new =3D new; + qht_map_iter__all_locked(old, &iter, &data); qht_map_debug__all_locked(new); =20 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, gconstpointe= r bp, gpointer up) } } =20 -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 =3D p; GTree *tree =3D 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); } =20 -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 =3D up; const QSPEntry *e =3D 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); } =20 -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 =3D htp; QSPEntry *old =3D p; @@ -583,8 +583,7 @@ static void qsp_diff(struct qht *orig, struct qht *new) qht_iter(orig, qsp_iter_diff, new); } =20 -static void -qsp_iter_callsite_coalesce(struct qht *orig, void *p, uint32_t h, void *ht= p) +static void qsp_iter_callsite_coalesce(void *p, uint32_t h, void *htp) { struct qht *ht =3D htp; QSPEntry *old =3D p; @@ -603,7 +602,7 @@ qsp_iter_callsite_coalesce(struct qht *orig, void *p, u= int32_t h, void *htp) e->n_acqs +=3D old->n_acqs; } =20 -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); } --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987332519661.560013151092; Wed, 26 Sep 2018 11:42:12 -0700 (PDT) Received: from localhost ([::1]:60183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ElA-0005ik-9k for importer@patchew.org; Wed, 26 Sep 2018 14:42:04 -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) 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) 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-Google-Smtp-Source: ACcGV61rBm8DpZFnIkoKjG+mAHyTQzDo/vtQnlkXqSI5FFNMqgvl+hbrALQ6CE3NB+6rD9T8Bpd0ZQ== X-Received: by 2002:a17:902:b90b:: with SMTP id bf11-v6mr7414692plb.52.1537987044350; Wed, 26 Sep 2018 11:37:24 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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) } =20 /* - * 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 po= s) --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987645949113.42130754871198; Wed, 26 Sep 2018 11:47:25 -0700 (PDT) Received: from localhost ([::1]:60214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EqK-0002pn-PS for importer@patchew.org; Wed, 26 Sep 2018 14:47:24 -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) 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) 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-Google-Smtp-Source: ACcGV608v98HT/4jzk4F24kP4cJt2yQ7bD/z4JfF6vjBmE4xSo9m2EVtZULCFLYikxZ09rpeF41BNw== X-Received: by 2002:a62:20d8:: with SMTP id m85-v6mr7573490pfj.74.1537987046016; Wed, 26 Sep 2018 11:37:26 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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); =20 /** @@ -115,7 +115,7 @@ void *qht_lookup_custom(struct qht *ht, const void *use= rp, 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); =20 /** * 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) } =20 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 h= ash) { return &map->buckets[hash & (map->n_buckets - 1)]; } @@ -482,10 +482,10 @@ bool qht_reset_size(struct qht *ht, size_t n_elems) } =20 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 =3D head; + const struct qht_bucket *b =3D head; int i; =20 do { @@ -509,7 +509,7 @@ void *qht_do_lookup(struct qht_bucket *head, qht_lookup= _func_t func, } =20 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 f= unc, 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; } =20 -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; =20 @@ -545,7 +545,7 @@ void *qht_lookup_custom(struct qht *ht, const void *use= rp, uint32_t hash, return qht_lookup__slowpath(b, func, userp, hash); } =20 -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); } --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987498717623.7651735136702; Wed, 26 Sep 2018 11:44:58 -0700 (PDT) Received: from localhost ([::1]:60199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Enx-0000qD-Fx for importer@patchew.org; Wed, 26 Sep 2018 14:44:57 -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) 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) 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-Google-Smtp-Source: ACcGV61NQt/N7fuMT7W/GahQ+foBYcRVr+gnXrg13H6w1ml/jMkNl/dXOELGkfUt0/Si9Fmkt/r0SA== X-Received: by 2002:a63:7b09:: with SMTP id w9-v6mr6926880pgc.385.1537987047747; Wed, 26 Sep 2018 11:37:27 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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); =20 /** * 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) } =20 /* 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; =20 map =3D atomic_rcu_read(&ht->map); @@ -914,8 +914,8 @@ void qht_statistics_init(struct qht *ht, struct qht_sta= ts *stats) stats->head_buckets =3D map->n_buckets; =20 for (i =3D 0; i < map->n_buckets; i++) { - struct qht_bucket *head =3D &map->buckets[i]; - struct qht_bucket *b; + const struct qht_bucket *head =3D &map->buckets[i]; + const struct qht_bucket *b; unsigned int version; size_t buckets; size_t entries; --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987645973272.69151330792965; Wed, 26 Sep 2018 11:47:25 -0700 (PDT) Received: from localhost ([::1]:60215 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5EqK-0002pr-Qo for importer@patchew.org; Wed, 26 Sep 2018 14:47:24 -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) 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) 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-Google-Smtp-Source: ACcGV635HkWmTK8LDCblEVM4nZzM3+bvfN/myAdg2tygiEImVDFrfMaf9L/hQUOj5UP0h2jOXAdR+A== X-Received: by 2002:a62:ac15:: with SMTP id v21-v6mr7641529pfe.126.1537987049339; Wed, 26 Sep 2018 11:37:29 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 !=3D ht->map; } @@ -337,12 +338,12 @@ struct qht_bucket *qht_bucket_lock__no_stale(struct q= ht *ht, uint32_t hash, return b; } =20 -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_thres= hold; } =20 -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 =3D head->next; struct qht_bucket *prev; @@ -550,8 +551,11 @@ void *qht_lookup(const struct qht *ht, const void *use= rp, uint32_t hash) return qht_lookup_custom(ht, userp, hash, ht->cmp); } =20 -/* 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; } =20 -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 =3D=3D QHT_BUCKET_ENTRIES - 1) { if (b->next =3D=3D NULL) { --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987175003992.5389243430274; Wed, 26 Sep 2018 11:39:35 -0700 (PDT) Received: from localhost ([::1]:60168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eij-0003YC-Ji for importer@patchew.org; Wed, 26 Sep 2018 14:39:33 -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) 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) 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-Google-Smtp-Source: ACcGV61Ykt6EFgcPeEpT5CSgVtppZBcmiAMRGTNQSJKxyexu9TjS1ktMLsbSCuwaWU7l/y5r0I5SdA== X-Received: by 2002:a17:902:40d:: with SMTP id 13-v6mr7288339ple.257.1537987050911; Wed, 26 Sep 2018 11:37:30 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D 1000; static double resize_rate; /* 0.0 to 1.0 */ static unsigned int n_rz_threads =3D 1; static QemuThread *rz_threads; +static bool precompute_hash; =20 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 =3D=3D *b; } =20 -static inline uint32_t h(unsigned long v) +static uint32_t h(unsigned long v) { return tb_hash_func7(v, 0, 0, 0, 0); } =20 +static uint32_t hval(unsigned long v) +{ + return v; +} + +static uint32_t (*hfunc)(unsigned long v) =3D h; + /* * From: https://en.wikipedia.org/wiki/Xorshift * This is faster than rand_r(), and gives us a wider range (RAND_MAX is o= nly @@ -149,7 +157,7 @@ static void do_rw(struct thread_info *info) bool read; =20 p =3D &keys[info->r & (lookup_range - 1)]; - hash =3D h(*p); + hash =3D hfunc(*p); read =3D qht_lookup(&ht, p, hash); if (read) { stats->rd++; @@ -158,7 +166,7 @@ static void do_rw(struct thread_info *info) } } else { p =3D &keys[info->r & (update_range - 1)]; - hash =3D h(*p); + hash =3D hfunc(*p); if (info->write_op) { bool written =3D false; =20 @@ -289,7 +297,9 @@ static void htable_init(void) /* avoid allocating memory later by allocating all the keys now */ keys =3D g_malloc(sizeof(*keys) * n); for (i =3D 0; i < n; i++) { - keys[i] =3D populate_offset + i; + long val =3D populate_offset + i; + + keys[i] =3D precompute_hash ? h(val) : hval(val); } =20 /* some sanity checks */ @@ -321,7 +331,7 @@ static void htable_init(void) =20 r =3D xorshift64star(r); p =3D &keys[r & (init_range - 1)]; - hash =3D h(*p); + hash =3D hfunc(*p); if (qht_insert(&ht, p, hash, NULL)) { break; } @@ -412,7 +422,7 @@ static void parse_args(int argc, char *argv[]) int c; =20 for (;;) { - c =3D getopt(argc, argv, "d:D:g:k:K:l:hn:N:o:r:Rs:S:u:"); + c =3D 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 =3D atol(optarg); break; + case 'p': + precompute_hash =3D true; + hfunc =3D hval; + break; case 'r': update_range =3D pow2ceil(atol(optarg)); break; --=20 2.17.1 From nobody Tue May 7 10:46:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987499276357.21798979746563; Wed, 26 Sep 2018 11:44:59 -0700 (PDT) Received: from localhost ([::1]:60198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Eny-0000pn-2u for importer@patchew.org; Wed, 26 Sep 2018 14:44:58 -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) 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) 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-Google-Smtp-Source: ACcGV632e9C3QLg4Yc8RvOjvXrP8+Ei/Zj++h/KLiPqsewsVC2rg5aMVKLaORchXW+9yc0Q9eyt72w== X-Received: by 2002:a17:902:b40c:: with SMTP id x12-v6mr7230730plr.163.1537987052552; Wed, 26 Sep 2018 11:37:32 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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_lo= ng val, TCGType type, return 0; } =20 -#if TCG_TARGET_REG_BITS =3D=3D 64 # define LOWREGMASK(x) ((x) & 7) -#else -# define LOWREGMASK(x) (x) -#endif =20 #define P_EXT 0x100 /* 0x0f opcode prefix */ #define P_EXT38 0x200 /* 0x0f 0x38 opcode prefix */ --=20 2.17.1