From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C194643B67;
	Wed, 21 Feb 2024 22:51:13 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 526D440297;
	Wed, 21 Feb 2024 22:51:13 +0100 (CET)
Received: from mail-oa1-f49.google.com (mail-oa1-f49.google.com
 [209.85.160.49]) by mails.dpdk.org (Postfix) with ESMTP id 1F8C34013F
 for <dev@dpdk.org>; Wed, 21 Feb 2024 22:51:12 +0100 (CET)
Received: by mail-oa1-f49.google.com with SMTP id
 586e51a60fabf-21f2f813e3bso111385fac.0
 for <dev@dpdk.org>; Wed, 21 Feb 2024 13:51:12 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1708552271; x=1709157071; 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=lgjcUwOHiGpIgV1TsI/zJXF6/FsbLgfOKK/Awyqt3ls=;
 b=gs43yevpEApC/Kf0eWn+kKYyKNZa6IQGKklDWoLc1g0s3MSBZKkh7CBNg5ZGB3jENH
 1WmfrDcERrGDbO2dEja+8Nn77WhE8GT1D7eQnLHN3mzT9df4/IdkR3hcNRvximvGZs9P
 YGozf8MfH+Xe2P43OupTnOhjg9NgP8kKq1WbYwIPb2pNJd+haxnvLsgBLT4OhLJrCXFT
 +lKJ/vMw1dMEvI+8HjnU/FoOwkNFUfIIlOWvx9V46kJ4Kf1c4H/ZvZp+b37goxbJE7JM
 yqtjwpclV4mYOb/CKSvD6juCX8dyEqf6/9XQqS8EJugTZuNJ2WBI5fh8AukINLD8deOW
 fmGw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1708552271; x=1709157071;
 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=lgjcUwOHiGpIgV1TsI/zJXF6/FsbLgfOKK/Awyqt3ls=;
 b=sYp18T+ojqGFhzfjS81xDESP5o/NVQ7FcKjpcFM8Q5CjiWQn9w+hppeZqUxairdbYh
 JXwSjON2SD3hdPWkKdfFNzkwtw+Yc7Xxg+VHtb3cPSk2SS3j2+VkPcXVf0yDeqy+fLKl
 H31T1OH8wL64ZOvaUY2L/yHpS1dknExDQgxZF3P9T10MpI3ws4WtgrahC+eflMd6W8IH
 VrwFnzkhwhUQ2BuXIEkMKvr166SVLty/jKyW0W1V4TMhF2JQABFYg2arUwYZnWvB31C0
 bE1aHCaMV4lB2hE04/UtBa1n+GJCOMiEpZ0+SMj+LWSjERYYJclgs/B8XnmVmzu4rVuI
 z1SQ==
X-Forwarded-Encrypted: i=1;
 AJvYcCWrgTJVlSMU6ycx7WTYpNDcQFZVhf1XrGXuNVt4Il+zoB0R7TwGE07N2YZk5HemQGuzMHSx1YBZ1c+UrOU=
X-Gm-Message-State: AOJu0YyqxhIjfS1eH/1HH8hofABzfPh1K4x09TZo2itUEj0oP2JEG4LI
 /6KhOlpd5c4z0GvYMsZvWYBE+neyVaUnGVyK0tfsF/XWJtPAVezG2DPJF5laLKahkCLQ+xFfu4u
 QV/dwxLu1NC/3uZqXSWzzQGW5/wg=
X-Google-Smtp-Source: AGHT+IGBerrMqhC4j9uhQ2oTy21VFjeWsF79Ussr5aysu29DCkh1FHAEOV90K6TJ6oUdsaIWIbLvINTTuQf6Wd1tj4o=
X-Received: by 2002:a05:6870:148d:b0:21f:7238:905a with SMTP id
 k13-20020a056870148d00b0021f7238905amr4508oab.3.1708552271180; Wed, 21 Feb
 2024 13:51:11 -0800 (PST)
MIME-Version: 1.0
References: <20240207153340.34146-1-aomeryamac@gmail.com>
 <cc8ac134-3c87-4f4e-9b21-261dad19b740@intel.com>
 <CA+sj1i-HXEt6jGLyUEbO8oj46Q215DPSFvFo1rZwivW1kJDJ=g@mail.gmail.com>
 <4CC50196-1F8F-40E2-8280-261783FDCFC8@arm.com>
 <CA+sj1i-LverDff3YKOjZ-52NNoUkwQqG2yCCxxPM4CjU0d135w@mail.gmail.com>
 <CA06E482-DAFA-4AEB-98E5-4500A249149E@arm.com>
In-Reply-To: <CA06E482-DAFA-4AEB-98E5-4500A249149E@arm.com>
From: =?UTF-8?B?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= <aomeryamac@gmail.com>
Date: Thu, 22 Feb 2024 00:51:01 +0300
Message-ID: <CA+sj1i9iW8E+U7Y+wVJUrZ1cJAgXRTRP363rD4_i_COwV0J+tQ@mail.gmail.com>
Subject: Re: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash
To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
Cc: "Medvedkin, Vladimir" <vladimir.medvedkin@intel.com>,
 "dev@dpdk.org" <dev@dpdk.org>, 
 Yipeng Wang <yipeng1.wang@intel.com>, Sameh Gobriel <sameh.gobriel@intel.com>, 
 Bruce Richardson <bruce.richardson@intel.com>,
 "thomas@monjalon.net" <thomas@monjalon.net>, nd <nd@arm.com>
Content-Type: multipart/alternative; boundary="0000000000003439a60611eb5352"
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

--0000000000003439a60611eb5352
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, Feb 21, 2024 at 6:24=E2=80=AFAM Honnappa Nagarahalli <
Honnappa.Nagarahalli@arm.com> wrote:

>
>
> > On Feb 20, 2024, at 12:58=E2=80=AFPM, Abdullah =C3=96mer Yama=C3=A7 <ao=
meryamac@gmail.com>
> wrote:
> >
> > I appreciate that you gave me suggestions and comments. I will make
> changes according to all your recommendations, but before that, I want to
> make everyone's minds clear. Then, I will apply modifications.
> >
> > On Tue, Feb 20, 2024 at 2:35=E2=80=AFAM Honnappa Nagarahalli <
> Honnappa.Nagarahalli@arm.com> wrote:
> >
> >
> > > On Feb 19, 2024, at 3:28=E2=80=AFPM, Abdullah =C3=96mer Yama=C3=A7 <a=
omeryamac@gmail.com>
> wrote:
> > >
> > > Hello,
> > >
> > > Let me explain a use case;
> > >
> > > I have a hash table whose key value is IP addresses, and data (let's
> say the username of the IP) is related to the IP address. The key point i=
s
> matching these data with flows. Flows are dynamic, and this hash table is
> dynamic, as well; both can change anytime. For example, when a flow start=
s,
> we look up the hash table with the corresponding IP and retrieve the
> username. We need to hold this username until the flow terminates, althou=
gh
> we removed this IP key from the hash table (multithread). That's why we
> have RCU and defer queue is necessary for high performance. In my
> application, I need to know the number of IP-username entries. These
> numbers can be calculated by rte_hash_count - defer queue size.
> > The entries in the defer queue are not reclaimed (there is a probabilit=
y
> that all of them can be reclaimed) and hence they are not available for
> allocation. So, rte_hash_count - defer queue size might not give you the
> correct number you are expecting.
> >
> > Currently, there is no API in hash library that forces a reclaim. Does
> it makes sense to have an API that just does the reclaim (and returns the
> number of entries pending in the defer queue)? A call to rte_hash_count
> should provide the exact count you are looking for.
> > You are right; no API in the hash library forces a reclaim. In my
> application, I periodically call rte_count to retrieve hash size, and thi=
s
> data is shown in my GUI. So that means I need to call regularly reclaim. =
I
> am trying to figure out which is better, calling reclaim or retrieving th=
e
> defer queue size. Any comment about this?
> Retrieving the defer queue size will be cheaper. However, calling the
> reclaim API will ensure the entries are freed hence providing an accurate
> number. Calling the reclaim API on an empty defer queue does not consume
> many cycles. If needed we could add a check for empty defer queue in the
> reclaim API and return early.
>
> I am also wondering if a reclaim API in hash library is needed. Why not
> call rte_rcu_qsbr_dq_reclaim API from the application?
>
The reason is simple. struct rte_hash *h is an internal structure and we
cannot access the h->dq. So it is not possible to call reclaim.

>
>
> > >
> > > I think if you need a non-blocking and multithreaded hash table, an
> RCU-enabled hash table is necessary. Also, this API is necessary if you
> need to get the actual matchable size.
> > >
> > >
> > >
> > >
> > >
> > > On Mon, Feb 19, 2024 at 8:36=E2=80=AFPM Medvedkin, Vladimir <
> vladimir.medvedkin@intel.com> wrote:
> > > Hi Abdullah,
> > >
> > > Could you please tell more about use cases where this API may be
> useful?
> > >
> > > >a new API to get the hidden key count in the hash table if the rcu
> qsbr is enabled
> > >
> > > Here in commit message and down below in doxygen comments, I think
> this
> > > statement should be more specific because rcu can be created with
> > > RTE_HASH_QSBR_MODE_SYNC mode i.e. without defer queue.
> > >
> > > Also, new API must be reflected in release notes
> > >
> > > On 07/02/2024 15:33, Abdullah =C3=96mer Yama=C3=A7 wrote:
> > > > This patch introduce a new API to get the hidden key count in the
> hash
> > > > table if the rcu qsbr is enabled. When using rte_hash_count with rc=
u
> > > > qsbr enabled, it will return the number of elements that are not in
> the
> > > > free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the number of
> > > > elements in the defer queue will not be counted and freed. Therefor=
e
> I
> > > > added a new API to get the number of hidden (defer queue) elements
> > > > in the hash table. Then the user can calculate the total number of
> > > > elements that are available in the hash table.
> > > >
> > > > Signed-off-by: Abdullah =C3=96mer Yama=C3=A7 <aomeryamac@gmail.com>
> > > >
> > > > ---
> > > > Cc: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > > > Cc: Yipeng Wang <yipeng1.wang@intel.com>
> > > > Cc: Sameh Gobriel <sameh.gobriel@intel.com>
> > > > Cc: Bruce Richardson <bruce.richardson@intel.com>
> > > > Cc: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> > > > ---
> > > >   lib/hash/rte_cuckoo_hash.c |  9 +++++++++
> > > >   lib/hash/rte_hash.h        | 13 +++++++++++++
> > > >   lib/hash/version.map       |  1 +
> > > >   lib/rcu/rte_rcu_qsbr.c     |  8 ++++++++
> > > >   lib/rcu/rte_rcu_qsbr.h     | 11 +++++++++++
> > > >   lib/rcu/version.map        |  1 +
> > > >   6 files changed, 43 insertions(+)
> > > >
> > > > diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.=
c
> > > > index 70456754c4..3553f3efc7 100644
> > > > --- a/lib/hash/rte_cuckoo_hash.c
> > > > +++ b/lib/hash/rte_cuckoo_hash.c
> > > > @@ -555,6 +555,15 @@ rte_hash_max_key_id(const struct rte_hash *h)
> > > >               return h->entries;
> > > >   }
> > > >
> > > > +int32_t
> > > > +rte_hash_dq_count(const struct rte_hash *h)
> > > > +{
> > > > +     if (h->dq =3D=3D NULL)
> > > input arguments must be checked since this is a public API, the same
> is
> > > true for rte_rcu_qsbr_dq_count()
> > > > +             return -EINVAL;
> > > why not just return 0?
> > > > +
> > > > +     return rte_rcu_qsbr_dq_count(h->dq);
> > > > +}
> > > > +
> > > >   int32_t
> > > >   rte_hash_count(const struct rte_hash *h)
> > > >   {
> > > > diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h
> > > > index 7ecc021111..8ea97e297d 100644
> > > > --- a/lib/hash/rte_hash.h
> > > > +++ b/lib/hash/rte_hash.h
> > > > @@ -193,6 +193,19 @@ rte_hash_free(struct rte_hash *h);
> > > >   void
> > > >   rte_hash_reset(struct rte_hash *h);
> > > >
> > > > +
> > > > +/**
> > > > + * Return the number of records in the defer queue of the hash tab=
le
> > > > + * if RCU is enabled.
> > > > + * @param h
> > > > + *  Hash table to query from
> > > > + * @return
> > > > + *   - -EINVAL if parameters are invalid
> > > > + *   - A value indicating how many records were inserted in the
> table.
> > > did you mean how many records are kept in defer queue?
> > > > + */
> > > > +int32_t
> > > > +rte_hash_dq_count(const struct rte_hash *h);
> > > > +
> > > >   /**
> > > >    * Return the number of keys in the hash table
> > > >    * @param h
> > > > diff --git a/lib/hash/version.map b/lib/hash/version.map
> > > > index 6b2afebf6b..7f7b158cf1 100644
> > > > --- a/lib/hash/version.map
> > > > +++ b/lib/hash/version.map
> > > > @@ -9,6 +9,7 @@ DPDK_24 {
> > > >       rte_hash_add_key_with_hash;
> > > >       rte_hash_add_key_with_hash_data;
> > > >       rte_hash_count;
> > > > +     rte_hash_dq_count;
> > > new API must introduced as an experimental API. The same is true for
> > > rte_rcu_qsbr_dq_count()
> > > >       rte_hash_crc32_alg;
> > > >       rte_hash_crc_set_alg;
> > > >       rte_hash_create;
> > > > diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c
> > > > index bd0b83be0c..89f8da4c4c 100644
> > > > --- a/lib/rcu/rte_rcu_qsbr.c
> > > > +++ b/lib/rcu/rte_rcu_qsbr.c
> > > > @@ -450,6 +450,14 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq
> *dq, unsigned int n,
> > > >       return 0;
> > > >   }
> > > >
> > > > +/**
> > > > + * Return the number of entries in a defer queue.
> > > > + */
> > > > +unsigned int rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq)
> > > > +{
> > Please validate dq here.
> >
> > > > +     return rte_ring_count(dq->r);
> > > > +}
> > > > +
> > > >   /* Delete a defer queue. */
> > > >   int
> > > >   rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq)
> > > > diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h
> > > > index 23c9f89805..ed5a590edd 100644
> > > > --- a/lib/rcu/rte_rcu_qsbr.h
> > > > +++ b/lib/rcu/rte_rcu_qsbr.h
> > > > @@ -794,6 +794,17 @@ int
> > > >   rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int =
n,
> > > >       unsigned int *freed, unsigned int *pending, unsigned int
> *available);
> > > >
> > > > +/**
> > > > + * Return the number of entries in a defer queue.
> > > > + *
> > > > + * @param dq
> > > > + *   Defer queue.
> > > > + * @return
> > > > + *   The number of entries in the defer queue.
> > > > + */
> > > > +unsigned int
> > > > +rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq);
> > Agree on the need for this API in RCU
> >
> > > > +
> > > >   /**
> > > >    * Delete a defer queue.
> > > >    *
> > > > diff --git a/lib/rcu/version.map b/lib/rcu/version.map
> > > > index 982ffd59d9..f410ab41e7 100644
> > > > --- a/lib/rcu/version.map
> > > > +++ b/lib/rcu/version.map
> > > > @@ -5,6 +5,7 @@ DPDK_24 {
> > > >       rte_rcu_qsbr_dq_create;
> > > >       rte_rcu_qsbr_dq_delete;
> > > >       rte_rcu_qsbr_dq_enqueue;
> > > > +     rte_rcu_qsbr_dq_count;
> > > >       rte_rcu_qsbr_dq_reclaim;
> > > >       rte_rcu_qsbr_dump;
> > > >       rte_rcu_qsbr_get_memsize;
> > >
> > > --
> > > Regards,
> > > Vladimir
> > >
> >
>
>

--0000000000003439a60611eb5352
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Wed, Feb 21, 2024 at 6:24=E2=80=AF=
AM Honnappa Nagarahalli &lt;<a href=3D"mailto:Honnappa.Nagarahalli@arm.com"=
>Honnappa.Nagarahalli@arm.com</a>&gt; wrote:<br></div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20=
4,204,204);padding-left:1ex"><br>
<br>
&gt; On Feb 20, 2024, at 12:58=E2=80=AFPM, Abdullah =C3=96mer Yama=C3=A7 &l=
t;<a href=3D"mailto:aomeryamac@gmail.com" target=3D"_blank">aomeryamac@gmai=
l.com</a>&gt; wrote:<br>
&gt; <br>
&gt; I appreciate that you gave me suggestions and comments. I will make ch=
anges according to all your recommendations, but before that, I want to mak=
e everyone&#39;s minds clear. Then, I will apply modifications. <br>
&gt; <br>
&gt; On Tue, Feb 20, 2024 at 2:35=E2=80=AFAM Honnappa Nagarahalli &lt;<a hr=
ef=3D"mailto:Honnappa.Nagarahalli@arm.com" target=3D"_blank">Honnappa.Nagar=
ahalli@arm.com</a>&gt; wrote:<br>
&gt; <br>
&gt; <br>
&gt; &gt; On Feb 19, 2024, at 3:28=E2=80=AFPM, Abdullah =C3=96mer Yama=C3=
=A7 &lt;<a href=3D"mailto:aomeryamac@gmail.com" target=3D"_blank">aomeryama=
c@gmail.com</a>&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt; Hello,<br>
&gt; &gt; <br>
&gt; &gt; Let me explain a use case;<br>
&gt; &gt; <br>
&gt; &gt; I have a hash table whose key value is IP addresses, and data (le=
t&#39;s say the username of the IP) is related to the IP address. The key p=
oint is matching these data with flows. Flows are dynamic, and this hash ta=
ble is dynamic, as well; both can change anytime. For example, when a flow =
starts, we look up the hash table with the corresponding IP and retrieve th=
e username. We need to hold this username until the flow terminates, althou=
gh we removed this IP key from the hash table (multithread). That&#39;s why=
 we have RCU and defer queue is necessary for high performance. In my appli=
cation, I need to know the number of IP-username entries. These numbers can=
 be calculated by rte_hash_count - defer queue size.<br>
&gt; The entries in the defer queue are not reclaimed (there is a probabili=
ty that all of them can be reclaimed) and hence they are not available for =
allocation. So, rte_hash_count - defer queue size might not give you the co=
rrect number you are expecting.<br>
&gt; <br>
&gt; Currently, there is no API in hash library that forces a reclaim. Does=
 it makes sense to have an API that just does the reclaim (and returns the =
number of entries pending in the defer queue)? A call to rte_hash_count sho=
uld provide the exact count you are looking for.<br>
&gt; You are right; no API in the hash library forces a reclaim. In my appl=
ication, I periodically call rte_count to retrieve hash size, and this data=
 is shown in my GUI. So that means I need to call regularly reclaim. I am t=
rying to figure out which is better, calling reclaim or retrieving the defe=
r queue size. Any comment about this?<br>
Retrieving the defer queue size will be cheaper. However, calling the recla=
im API will ensure the entries are freed hence providing an accurate number=
. Calling the reclaim API on an empty defer queue does not consume many cyc=
les. If needed we could add a check for empty defer queue in the reclaim AP=
I and return early.<br>
<br>
I am also wondering if a reclaim API in hash library is needed. Why not cal=
l rte_rcu_qsbr_dq_reclaim API from the application?<br></blockquote><div>Th=
e reason is simple. struct rte_hash *h is an internal structure and we cann=
ot access the h-&gt;dq. So it is not possible to call reclaim.</div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
&gt; &gt; <br>
&gt; &gt; I think if you need a non-blocking and multithreaded hash table, =
an RCU-enabled hash table is necessary. Also, this API is necessary if you =
need to get the actual matchable size.<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; On Mon, Feb 19, 2024 at 8:36=E2=80=AFPM Medvedkin, Vladimir &lt;<=
a href=3D"mailto:vladimir.medvedkin@intel.com" target=3D"_blank">vladimir.m=
edvedkin@intel.com</a>&gt; wrote:<br>
&gt; &gt; Hi Abdullah,<br>
&gt; &gt; <br>
&gt; &gt; Could you please tell more about use cases where this API may be =
useful?<br>
&gt; &gt; <br>
&gt; &gt; &gt;a new API to get the hidden key count in the hash table if th=
e rcu qsbr is enabled<br>
&gt; &gt; <br>
&gt; &gt; Here in commit message and down below in doxygen comments, I thin=
k this <br>
&gt; &gt; statement should be more specific because rcu can be created with=
 <br>
&gt; &gt; RTE_HASH_QSBR_MODE_SYNC mode i.e. without defer queue.<br>
&gt; &gt; <br>
&gt; &gt; Also, new API must be reflected in release notes<br>
&gt; &gt; <br>
&gt; &gt; On 07/02/2024 15:33, Abdullah =C3=96mer Yama=C3=A7 wrote:<br>
&gt; &gt; &gt; This patch introduce a new API to get the hidden key count i=
n the hash<br>
&gt; &gt; &gt; table if the rcu qsbr is enabled. When using rte_hash_count =
with rcu<br>
&gt; &gt; &gt; qsbr enabled, it will return the number of elements that are=
 not in the<br>
&gt; &gt; &gt; free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the nu=
mber of<br>
&gt; &gt; &gt; elements in the defer queue will not be counted and freed. T=
herefore I<br>
&gt; &gt; &gt; added a new API to get the number of hidden (defer queue) el=
ements<br>
&gt; &gt; &gt; in the hash table. Then the user can calculate the total num=
ber of<br>
&gt; &gt; &gt; elements that are available in the hash table.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Signed-off-by: Abdullah =C3=96mer Yama=C3=A7 &lt;<a href=3D"=
mailto:aomeryamac@gmail.com" target=3D"_blank">aomeryamac@gmail.com</a>&gt;=
<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; ---<br>
&gt; &gt; &gt; Cc: Honnappa Nagarahalli &lt;<a href=3D"mailto:honnappa.naga=
rahalli@arm.com" target=3D"_blank">honnappa.nagarahalli@arm.com</a>&gt;<br>
&gt; &gt; &gt; Cc: Yipeng Wang &lt;<a href=3D"mailto:yipeng1.wang@intel.com=
" target=3D"_blank">yipeng1.wang@intel.com</a>&gt;<br>
&gt; &gt; &gt; Cc: Sameh Gobriel &lt;<a href=3D"mailto:sameh.gobriel@intel.=
com" target=3D"_blank">sameh.gobriel@intel.com</a>&gt;<br>
&gt; &gt; &gt; Cc: Bruce Richardson &lt;<a href=3D"mailto:bruce.richardson@=
intel.com" target=3D"_blank">bruce.richardson@intel.com</a>&gt;<br>
&gt; &gt; &gt; Cc: Vladimir Medvedkin &lt;<a href=3D"mailto:vladimir.medved=
kin@intel.com" target=3D"_blank">vladimir.medvedkin@intel.com</a>&gt;<br>
&gt; &gt; &gt; ---<br>
&gt; &gt; &gt;=C2=A0 =C2=A0lib/hash/rte_cuckoo_hash.c |=C2=A0 9 +++++++++<b=
r>
&gt; &gt; &gt;=C2=A0 =C2=A0lib/hash/rte_hash.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=
 13 +++++++++++++<br>
&gt; &gt; &gt;=C2=A0 =C2=A0lib/hash/version.map=C2=A0 =C2=A0 =C2=A0 =C2=A0|=
=C2=A0 1 +<br>
&gt; &gt; &gt;=C2=A0 =C2=A0lib/rcu/rte_rcu_qsbr.c=C2=A0 =C2=A0 =C2=A0|=C2=
=A0 8 ++++++++<br>
&gt; &gt; &gt;=C2=A0 =C2=A0lib/rcu/rte_rcu_qsbr.h=C2=A0 =C2=A0 =C2=A0| 11 +=
++++++++++<br>
&gt; &gt; &gt;=C2=A0 =C2=A0lib/rcu/version.map=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=
=C2=A0 1 +<br>
&gt; &gt; &gt;=C2=A0 =C2=A06 files changed, 43 insertions(+)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cucko=
o_hash.c<br>
&gt; &gt; &gt; index 70456754c4..3553f3efc7 100644<br>
&gt; &gt; &gt; --- a/lib/hash/rte_cuckoo_hash.c<br>
&gt; &gt; &gt; +++ b/lib/hash/rte_cuckoo_hash.c<br>
&gt; &gt; &gt; @@ -555,6 +555,15 @@ rte_hash_max_key_id(const struct rte_ha=
sh *h)<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return=
 h-&gt;entries;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0}<br>
&gt; &gt; &gt;=C2=A0 =C2=A0<br>
&gt; &gt; &gt; +int32_t<br>
&gt; &gt; &gt; +rte_hash_dq_count(const struct rte_hash *h)<br>
&gt; &gt; &gt; +{<br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0if (h-&gt;dq =3D=3D NULL)<br>
&gt; &gt; input arguments must be checked since this is a public API, the s=
ame is <br>
&gt; &gt; true for rte_rcu_qsbr_dq_count()<br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -EIN=
VAL;<br>
&gt; &gt; why not just return 0?<br>
&gt; &gt; &gt; +<br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0return rte_rcu_qsbr_dq_count(h-&gt;dq);=
<br>
&gt; &gt; &gt; +}<br>
&gt; &gt; &gt; +<br>
&gt; &gt; &gt;=C2=A0 =C2=A0int32_t<br>
&gt; &gt; &gt;=C2=A0 =C2=A0rte_hash_count(const struct rte_hash *h)<br>
&gt; &gt; &gt;=C2=A0 =C2=A0{<br>
&gt; &gt; &gt; diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h<br>
&gt; &gt; &gt; index 7ecc021111..8ea97e297d 100644<br>
&gt; &gt; &gt; --- a/lib/hash/rte_hash.h<br>
&gt; &gt; &gt; +++ b/lib/hash/rte_hash.h<br>
&gt; &gt; &gt; @@ -193,6 +193,19 @@ rte_hash_free(struct rte_hash *h);<br>
&gt; &gt; &gt;=C2=A0 =C2=A0void<br>
&gt; &gt; &gt;=C2=A0 =C2=A0rte_hash_reset(struct rte_hash *h);<br>
&gt; &gt; &gt;=C2=A0 =C2=A0<br>
&gt; &gt; &gt; +<br>
&gt; &gt; &gt; +/**<br>
&gt; &gt; &gt; + * Return the number of records in the defer queue of the h=
ash table<br>
&gt; &gt; &gt; + * if RCU is enabled.<br>
&gt; &gt; &gt; + * @param h<br>
&gt; &gt; &gt; + *=C2=A0 Hash table to query from<br>
&gt; &gt; &gt; + * @return<br>
&gt; &gt; &gt; + *=C2=A0 =C2=A0- -EINVAL if parameters are invalid<br>
&gt; &gt; &gt; + *=C2=A0 =C2=A0- A value indicating how many records were i=
nserted in the table.<br>
&gt; &gt; did you mean how many records are kept in defer queue?<br>
&gt; &gt; &gt; + */<br>
&gt; &gt; &gt; +int32_t<br>
&gt; &gt; &gt; +rte_hash_dq_count(const struct rte_hash *h);<br>
&gt; &gt; &gt; +<br>
&gt; &gt; &gt;=C2=A0 =C2=A0/**<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 * Return the number of keys in the hash table<b=
r>
&gt; &gt; &gt;=C2=A0 =C2=A0 * @param h<br>
&gt; &gt; &gt; diff --git a/lib/hash/version.map b/lib/hash/version.map<br>
&gt; &gt; &gt; index 6b2afebf6b..7f7b158cf1 100644<br>
&gt; &gt; &gt; --- a/lib/hash/version.map<br>
&gt; &gt; &gt; +++ b/lib/hash/version.map<br>
&gt; &gt; &gt; @@ -9,6 +9,7 @@ DPDK_24 {<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_add_key_with_hash;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_add_key_with_hash_data;<b=
r>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_count;<br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0rte_hash_dq_count;<br>
&gt; &gt; new API must introduced as an experimental API. The same is true =
for <br>
&gt; &gt; rte_rcu_qsbr_dq_count()<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_crc32_alg;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_crc_set_alg;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_hash_create;<br>
&gt; &gt; &gt; diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c=
<br>
&gt; &gt; &gt; index bd0b83be0c..89f8da4c4c 100644<br>
&gt; &gt; &gt; --- a/lib/rcu/rte_rcu_qsbr.c<br>
&gt; &gt; &gt; +++ b/lib/rcu/rte_rcu_qsbr.c<br>
&gt; &gt; &gt; @@ -450,6 +450,14 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_=
qsbr_dq *dq, unsigned int n,<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0}<br>
&gt; &gt; &gt;=C2=A0 =C2=A0<br>
&gt; &gt; &gt; +/**<br>
&gt; &gt; &gt; + * Return the number of entries in a defer queue.<br>
&gt; &gt; &gt; + */<br>
&gt; &gt; &gt; +unsigned int rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *=
dq)<br>
&gt; &gt; &gt; +{<br>
&gt; Please validate dq here.<br>
&gt; <br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0return rte_ring_count(dq-&gt;r);<br>
&gt; &gt; &gt; +}<br>
&gt; &gt; &gt; +<br>
&gt; &gt; &gt;=C2=A0 =C2=A0/* Delete a defer queue. */<br>
&gt; &gt; &gt;=C2=A0 =C2=A0int<br>
&gt; &gt; &gt;=C2=A0 =C2=A0rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *d=
q)<br>
&gt; &gt; &gt; diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h=
<br>
&gt; &gt; &gt; index 23c9f89805..ed5a590edd 100644<br>
&gt; &gt; &gt; --- a/lib/rcu/rte_rcu_qsbr.h<br>
&gt; &gt; &gt; +++ b/lib/rcu/rte_rcu_qsbr.h<br>
&gt; &gt; &gt; @@ -794,6 +794,17 @@ int<br>
&gt; &gt; &gt;=C2=A0 =C2=A0rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *=
dq, unsigned int n,<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int *freed, unsigned int =
*pending, unsigned int *available);<br>
&gt; &gt; &gt;=C2=A0 =C2=A0<br>
&gt; &gt; &gt; +/**<br>
&gt; &gt; &gt; + * Return the number of entries in a defer queue.<br>
&gt; &gt; &gt; + *<br>
&gt; &gt; &gt; + * @param dq<br>
&gt; &gt; &gt; + *=C2=A0 =C2=A0Defer queue.<br>
&gt; &gt; &gt; + * @return<br>
&gt; &gt; &gt; + *=C2=A0 =C2=A0The number of entries in the defer queue.<br=
>
&gt; &gt; &gt; + */<br>
&gt; &gt; &gt; +unsigned int<br>
&gt; &gt; &gt; +rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq);<br>
&gt; Agree on the need for this API in RCU<br>
&gt; <br>
&gt; &gt; &gt; +<br>
&gt; &gt; &gt;=C2=A0 =C2=A0/**<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 * Delete a defer queue.<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 *<br>
&gt; &gt; &gt; diff --git a/lib/rcu/version.map b/lib/rcu/version.map<br>
&gt; &gt; &gt; index 982ffd59d9..f410ab41e7 100644<br>
&gt; &gt; &gt; --- a/lib/rcu/version.map<br>
&gt; &gt; &gt; +++ b/lib/rcu/version.map<br>
&gt; &gt; &gt; @@ -5,6 +5,7 @@ DPDK_24 {<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_dq_create;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_dq_delete;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_dq_enqueue;<br>
&gt; &gt; &gt; +=C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_dq_count;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_dq_reclaim;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_dump;<br>
&gt; &gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0rte_rcu_qsbr_get_memsize;<br>
&gt; &gt; <br>
&gt; &gt; -- <br>
&gt; &gt; Regards,<br>
&gt; &gt; Vladimir<br>
&gt; &gt; <br>
&gt; <br>
<br>
</blockquote></div></div>

--0000000000003439a60611eb5352--