diff options
| author | Abdullah Ömer Yamaç <[email protected]> | 2024-05-15 10:54:46 +0000 |
|---|---|---|
| committer | David Marchand <[email protected]> | 2024-06-18 16:08:17 +0200 |
| commit | 567bb951716f1ae9e418eacda3dd9dac5edf6fde (patch) | |
| tree | 4ab735358cac9b7229bb5192bdaa34d002596d99 /lib/hash | |
| parent | d45a7eed07d6b024956d10af529fcdcdd798227f (diff) | |
hash: reclaim RCU defer queue
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ç <[email protected]>
Reviewed-by: Honnappa Nagarahalli <[email protected]>
Diffstat (limited to 'lib/hash')
| -rw-r--r-- | lib/hash/rte_cuckoo_hash.c | 21 | ||||
| -rw-r--r-- | lib/hash/rte_hash.h | 24 | ||||
| -rw-r--r-- | lib/hash/version.map | 7 |
3 files changed, 52 insertions, 0 deletions
diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 265335f845..d87aa52b5b 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -1590,6 +1590,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, unsigned int *freed, unsigned int *pending, + unsigned int *available) +{ + int ret; + + if (h == NULL || h->hash_rcu_cfg == NULL) { + HASH_LOG(ERR, "Invalid input parameter"); + rte_errno = EINVAL; + return 1; + } + + ret = rte_rcu_qsbr_dq_reclaim(h->dq, h->hash_rcu_cfg->max_reclaim_size, freed, pending, + available); + 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) diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h index ba96521529..05ab447e4a 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 */ 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 6f4bcdb71b..d348dd9196 100644 --- a/lib/hash/version.map +++ b/lib/hash/version.map @@ -53,3 +53,10 @@ INTERNAL { rte_thash_gfni_stub; rte_thash_gfni_bulk_stub; }; + +EXPERIMENTAL { + global: + + # added in 24.07 + rte_hash_rcu_qsbr_dq_reclaim; +}; |
