From patchwork Sat Mar 2 21:08:22 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: 137810 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 175BD43BD1; Sat, 2 Mar 2024 22:08:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 968CD4338E; Sat, 2 Mar 2024 22:08:29 +0100 (CET) Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by mails.dpdk.org (Postfix) with ESMTP id 128A84338A for ; Sat, 2 Mar 2024 22:08:28 +0100 (CET) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-412cbf58fdeso8641595e9.3 for ; Sat, 02 Mar 2024 13:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709413707; x=1710018507; 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=HmULtWOVRyCd+BfVKZxL/qzuf9VUrOedF1wVHZGIKPg=; b=aFR1mQ590VZqaV9Hk9MZ/ftfuLDZTQa1Bz6zYaiEo6AaSHxbv3uhmzuXhnxopImHqL Su1Mn7pRFCEdEwcasAQR2tdBBYwGobi5ehwNpMN968cOjVYUnUWSLsadR/4hyGz547BZ ztlUPCVHvvAwQbRIU7xnUwhfBFVrpO6KjX78X9mf7D0dNRljJ+vwRrMWMvN5X4EpUavw dFql8E2wB/e91YolpT2FSs2PUljBLf326gwNSOgfH1uB4Hr1ZSuSEZgDo52bDjPconiW OkUbN0rntrSp9027Ra+CLkAasmAKYq0zwsFLGgzl7KawEJ+ra7ECNNPMpiKKOwOUmxKF c9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709413707; x=1710018507; 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=HmULtWOVRyCd+BfVKZxL/qzuf9VUrOedF1wVHZGIKPg=; b=uZJSZB5AoFn2d9ooRMGlB3uXaZuahKvYAAv8TMDyMxjb+31PsXxxuaKymTkfZpwIbP WpL9ktL9Jkx1/v+RTypiHcdBUwTNPh58F93oVLWPTn/Trz14Ge0UEtpib9TvL6bgm7cp aU8VUnknpuZhDaR3EiUAgAcRRFAecezP4voFFCVZ4d/k0AAhPMooeVxtWAKEmgbcfkCT 3rSwiDr8EAVXBfFc/+gLUWpqWbXTbKkzJIiND05J7ACo9uiik/01xI7SIpUzmXUD814j Iv04NVvRoguCnoeiCbgUlYIuw7EULvph0JZtvWydggRqb/3Pww02gzMMJJ/WNf/rVYgE besw== X-Gm-Message-State: AOJu0YzLt+eq6higU9sthb8CPgyiO8B/GBS7OiznHyKmMFvzUqRA4L9G r+vf1LP9BJWVGXGcJqMcGVTbAy8GKvBlQRKdR8MkKap8dxOXtWok4IMMgH8u3Lk= X-Google-Smtp-Source: AGHT+IH8HJNsjtfjK9xhUs7lSEFBhjiHmvagYgN869cizDWUl3SKvZOk2ucokeYm5YThyCznlLOoUg== X-Received: by 2002:a05:600c:4746:b0:412:64a5:a21 with SMTP id w6-20020a05600c474600b0041264a50a21mr3612680wmo.40.1709413707139; Sat, 02 Mar 2024 13:08:27 -0800 (PST) Received: from dcu.otaknetworks.com ([212.156.37.190]) by smtp.gmail.com with ESMTPSA id az23-20020adfe197000000b0033d97bd5ddasm8241816wrb.85.2024.03.02.13.08.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 13:08:26 -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:08:22 +0000 Message-Id: <20240302210822.202270-1-aomeryamac@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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,10 @@ DPDK_24 { local: *; }; + +EXPERIMENTAL { + global: + + #added in 24.1 + rte_hash_rcu_qsbr_dq_reclaim; +} \ No newline at end of file