<div dir="ltr"><div dir="ltr">Just one more question.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 3, 2024 at 10:14 PM Honnappa Nagarahalli <<a href="mailto:Honnappa.Nagarahalli@arm.com">Honnappa.Nagarahalli@arm.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello Abdullah,<br>
Thank you for the patch, few comments inline.<br>
<br>
The short commit log could be changed as follows:<br>
<br>
"lib/hash: add defer queue reclaim API”<br>
<br>
> On Mar 2, 2024, at 3:27 PM, Abdullah Ömer Yamaç <<a href="mailto:aomeryamac@gmail.com" target="_blank">aomeryamac@gmail.com</a>> wrote:<br>
> <br>
> This patch adds a new feature to the hash library to allow the user to<br>
> reclaim the defer queue. This is useful when the user wants to force<br>
> reclaim resources that are not being used. This API is only available<br>
> if the RCU is enabled.<br>
> <br>
> Signed-off-by: Abdullah Ömer Yamaç <<a href="mailto:aomeryamac@gmail.com" target="_blank">aomeryamac@gmail.com</a>><br>
> Acked-by: Honnappa Nagarahalli <<a href="mailto:honnappa.nagarahalli@arm.com" target="_blank">honnappa.nagarahalli@arm.com</a>><br>
Please add this only after you get an explicit Ack on the patch.<br>
<br>
> ---<br>
> lib/hash/rte_cuckoo_hash.c | 23 +++++++++++++++++++++++<br>
> lib/hash/rte_hash.h | 14 ++++++++++++++<br>
> lib/hash/version.map | 7 +++++++<br>
> 3 files changed, 44 insertions(+)<br>
> <br>
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c<br>
> index 9cf94645f6..254fa80cc5 100644<br>
> --- a/lib/hash/rte_cuckoo_hash.c<br>
> +++ b/lib/hash/rte_cuckoo_hash.c<br>
> @@ -1588,6 +1588,27 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)<br>
> return 0;<br>
> }<br>
> <br>
> +int<br>
> +rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h)<br>
We need to add freed, pending and available parameters to this API. I think this information will be helpful for the users. For ex: in your use case, you could use the pending value to calculate the available hash entries.<br>
<br></blockquote><div>The second parameter, "Maximum number of resources to free.", should be available also? I set this value to " h->hash_rcu_cfg->max_reclaim_size", but it can be a parameter in addition to the above parameters</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> +{<br>
> + int ret;<br>
> +<br>
> + if (h->hash_rcu_cfg == NULL || h->dq == NULL) {<br>
We can skip NULL check for h->dq as the RCU reclaim API makes the same check.<br>
<br>
> + rte_errno = EINVAL;<br>
> + return -1;<br>
> + }<br>
> +<br>
> + ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size, NULL, NULL, NULL);<br>
> + if (ret != 0) {<br>
> + HASH_LOG(ERR,<br>
> + "%s: could not reclaim the defer queue in hash table",<br>
> + __func__);<br>
> + return -1;<br>
> + }<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> static inline void<br>
> remove_entry(const struct rte_hash *h, struct rte_hash_bucket *bkt,<br>
> unsigned int i)<br>
> diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h<br>
> index 7ecc021111..c119477d50 100644<br>
> --- a/lib/hash/rte_hash.h<br>
> +++ b/lib/hash/rte_hash.h<br>
> @@ -674,6 +674,21 @@ rte_hash_iterate(const struct rte_hash *h, const void **key, void **data, uint32<br>
> */<br>
> int rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg);<br>
> <br>
> +/**<br>
> + * Reclaim resources from the defer queue.<br>
> + * This API reclaim the resources from the defer queue if rcu is enabled.<br>
> + *<br>
> + * @param h<br>
> + * the hash object to reclaim resources<br>
> + * @return<br>
> + * On success - 0<br>
> + * On error - 1 with error code set in rte_errno.<br>
> + * Possible rte_errno codes are:<br>
> + * - EINVAL - invalid pointer or invalid rcu mode<br>
We can remove the ‘invalid rcd mode’.<br>
<br>
> + */<br>
> +__rte_experimental<br>
> +int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h);<br>
> +<br>
> #ifdef __cplusplus<br>
> }<br>
> #endif<br>
> diff --git a/lib/hash/version.map b/lib/hash/version.map<br>
> index 6b2afebf6b..cec0e8fc67 100644<br>
> --- a/lib/hash/version.map<br>
> +++ b/lib/hash/version.map<br>
> @@ -48,3 +48,9 @@ DPDK_24 {<br>
> <br>
> local: *;<br>
> };<br>
> +<br>
> +EXPERIMENTAL {<br>
> + global:<br>
> +<br>
> + rte_hash_rcu_qsbr_dq_reclaim;<br>
> +}<br>
> \ No newline at end of file<br>
> -- <br>
> 2.34.1<br>
> <br>
<br>
</blockquote></div></div>