From patchwork Sat Mar 2 21:27:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= X-Patchwork-Id: 137811 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 450CB43B97; Sat, 2 Mar 2024 22:27:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 372DA42DF0; Sat, 2 Mar 2024 22:27:17 +0100 (CET) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mails.dpdk.org (Postfix) with ESMTP id 02679402C8 for ; Sat, 2 Mar 2024 22:27:15 +0100 (CET) Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-412dcaf55eeso1286995e9.2 for ; Sat, 02 Mar 2024 13:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709414834; x=1710019634; 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=5RxOE8zxFOUayotfuEgVXxYmp6hEjfv7bqDjHBAgmOM=; b=VY1Bfjnz3eJTeDZrNAzHXZz0cZweCgu24Qv3Ra8iwEtWEgpIfQQtf4ZD2UBzG6mvnZ F1VKOi2YgdrC3hiGQ4nK6HUTToETgjtcxVsNh9zpV8DDMP77BtYofdv41w7g+MSX47N9 VWFVALpWnYca4sExiGLvMO0thREEj/hxPZXQF2zMKQCTEYBzr9Sx1Y+o0sF7PKy81AJ/ jMFhNnKl0MOgiwbjQBmLx2elgVy4spicwR+0NqrTk2S5FimazAf1AnZZVqNyvV7ZVmnh 1J9CsQ2JLWM2bfvSdPj3fejS3+CIHiH9/aMKhgBhqvb/YzSnZZ5Qom+SKA3FzL/Q8oda PwWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709414834; x=1710019634; 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=5RxOE8zxFOUayotfuEgVXxYmp6hEjfv7bqDjHBAgmOM=; b=qiAWKf+cB7qIu9C/hTXtBtvQGMtW2V3kFhQ5fPb5oEVf+AYZopA+JhEsPFlfrsT9Px P/rCWMNyCmme2y7phXweSbb5Pu8yvet+0KeGAtpvSoTlhd2yil74dQgkGJt/1EujXVBW Pfe5C7sDuhRnN8i0iePJHhxBXYYOdK8tgPANrxBOadvL6KeWxo0F2HNlAd7nWiPOWIQM UoO8aLh50qBOnNy6UH6LF+XiKjW+OQJNveKK3fKPMxeqpS3P1ImCeXm/t36U8KaKKIc5 Sau5mvYgPxWLSAVCfbFWpps/RySl0vM3webjhHURqdV2TaV2cz2tXW6ij0CtsWqhJt3X cOhw== X-Gm-Message-State: AOJu0YxKVlWvOTxXGNc/oStNuk+T2sNLwJW4IN0MpV5Bn4gAvfS1j/3h Hv5+/mSKgLei/YMLbD6EhqDct0ikaIGoow0w+mQNyqXpPWttrWTk3gXbOLlzTC4= X-Google-Smtp-Source: AGHT+IGbZPx500PuFYBN8hc+zYb/W6Yf4I85QdtxMGyJACAvS1soppDjuG5M8lnoFOgukPLR7S6rMQ== X-Received: by 2002:a05:600c:3b8c:b0:412:c3f7:2a22 with SMTP id n12-20020a05600c3b8c00b00412c3f72a22mr4295791wms.38.1709414834289; Sat, 02 Mar 2024 13:27:14 -0800 (PST) Received: from dcu.otaknetworks.com ([212.156.37.190]) by smtp.gmail.com with ESMTPSA id bp16-20020a5d5a90000000b0033e0567e90bsm8431803wrb.5.2024.03.02.13.27.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 13:27:13 -0800 (PST) From: =?utf-8?b?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= To: dev@dpdk.org Cc: =?utf-8?b?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= , Honnappa Nagarahalli Subject: [PATCH v2] lib/hash: feature reclaim defer queue Date: Sat, 2 Mar 2024 21:27:11 +0000 Message-Id: <20240302212711.204396-1-aomeryamac@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240302210822.202270-1-aomeryamac@gmail.com> References: <20240302210822.202270-1-aomeryamac@gmail.com> MIME-Version: 1.0 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ç Acked-by: Honnappa Nagarahalli --- lib/hash/rte_cuckoo_hash.c | 23 +++++++++++++++++++++++ lib/hash/rte_hash.h | 14 ++++++++++++++ lib/hash/version.map | 7 +++++++ 3 files changed, 44 insertions(+) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 9cf94645f6..254fa80cc5 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -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) diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h index 7ecc021111..c119477d50 100644 --- a/lib/hash/rte_hash.h +++ b/lib/hash/rte_hash.h @@ -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 diff --git a/lib/hash/version.map b/lib/hash/version.map index 6b2afebf6b..cec0e8fc67 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