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 F160443C58; Wed, 6 Mar 2024 11:13:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D566D40276; Wed, 6 Mar 2024 11:13:39 +0100 (CET) Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by mails.dpdk.org (Postfix) with ESMTP id 1351640275 for ; Wed, 6 Mar 2024 11:13:39 +0100 (CET) Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a458850dbddso310193866b.0 for ; Wed, 06 Mar 2024 02:13:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709720018; x=1710324818; 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=E5PUlpR1MuBM/aZXeLUueveJ5c1JpiE8DtGVjX8r+fc=; b=Q9zbtt7EEvOxxJgMS3BGpw+BbSOOZgsIyKhzkX0ADefQT/eAtHj0hw62DJDaxS6sCD 8HX3LJItDoyEmVaFcQ04PSUk+hxpKlfE9+SiDyRCpjyRRixUIFmgQU5VJGdsUTaEBcXZ 5ddHsoiFC3yJhWe3k9eIaSsJrg53jbQHqsOXzRF/GVueEjbDvZ17rFzZ+SWBR8uwX+3m wzcdM0yIiBxBEpfKDcfE2DeKjW8hDa+f9qEUu8wcwLTqDGUv6qrWjkcvFNCIJabNtJai BfNtfKtr9VOFFbyE3K777NNjoaM2ZmdrNNi9EtSuTm533gmwrMqoHLYO1Mk0lSaiuAqX zFUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709720018; x=1710324818; 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=E5PUlpR1MuBM/aZXeLUueveJ5c1JpiE8DtGVjX8r+fc=; b=cPZDYfwoOpGK90OOGAJPe4qt+jEuS7DHxOEpGTFI3y5HXztWQZi6CmwOgvduHBHgC9 OMRwtG4jUretjjZRqy/fMe/YKngEQIrcyyzP+baby/iw6C790fi6xPgBQ47kZQUHHBuF 0zi9HgqYid8pSLtqetZGPsnj6W5zyz7pxqcs1EjL4oIMYVLQaCM1L6cWb33NSzEaW4TB /35WJ7rkV0dmaGoxlS3STiuY0gl73zo9a9rrVWwO3dhH83UPupCv/6uKYlXYflWEV0Ne GHYpyyXe0HT8Ea/+yB8YPnztYBQCfho6TFeX7vpzuTRgMgTICAbiuH5JVzC0yORZkHkV c4Vg== X-Gm-Message-State: AOJu0YxB3t3kHC/OE8axJp/UM3NIrWvWDnI643mdyzwqf1WwfXLiXITb saZiMPLZ2ca3t6Tko75N0EXVMGqLc6P67Gxf9Bds3mkw7V0f1WSgqkz6ES2WVPA= X-Google-Smtp-Source: AGHT+IHPgnHTTH2q9FKqHzWPP0qpITEm5VG2iCdA5BiOl+AbFhNJLlXLhT76nWR78JTdIPFSlTZkGQ== X-Received: by 2002:a17:906:4a55:b0:a44:978b:534a with SMTP id a21-20020a1709064a5500b00a44978b534amr9286959ejv.64.1709720018213; Wed, 06 Mar 2024 02:13:38 -0800 (PST) Received: from dcu.otaknetworks.com ([212.156.37.190]) by smtp.gmail.com with ESMTPSA id g7-20020a170906198700b00a4503a78dd5sm4317475ejd.17.2024.03.06.02.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 02:13:37 -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 10:13:35 +0000 Message-Id: <20240306101335.246097-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 | 24 ++++++++++++++++++++++++ lib/hash/version.map | 6 ++++++ 3 files changed, 53 insertions(+) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf94645f6..1c360fa38b 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..edfa262aca 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 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