From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7BF7E43B3B; Fri, 16 Feb 2024 13:43:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60E60432C8; Fri, 16 Feb 2024 13:43:56 +0100 (CET) Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) by mails.dpdk.org (Postfix) with ESMTP id 3C39C43001 for ; Fri, 16 Feb 2024 13:43:55 +0100 (CET) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 9D3E711400BC; Fri, 16 Feb 2024 07:43:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 16 Feb 2024 07:43:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1708087434; x=1708173834; bh=ISZIY5Y853bVa3RVaSWsnQsv7IXUNfTDYYw50p5lbnY=; b= HyKQ0CDgeF2hfp/BgDRZBherzE+sWBsNYFEvUIAtjgLnvmbIoEELOSt/89auI6y2 A0r4zD/fW8uC0mqk0EWGUyCvuZbApNCgDDZdnFxyPhPAgXjpxTbv6pE0NsyYCwRd MbUq1vZMhSUnSdXMTG3iBfJEih6Vf3wPF++c/BUyBed0VQyFOYqDNWpyID3V/Rr8 QbuwU4DX4QTqfao20Y37h7looVm8jwtPTOVfK5GSBkcOjXZAq0f1tZ6dwjujc00O JI2TZ2fGfHNurMn5zxNYtbj8q7zkg9zBajSfrm67v3Srz/OPWIz20UcSDC440c+y 8psXelHFTU1nRDF1aOggkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1708087434; x= 1708173834; bh=ISZIY5Y853bVa3RVaSWsnQsv7IXUNfTDYYw50p5lbnY=; b=C kDmIwf4LlbTd2lO2KjChnE/Ov+sXTZzVznWzJIpRa6uPIFunK+bqXqsp2kFJUSih euZ5CtKqOITUVD1n0IrHE13ydBRdaPwb0YcOTmjkupCUWGoyOayePTwh3RoVF4po Cdb+cKa0x5otyiY73/Ydhukv8CQ7owt95bNR8blX+J/v0qM4zW5BvHQUzLX9G39G dyXkPMK62ZF1yS77pOC4nKg9TKlUglSItC4YDigh79P+SJvbidLLOsjoJF615Vh7 ZerwdkvySv9mumrGbcCaRKM4TfJp8CxcDfI2IkWpDEN7ftLvBEecjthUcIyzu5lb JHCp5VOBgQiIgsZ0Nem6g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvgdegfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkfgjfhgggfgtsehtqhertddttddunecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepfefhjeeluedvvedtuddtuedtvefhieejtefhffeujefhteduudev tdektdeikeffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 16 Feb 2024 07:43:53 -0500 (EST) From: Thomas Monjalon To: dev@dpdk.org Cc: Abdullah =?ISO-8859-1?Q?=D6mer_Yama=E7?= , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin , David Marchand , Abdullah =?ISO-8859-1?Q?=D6mer_Yama=E7?= Subject: Re: [PATCH v2] lib/hash: new feature adding existing key Date: Fri, 16 Feb 2024 13:43:52 +0100 Message-ID: <5156487.LM0AJKV5NW@thomas> In-Reply-To: <20231023082925.256141-1-aomeryamac@gmail.com> References: <20231023082925.256141-1-aomeryamac@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Any review please? If maintainers agree with the idea, we should announce the ABI change. 23/10/2023 10:29, Abdullah =D6mer Yama=E7: > From: Abdullah =D6mer Yama=E7 >=20 > In some use cases inserting data with the same key shouldn't be > overwritten. We use a new flag in this patch to disable overwriting > data for the same key. >=20 > Signed-off-by: Abdullah =D6mer Yama=E7 >=20 > --- > Cc: Yipeng Wang > Cc: Sameh Gobriel > Cc: Bruce Richardson > Cc: Vladimir Medvedkin > Cc: David Marchand > --- > lib/hash/rte_cuckoo_hash.c | 10 +++++++++- > lib/hash/rte_cuckoo_hash.h | 2 ++ > lib/hash/rte_hash.h | 4 ++++ > 3 files changed, 15 insertions(+), 1 deletion(-) >=20 > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c > index 19b23f2a97..fe8f21bee4 100644 > --- a/lib/hash/rte_cuckoo_hash.c > +++ b/lib/hash/rte_cuckoo_hash.c > @@ -32,7 +32,8 @@ > RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY | \ > RTE_HASH_EXTRA_FLAGS_EXT_TABLE | \ > RTE_HASH_EXTRA_FLAGS_NO_FREE_ON_DEL | \ > - RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF) > + RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF | \ > + RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY) > =20 > #define FOR_EACH_BUCKET(CURRENT_BKT, START_BUCKET) = \ > for (CURRENT_BKT =3D START_BUCKET; = \ > @@ -148,6 +149,7 @@ rte_hash_create(const struct rte_hash_parameters *par= ams) > unsigned int readwrite_concur_support =3D 0; > unsigned int writer_takes_lock =3D 0; > unsigned int no_free_on_del =3D 0; > + unsigned int no_update_data =3D 0; > uint32_t *ext_bkt_to_free =3D NULL; > uint32_t *tbl_chng_cnt =3D NULL; > struct lcore_cache *local_free_slots =3D NULL; > @@ -216,6 +218,9 @@ rte_hash_create(const struct rte_hash_parameters *par= ams) > no_free_on_del =3D 1; > } > =20 > + if (params->extra_flag & RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_K= EY) > + no_update_data =3D 1; > + > /* Store all keys and leave the first entry as a dummy entry for lookup= _bulk */ > if (use_local_cache) > /* > @@ -428,6 +433,7 @@ rte_hash_create(const struct rte_hash_parameters *par= ams) > h->ext_table_support =3D ext_table_support; > h->writer_takes_lock =3D writer_takes_lock; > h->no_free_on_del =3D no_free_on_del; > + h->no_update_data =3D no_update_data; > h->readwrite_concur_lf_support =3D readwrite_concur_lf_support; > =20 > #if defined(RTE_ARCH_X86) > @@ -707,6 +713,8 @@ search_and_update(const struct rte_hash *h, void *dat= a, const void *key, > k =3D (struct rte_hash_key *) ((char *)keys + > bkt->key_idx[i] * h->key_entry_size); > if (rte_hash_cmp_eq(key, k->key, h) =3D=3D 0) { > + if (h->no_update_data =3D=3D 1) > + return -EINVAL; > /* The store to application data at *data > * should not leak after the store to pdata > * in the key store. i.e. pdata is the guard > diff --git a/lib/hash/rte_cuckoo_hash.h b/lib/hash/rte_cuckoo_hash.h > index eb2644f74b..e8b7283ec2 100644 > --- a/lib/hash/rte_cuckoo_hash.h > +++ b/lib/hash/rte_cuckoo_hash.h > @@ -193,6 +193,8 @@ struct rte_hash { > /**< If read-write concurrency support is enabled */ > uint8_t ext_table_support; /**< Enable extendable bucket table */ > uint8_t no_free_on_del; > + /**< If update is prohibited on adding same key */ > + uint8_t no_update_data; > /**< If key index should be freed on calling rte_hash_del_xxx APIs. > * If this is set, rte_hash_free_key_with_position must be called to > * free the key index associated with the deleted entry. > diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h > index 7ecc021111..ca5b4841d2 100644 > --- a/lib/hash/rte_hash.h > +++ b/lib/hash/rte_hash.h > @@ -55,6 +55,10 @@ extern "C" { > */ > #define RTE_HASH_EXTRA_FLAGS_RW_CONCURRENCY_LF 0x20 > =20 > +/** Flag to disable updating data of existing key > + */ > +#define RTE_HASH_EXTRA_FLAGS_DISABLE_UPDATE_EXISTING_KEY 0x40 > + > /** > * The type of hash value of a key. > * It should be a value of at least 32bit with fully random pattern. >=20