From nobody Tue Feb 10 02:49:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1680166262; cv=none; d=zohomail.com; s=zohoarc; b=gh9AGrBjMJiEmrXEzXWIkaGKmlny2DpD5iRy4OP2e07qldxf3SgQWKjFuII/bj6kdKXboh9iw71K+w6KPfLoST7kQjyr0WvByPERRGBw9RoGXBcRmnnZrfDXjqIYZn0GLRGuVZrKeB/IT5yGRhqG65bN2/dbeagX/O+5KSbuKHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1680166262; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yNDHqsZeJimLNlZjd9q+WaVtry8TrNvKJye99WJK+MI=; b=al15RI9JVoqDVatNBdB4uq157SYnq+aBqCRrFMUDg+xxRdo4+Ie/R2Tfsc++ndHe6TiGjGq6lvITS5pY6+BVuw9liMtRo4hwD84+5TLOmXrzD+xkM4W2qtJaKhwndoWWP5bHt7QU6wfzS1fY2W+mX+LNZZA6mLmYi4qTA7BCw4Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1680166262514801.8629972541321; Thu, 30 Mar 2023 01:51:02 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.516501.800713 (Exim 4.92) (envelope-from ) id 1phnzO-0006Q3-9G; Thu, 30 Mar 2023 08:50:34 +0000 Received: by outflank-mailman (output) from mailman id 516501.800713; Thu, 30 Mar 2023 08:50:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phnzO-0006Pt-5H; Thu, 30 Mar 2023 08:50:34 +0000 Received: by outflank-mailman (input) for mailman id 516501; Thu, 30 Mar 2023 08:50:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1phnzM-0005Qp-VM for xen-devel@lists.xenproject.org; Thu, 30 Mar 2023 08:50:33 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2001:67c:2178:6::1c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ed27b3ea-ced7-11ed-b464-930f4c7d94ae; Thu, 30 Mar 2023 10:50:31 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E984321B0D; Thu, 30 Mar 2023 08:50:30 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id B0A51138FF; Thu, 30 Mar 2023 08:50:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mcjKKVZNJWQTIwAAMHmgww (envelope-from ); Thu, 30 Mar 2023 08:50:30 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ed27b3ea-ced7-11ed-b464-930f4c7d94ae DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1680166230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yNDHqsZeJimLNlZjd9q+WaVtry8TrNvKJye99WJK+MI=; b=C1P36EdJ4nEFayaBwK+INqIbDnPYvVnIZdKRLJa/Xau0oQlOgrlxHSlNF70o4X8xOxMTop 6d2mE3Sy6PhCQAjxJds3y/H2e46l+9EoDshJndWSS3nh6twomzv7KsNQoY41bpRCwkyGO4 vLofgXJltNLvWUHy6jPVhdKS5CIwM7Q= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD Subject: [PATCH v2 03/13] tools/xenstore: modify interface of create_hashtable() Date: Thu, 30 Mar 2023 10:50:01 +0200 Message-Id: <20230330085011.9170-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230330085011.9170-1-jgross@suse.com> References: <20230330085011.9170-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1680166263653100001 Content-Type: text/plain; charset="utf-8" The minsize parameter of create_hashtable() doesn't have any real use case for Xenstore, so drop it. For better talloc_report_full() diagnostic output add a name parameter to create_hashtable(). Signed-off-by: Juergen Gross --- tools/xenstore/hashtable.c | 20 ++++++-------------- tools/xenstore/hashtable.h | 4 ++-- tools/xenstore/xenstored_core.c | 2 +- tools/xenstore/xenstored_domain.c | 4 ++-- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/tools/xenstore/hashtable.c b/tools/xenstore/hashtable.c index c1b11743bb..ab1e687d0b 100644 --- a/tools/xenstore/hashtable.c +++ b/tools/xenstore/hashtable.c @@ -55,36 +55,28 @@ static unsigned int loadlimit(unsigned int pindex) return ((uint64_t)primes[pindex] * MAX_LOAD_PERCENT) / 100; } =20 -struct hashtable *create_hashtable(const void *ctx, unsigned int minsize, +struct hashtable *create_hashtable(const void *ctx, const char *name, unsigned int (*hashf) (const void *), int (*eqf) (const void *, const void *), unsigned int flags) { struct hashtable *h; - unsigned int pindex, size =3D primes[0]; - - /* Check requested hashtable isn't too large */ - if (minsize > (1u << 30)) return NULL; - - /* Enforce size as prime */ - for (pindex=3D0; pindex < PRIME_TABLE_LEN; pindex++) { - if (primes[pindex] > minsize) { size =3D primes[pindex]; break; } - } =20 h =3D talloc_zero(ctx, struct hashtable); if (NULL =3D=3D h) goto err0; - h->table =3D talloc_zero_array(h, struct entry *, size); + talloc_set_name_const(h, name); + h->table =3D talloc_zero_array(h, struct entry *, primes[0]); if (NULL =3D=3D h->table) goto err1; =20 - h->tablelength =3D size; + h->tablelength =3D primes[0]; h->flags =3D flags; - h->primeindex =3D pindex; + h->primeindex =3D 0; h->entrycount =3D 0; h->hashfn =3D hashf; h->eqfn =3D eqf; - h->loadlimit =3D loadlimit(pindex); + h->loadlimit =3D loadlimit(0); return h; =20 err1: diff --git a/tools/xenstore/hashtable.h b/tools/xenstore/hashtable.h index 04310783b6..0e1a6f61c2 100644 --- a/tools/xenstore/hashtable.h +++ b/tools/xenstore/hashtable.h @@ -10,7 +10,7 @@ struct hashtable; =20 * @name create_hashtable * @param ctx talloc context to use for allocations - * @param minsize minimum initial size of hashtable + * @param name talloc name of the hashtable * @param hashfunction function for hashing keys * @param key_eq_fn function for determining key equality * @param flags flags HASHTABLE_* @@ -23,7 +23,7 @@ struct hashtable; #define HASHTABLE_FREE_KEY (1U << 1) =20 struct hashtable * -create_hashtable(const void *ctx, unsigned int minsize, +create_hashtable(const void *ctx, const char *name, unsigned int (*hashfunction) (const void *), int (*key_eq_fn) (const void *, const void *), unsigned int flags diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index 7214b3df03..6ce7be3161 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -2511,7 +2511,7 @@ void check_store(void) struct check_store_data data; =20 /* Don't free values (they are all void *1) */ - data.reachable =3D create_hashtable(NULL, 16, hash_from_key_fn, + data.reachable =3D create_hashtable(NULL, "checkstore", hash_from_key_fn, keys_equal_fn, HASHTABLE_FREE_KEY); if (!data.reachable) { log("check_store: ENOMEM"); diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_d= omain.c index df64c87efc..6d40aefc63 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -1017,7 +1017,7 @@ void domain_init(int evtfd) int rc; =20 /* Start with a random rather low domain count for the hashtable. */ - domhash =3D create_hashtable(NULL, 8, domhash_fn, domeq_fn, 0); + domhash =3D create_hashtable(NULL, "domains", domhash_fn, domeq_fn, 0); if (!domhash) barf_perror("Failed to allocate domain hashtable"); =20 @@ -1804,7 +1804,7 @@ struct hashtable *domain_check_acc_init(void) { struct hashtable *domains; =20 - domains =3D create_hashtable(NULL, 8, domhash_fn, domeq_fn, + domains =3D create_hashtable(NULL, "domain_check", domhash_fn, domeq_fn, HASHTABLE_FREE_VALUE); if (!domains) return NULL; --=20 2.35.3