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 D4B5743C56; Wed, 6 Mar 2024 09:55:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9B46040275; Wed, 6 Mar 2024 09:55:25 +0100 (CET) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by mails.dpdk.org (Postfix) with ESMTP id 7F2B740156 for ; Wed, 6 Mar 2024 09:55:24 +0100 (CET) Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d208be133bso90392591fa.2 for ; Wed, 06 Mar 2024 00:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709715323; x=1710320123; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9DCF9iwGsO5DCAJv6kfHJqRgklSafO3sT8hp0aQiTww=; b=QnDpDVnUd7SksJusCYuqnzrSAKE+GGvOgybSUkMlRxRhQzMKTiOVAeBGI3NHmsOdNH eZMerW2t/JVZ1LPY0wpIqvWubiaLAD5XJMNWEO49SQZ5UofPqAOvTeklqIl2MGewDxb8 fh1qcaUsxx9mcndkRnBguhdMOz3rdspQxbI0D41rulXQHCXFIJlXy3yBzTmLeiyaoMkx Bf+tu2MbDCj5VFuBLNo7MkdTswzJlOWmW+nqTW283haLk/wIvRwrIyLIQC5tmVwSxocS WE8aN1ZJLWO8cK0TRQlK2l4FG0+PE2POeVqxUIIujnkL0XgsOV85XnUOJtlr4puTXHPH uZdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709715323; x=1710320123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9DCF9iwGsO5DCAJv6kfHJqRgklSafO3sT8hp0aQiTww=; b=lGjfOD6R2OTyC+5s+E+EaUdixQeESfwzN/HR493vISjTaoxjX2zwm3HBFVg86xKJA7 wuJjJ4tmP7QbzXF7w4bFYQYhk7eDlc8tZA5sJeV1eKRjnkfdFSbOW+FDaXIsnGYGYHOV YrKdIw3jHAHSSsrTXDsqdt8iMlc/+0ip52p4aQIaKF9En/z3T2eO9IRyiV/8qJrX0l8u kTn/gK1qnMne7HW9c9t2OwGyOmXRqUCbzIV7On6sJZeflv8WGf9kyUT7n8iiXpZT45B9 94OaAAeu24pfagz9We+eqbPsF16EA30qL0vrR4fB7Uqhi50wLHZevEYDQtn6Z83SwtIw iXhg== X-Gm-Message-State: AOJu0Yxtvi0voFMXnRmUFioPVQGVHeJgQ6lhSC1pCRgS7avwBSfyVvYL sey5T0w7aWe8UALdSclSZFynLDD8CdnzZO31TUTcZe3wZNwjoYSuWa32vD38x74= X-Google-Smtp-Source: AGHT+IFJiOl9pAZpVPIDeRoPSwzwW4nRftDdL/8h91pSQ8IVk7Dj6KdPsbzuyFKA0ZCBc+kaifSfrw== X-Received: by 2002:a2e:b8c5:0:b0:2d2:9fb1:1c7b with SMTP id s5-20020a2eb8c5000000b002d29fb11c7bmr3422455ljp.25.1709715323281; Wed, 06 Mar 2024 00:55:23 -0800 (PST) Received: from dcu.otaknetworks.com ([212.156.37.190]) by smtp.gmail.com with ESMTPSA id a10-20020a50ff0a000000b005665a6e07fcsm6679607edu.30.2024.03.06.00.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 00:55:22 -0800 (PST) From: =?UTF-8?q?Abdullah=20=C3=96mer=20Yama=C3=A7?= To: dev@dpdk.org Cc: =?UTF-8?q?Abdullah=20=C3=96mer=20Yama=C3=A7?= Subject: [PATCH v3] lib/hash: add defer queue reclaim API Date: Wed, 6 Mar 2024 08:55:19 +0000 Message-Id: <20240306085519.184443-1-aomeryamac@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <2EAE263E-7275-432B-B06A-C50CCFD78DE4@arm.com> References: <2EAE263E-7275-432B-B06A-C50CCFD78DE4@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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ç --- lib/hash/rte_cuckoo_hash.c | 23 +++++++++++++++++++++++ lib/hash/rte_hash.h | 28 +++++++++++++++++++++++++++- lib/hash/version.map | 6 ++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf94645f6..ecc124f1fc 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 == NULL) { + 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 7ecc021111..ad13792dbb 100644 --- a/lib/hash/rte_hash.h +++ b/lib/hash/rte_hash.h @@ -631,7 +631,7 @@ rte_hash_lookup_with_hash_bulk_data(const struct rte_hash *h, */ int rte_hash_lookup_bulk(const struct rte_hash *h, const void **keys, - uint32_t num_keys, int32_t *positions); + uint32_t num_keys, int32_t *positions); /** * Iterate through the hash table, returning key-value pairs. @@ -674,6 +674,32 @@ 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 n + * Maximum number of resources to free. + * @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