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 5B0F343CAB; Thu, 14 Mar 2024 08:04:16 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C729940297; Thu, 14 Mar 2024 08:04:15 +0100 (CET) Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) by mails.dpdk.org (Postfix) with ESMTP id 51B76400D5 for ; Thu, 14 Mar 2024 08:04:14 +0100 (CET) Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e4f1660493so330576a34.0 for ; Thu, 14 Mar 2024 00:04:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710399853; x=1711004653; darn=dpdk.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vvvYf/KkdzdIOoCtjTPzE2teNiXnoJgOQJMye8XXP7s=; b=NTNYFE/YhfPI+YB80mklE7kZMg2QhiJpWyeq7sj9zqhc8Xlbo9vHLN8hsafXXNPkte kILGTmHqXgxO4CjgltFCEurjmVA49cEJkx4VnMzsQhO0l45jUi5x87kQGmTcjTDunTHa iKNQnVL6ovznQKPmzWDiWL3V0SGokQihUPwcmSSchxh0gX9XAIcaDWMOsrPjoc/UvyCU rNs4tI6w75AksvrCVzBlIzwmE1dPS/4uPTNQEqBgMOUt+3KSaukva2VbP+kbSEkRfxFF TY8YOTeBjTsbfc9ESNSWAy15v2loi+6GfnupvufoFgdUZHko7aS9CbugSd/o4RgGz5bM 77Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710399853; x=1711004653; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vvvYf/KkdzdIOoCtjTPzE2teNiXnoJgOQJMye8XXP7s=; b=YCq35jYU6AQ4Jq0A4zrnskc+bLDTF+ElJkxbb5nPDsSeY+QtsxYTbYoAXTtjAtNgrm ak+jBgAplwzAMlJSgVdOYupumh4dDmUe+1xtDyyRLSV8r0KacYzM+hZb5XYOEuhN/IBC TA8kaxqbe5B3xfNYVhYOnWDtye07kU+2VWSZ26uP7z7MzoZY7VTVUyLAubPnJYtf/xpd VFR5P/juhfxX3+fb59VM8lMf4gFqBt27WrCrTlCC1N5gOoCz0H2SEohKowkhG6dv1ojS n8jvIWA0fPMUvCtdr25CVLGV+LSdQY8gtiv6myOZHhGNUy+matnHmh7GqRqy2vRF1rnO qp1w== X-Gm-Message-State: AOJu0Yx9n2O8QUEymgqQ9Hvl+g9C7cCHHpTDubdzunIp2uijJ4WrPPqS julMqh0NNP850yRat3ig1osZabLVChiFNXlIJ8izdMOGWdBoAJ7vlvERKqM95Auroq/JOFJGluC KzAQQoZmNgD4pIUCEL86ZCaQlN1aQx2Xn X-Google-Smtp-Source: AGHT+IFF5JzSLe6gX7AZq+QiF5mhV/705vQqlzYlFq6dZ/Yo7W5RaygO55egkqR27VUVLOiD45B/fpRSsUXm5xzRGv0= X-Received: by 2002:a05:6870:4341:b0:221:fa57:b70f with SMTP id x1-20020a056870434100b00221fa57b70fmr1095173oah.0.1710399853322; Thu, 14 Mar 2024 00:04:13 -0700 (PDT) MIME-Version: 1.0 References: <2EAE263E-7275-432B-B06A-C50CCFD78DE4@arm.com> <20240306101335.246097-1-aomeryamac@gmail.com> In-Reply-To: <20240306101335.246097-1-aomeryamac@gmail.com> From: =?UTF-8?B?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= Date: Thu, 14 Mar 2024 10:04:05 +0300 Message-ID: Subject: Re: [PATCH v3] lib/hash: add defer queue reclaim API To: dev@dpdk.org Cc: Honnappa Nagarahalli Content-Type: multipart/alternative; boundary="000000000000ae684c0613997f1d" 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 --000000000000ae684c0613997f1d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, Is there any other comment on this? On Wed, Mar 6, 2024 at 1:13=E2=80=AFPM Abdullah =C3=96mer Yama=C3=A7 wrote: > This patch adds a new feature to the hash library to allow the user to > reclaim the defer queue. This is useful when the user wants to force > reclaim resources that are not being used. This API is only available > if the RCU is enabled. > > Signed-off-by: Abdullah =C3=96mer Yama=C3=A7 > --- > lib/hash/rte_cuckoo_hash.c | 23 +++++++++++++++++++++++ > lib/hash/rte_hash.h | 24 ++++++++++++++++++++++++ > lib/hash/version.map | 6 ++++++ > 3 files changed, 53 insertions(+) > > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c > index 9cf94645f6..1c360fa38b 100644 > --- a/lib/hash/rte_cuckoo_hash.c > +++ b/lib/hash/rte_cuckoo_hash.c > @@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct > rte_hash_rcu_config *cfg) > return 0; > } > > +int > +rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed, > + unsigned int *pending, unsigned int *available) > +{ > + int ret; > + > + if (h->hash_rcu_cfg =3D=3D NULL) { > + rte_errno =3D EINVAL; > + return -1; > + } > + > + ret =3D rte_rcu_qsbr_dq_reclaim(h->dq, > h->hash_rcu_cfg->max_reclaim_size, > + freed, pending, > available); > + if (ret !=3D 0) { > + HASH_LOG(ERR, > + "%s: could not reclaim the defer queue in hash > table", > + __func__); > + return -1; > + } > + > + return 0; > +} > + > static inline void > remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, > unsigned int i) > diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h > index 7ecc021111..edfa262aca 100644 > --- a/lib/hash/rte_hash.h > +++ b/lib/hash/rte_hash.h > @@ -674,6 +674,30 @@ rte_hash_iterate(const struct rte_hash *h, const voi= d > **key, void **data, uint32 > */ > int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config > *cfg); > > +/** > + * Reclaim resources from the defer queue. > + * This API reclaim the resources from the defer queue if rcu is enabled= . > + * > + * @param h > + * The hash object to reclaim resources. > + * @param freed > + * Number of resources that were freed. > + * @param pending > + * Number of resources pending on the defer queue. > + * This number might not be accurate if multi-thread safety is > configured. > + * @param available > + * Number of resources that can be added to the defer queue. > + * This number might not be accurate if multi-thread safety is > configured. > + * @return > + * On success - 0 > + * On error - 1 with error code set in rte_errno. > + * Possible rte_errno codes are: > + * - EINVAL - invalid pointer > + */ > +__rte_experimental > +int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed= , > + unsigned int *pending, unsigned int *available); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/hash/version.map b/lib/hash/version.map > index 6b2afebf6b..fac7f81e6f 100644 > --- a/lib/hash/version.map > +++ b/lib/hash/version.map > @@ -48,3 +48,9 @@ DPDK_24 { > > local: *; > }; > + > +EXPERIMENTAL { > + global: > + > + rte_hash_rcu_qsbr_dq_reclaim; > +}; > \ No newline at end of file > -- > 2.34.1 > > --000000000000ae684c0613997f1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,
Is there any other comment on this?=C2=A0
<= br>
On Wed,= Mar 6, 2024 at 1:13=E2=80=AFPM Abdullah =C3=96mer Yama=C3=A7 <aomeryamac@gmail.com> wrote:
This patch adds a new = feature to the hash library to allow the user to
reclaim the defer queue. This is useful when the user wants to force
reclaim resources that are not being used. This API is only available
if the RCU is enabled.

Signed-off-by: Abdullah =C3=96mer Yama=C3=A7 <aomeryamac@gmail.com>
---
=C2=A0lib/hash/rte_cuckoo_hash.c | 23 +++++++++++++++++++++++
=C2=A0lib/hash/rte_hash.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 | 24 +++++++++++++++++= +++++++
=C2=A0lib/hash/version.map=C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 6 ++++++
=C2=A03 files changed, 53 insertions(+)

diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
index 9cf94645f6..1c360fa38b 100644
--- a/lib/hash/rte_cuckoo_hash.c
+++ b/lib/hash/rte_cuckoo_hash.c
@@ -1588,6 +1588,29 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte= _hash_rcu_config *cfg)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
=C2=A0}

+int
+rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int *pendi= ng, unsigned int *available)
+{
+=C2=A0 =C2=A0 =C2=A0 =C2=A0int ret;
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (h->hash_rcu_cfg =3D=3D NULL) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rte_errno =3D EINVA= L;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D rte_rcu_qsbr_dq_reclaim(h->dq, h->= ;hash_rcu_cfg->max_reclaim_size,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0freed, pending, available);=
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (ret !=3D 0) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0HASH_LOG(ERR,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0"%s: could not reclaim the defer queue in hash table",<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0__func__);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -1;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
+}
+
=C2=A0static inline void
=C2=A0remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned int i)
diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
index 7ecc021111..edfa262aca 100644
--- a/lib/hash/rte_hash.h
+++ b/lib/hash/rte_hash.h
@@ -674,6 +674,30 @@ rte_hash_iterate(const struct rte_hash *h, const void = **key, void **data, uint32
=C2=A0 */
=C2=A0int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_con= fig *cfg);

+/**
+ * Reclaim resources from the defer queue.
+ * This API reclaim the resources from the defer queue if rcu is enabled.<= br> + *
+ * @param h
+ *=C2=A0 =C2=A0The hash object to reclaim resources.
+ * @param freed
+ *=C2=A0 =C2=A0Number of resources that were freed.
+ * @param pending
+ *=C2=A0 =C2=A0Number of resources pending on the defer queue.
+ *=C2=A0 =C2=A0This number might not be accurate if multi-thread safety is= configured.
+ * @param available
+ *=C2=A0 =C2=A0Number of resources that can be added to the defer queue. + *=C2=A0 =C2=A0This number might not be accurate if multi-thread safety is= configured.
+ * @return
+ *=C2=A0 =C2=A0On success - 0
+ *=C2=A0 =C2=A0On error - 1 with error code set in rte_errno.
+ *=C2=A0 =C2=A0Possible rte_errno codes are:
+ *=C2=A0 =C2=A0- EINVAL - invalid pointer
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h, unsigned int *freed,<= br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int *pendi= ng, unsigned int *available);
+
=C2=A0#ifdef __cplusplus
=C2=A0}
=C2=A0#endif
diff --git a/lib/hash/version.map b/lib/hash/version.map
index 6b2afebf6b..fac7f81e6f 100644
--- a/lib/hash/version.map
+++ b/lib/hash/version.map
@@ -48,3 +48,9 @@ DPDK_24 {

=C2=A0 =C2=A0 =C2=A0 =C2=A0 local: *;
=C2=A0};
+
+EXPERIMENTAL {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0global:
+
+=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_rcu_qsbr_dq_reclaim;
+};
\ No newline at end of file
--
2.34.1

--000000000000ae684c0613997f1d--