[v2] lib/hash: feature reclaim defer queue
Checks
Commit Message
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 Ömer Yamaç <aomeryamac@gmail.com>
Acked-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
---
lib/hash/rte_cuckoo_hash.c | 23 +++++++++++++++++++++++
lib/hash/rte_hash.h | 14 ++++++++++++++
lib/hash/version.map | 7 +++++++
3 files changed, 44 insertions(+)
@@ -1588,6 +1588,27 @@ 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)
+{
+ int ret;
+
+ if (h->hash_rcu_cfg == NULL || h->dq == NULL) {
+ rte_errno = EINVAL;
+ return -1;
+ }
+
+ ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size, NULL, NULL, NULL);
+ if (ret != 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)
@@ -674,6 +674,21 @@ rte_hash_iterate(const struct rte_hash *h, const void **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
+ * @return
+ * On success - 0
+ * On error - 1 with error code set in rte_errno.
+ * Possible rte_errno codes are:
+ * - EINVAL - invalid pointer or invalid rcu mode
+ */
+__rte_experimental
+int rte_hash_rcu_qsbr_dq_reclaim(struct rte_hash *h);
+
#ifdef __cplusplus
}
#endif
@@ -48,3 +48,10 @@ DPDK_24 {
local: *;
};
+
+EXPERIMENTAL {
+ global:
+
+ #added in 24.1
+ rte_hash_rcu_qsbr_dq_reclaim;
+}
\ No newline at end of file