From patchwork Wed Mar 6 08:59:48 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: 138009 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 706A443C56; Wed, 6 Mar 2024 09:59:54 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5973640275; Wed, 6 Mar 2024 09:59:54 +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 F270C40156 for ; Wed, 6 Mar 2024 09:59:52 +0100 (CET) Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a45b6fcd5e8so61513066b.1 for ; Wed, 06 Mar 2024 00:59:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709715592; x=1710320392; 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=u+xQ76eKztir5mSRjFQW8dRoWkJnp+Uwr0tk3d0e9QU=; b=dCDdwMvSrHz11HvOZiJm/ZYS7M/4eVAofUmQiByxhaJ0pLL2jvgnhRUsoqSyW5vhJf wFI6wXELfjp8dgNZw4l1mXyy4sVNI0b89ixX2IBE7o0xP42g1ZiYMiGlOmczBmJ2hD/H sKYFAANURT8dQwggb8ajtjsK6CdjfcKZ01UoXY6I9GvwjFsMYbtbAZMOc3tGHmleuVHp JA8Y8IszyJ7WcpBBm1ySw4hszMR24QGctp0Ci+X1Qopg1GkVaweUE5RJY2e/KfTCvjsF ZbObDx5cq/d9q5bWOg4777xbdOGVXHJKIQ+eLW7XdGQVUe4Knbp/2/IRAQjBmBJvNnE3 3Iig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709715592; x=1710320392; 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=u+xQ76eKztir5mSRjFQW8dRoWkJnp+Uwr0tk3d0e9QU=; b=LnjZYjPaRAc4efFyaanhQO5iclgo2Keg+91TKrXQVW75qOdhFC22HBq1WgfWPmAiBu RSTwP31oB78N7naFo8b3uqW1vFVVKmhL0t9+hRFfHHLXrD0YhulU6pHlOD2677MmSWmH AMoVlU2Pep2zNsTknskjeqb6QP3ZjVxNzyfKVjhXleZiSz3LhgJYJ9vvIJqNVAbAcmcJ N57iBTC6H1Lp1/RkNihOcrc7kQoHyIKpu6Fd1e6RoTGkcIi2zEpE5qknNoDys62XfDoF jvC1x0mdFEKJ/ZOG9Kem2p5GIwW/vd0kUc0pD9YKRqFndInBFziWk8sdoSu0Krp2hbnb glZQ== X-Gm-Message-State: AOJu0Yz8Q82ShHFc06b9VM6d5RLth9r4UvG6UJqhiGel74zchiDyBdGt BrCnZYOThbTUaGzH3nTBpGTX0cvuKXfVQUsIVO+G2BaGDRSDPCBVfr4Jk9QfAQc= X-Google-Smtp-Source: AGHT+IGzIa1lzYGUNNmHtolUGeImWh9O3/vot2iaqpCEaRJ2fnjymyB4WjAY/ld2H2BOZD5rn6DxqQ== X-Received: by 2002:a17:906:cd03:b0:a3d:ce2c:b06a with SMTP id oz3-20020a170906cd0300b00a3dce2cb06amr8883367ejb.22.1709715591936; Wed, 06 Mar 2024 00:59:51 -0800 (PST) Received: from dcu.otaknetworks.com ([212.156.37.190]) by smtp.gmail.com with ESMTPSA id l18-20020a1709060e1200b00a459094cf61sm2037379eji.115.2024.03.06.00.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 00:59:51 -0800 (PST) From: =?utf-8?b?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= To: dev@dpdk.org Cc: =?utf-8?b?QWJkdWxsYWggw5ZtZXIgWWFtYcOn?= Subject: [PATCH v3] lib/hash: add defer queue reclaim API Date: Wed, 6 Mar 2024 08:59:48 +0000 Message-Id: <20240306085948.185299-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 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 @@ -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