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 494E243AA0; Wed, 7 Feb 2024 16:33:48 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2DA5402A9; Wed, 7 Feb 2024 16:33:47 +0100 (CET) Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by mails.dpdk.org (Postfix) with ESMTP id B21C440295 for ; Wed, 7 Feb 2024 16:33:46 +0100 (CET) Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-33929364bdaso523386f8f.2 for ; Wed, 07 Feb 2024 07:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707320026; x=1707924826; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OzYi8SFv+Y94QV8kbj5umgrZgmdYndYLW3AhItw/zxE=; b=Wyn73YeYFgIrYWIjQWectAaIV6YHPWYphucASpoWwucnc3cCyE8g2C3+yA40W1iX5s BSuz8LeQ38PdANy5DOJ7t+xUMJInqTqMfIXa0yFEZtVXF68crEqLldqun49wnGCfuOOO 6Oh/6x4i8VJIvjUsmW/oSPqocGUjZOVmGY/nNQAVRpHgziCJAA3L7f0Vo1LUNhSfHaJC QZ2a3EhJM7PB1VtqkPQa0pLDP4D1wddL6+4SawRj9V6aPSl+2q7+LtH/bnFrzPUYgMh3 2LebyJHZXitf/usMGuawEHCZx+l+2A88Pv+g6u4c1yIRJWS132j7r90A+5zbDxmlCpB0 FHYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707320026; x=1707924826; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OzYi8SFv+Y94QV8kbj5umgrZgmdYndYLW3AhItw/zxE=; b=gbKR0MJaP88Pqq46M5+OlkS6GCw0M/+gHT4shLZddg2e8m5tysDUF+xi1cHP49oAy4 OajVAtV+iIvFiXtzqxOU1m7CkPPOSA6hCZ3Zf2ROhKOPFqfBqMn2bllZkWZHUbTIRnZJ L+Sw84XQxI9/+YVbZYz7mwioblxzMAzyKZE6h9RWMay6mMrd/Sa9qnj5p0S+34guCCXU dYeNA/kgVqYAG0oddjmZTqovgI8EqQTPDDtABL6Rwek46vbxyCkHptqDrs1m7cwMwuvf S0WwVtLfa40Vewf1Xj0zyomCG8iUOZGb8iILaNzL9HlWkGqJlXbrRsU46MvWNfXIqj2w vjoA== X-Gm-Message-State: AOJu0Yxh75ql21wHG8i/nQ8HynL7JvKr1GKhr0KSS/OOQgr0KDA3BRL6 SpTFi7NYHY5VluGaPQLCzALPYHvdHde69WktnC5xfWuhFOHi6U6q4MLxbVNDocU= X-Google-Smtp-Source: AGHT+IGh5CQJfe3x+SS7FVEGQNu0JSq2AjIGAhAMS332ImRx/1Q+dlm/Wl7Wyt0OIqEIztHc9nhUOg== X-Received: by 2002:a5d:558e:0:b0:33a:fe3b:b2ae with SMTP id i14-20020a5d558e000000b0033afe3bb2aemr3457567wrv.66.1707320025183; Wed, 07 Feb 2024 07:33:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW+HawI+dsRCL8Cqt6dFZJOhkAcdAl1K6hVuBrM8jk1lVNXJNnPpYp+J3TqascmKpOPnL+a1p77YF4ssEQIrCx/5c7YrZjzdr5iFcBIhGcO5Rtyt3KQZClY7Zt07egmCSHH2yQQ63Tdl5GT+f/F9cf2BOcbOc9cLJJK9+ylDNPQPqBZEBO2yVGDEMkY+DCG3bHewZ0ppSNg/pqXJknQsk9eBKHESu/+J445CujRnh6CyeJOwZoA28c= Received: from dcu.otaknetworks.com ([212.156.37.190]) by smtp.gmail.com with ESMTPSA id d15-20020a5d644f000000b0033b44a349e1sm1749987wrw.38.2024.02.07.07.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 07:33:44 -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?= , Honnappa Nagarahalli , Yipeng Wang , Sameh Gobriel , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH] lib/hash,lib/rcu: feature hidden key count in hash Date: Wed, 7 Feb 2024 15:33:40 +0000 Message-Id: <20240207153340.34146-1-aomeryamac@gmail.com> X-Mailer: git-send-email 2.34.1 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 introduce a new API to get the hidden key count in the hash table if the rcu qsbr is enabled. When using rte_hash_count with rcu qsbr enabled, it will return the number of elements that are not in the free queue. Unless rte_rcu_qsbr_dq_reclaim is called, the number of elements in the defer queue will not be counted and freed. Therefore I added a new API to get the number of hidden (defer queue) elements in the hash table. Then the user can calculate the total number of elements that are available in the hash table. Signed-off-by: Abdullah Ömer Yamaç --- Cc: Honnappa Nagarahalli Cc: Yipeng Wang Cc: Sameh Gobriel Cc: Bruce Richardson Cc: Vladimir Medvedkin --- lib/hash/rte_cuckoo_hash.c | 9 +++++++++ lib/hash/rte_hash.h | 13 +++++++++++++ lib/hash/version.map | 1 + lib/rcu/rte_rcu_qsbr.c | 8 ++++++++ lib/rcu/rte_rcu_qsbr.h | 11 +++++++++++ lib/rcu/version.map | 1 + 6 files changed, 43 insertions(+) diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c index 70456754c4..3553f3efc7 100644 --- a/lib/hash/rte_cuckoo_hash.c +++ b/lib/hash/rte_cuckoo_hash.c @@ -555,6 +555,15 @@ rte_hash_max_key_id(const struct rte_hash *h) return h->entries; } +int32_t +rte_hash_dq_count(const struct rte_hash *h) +{ + if (h->dq == NULL) + return -EINVAL; + + return rte_rcu_qsbr_dq_count(h->dq); +} + int32_t rte_hash_count(const struct rte_hash *h) { diff --git a/lib/hash/rte_hash.h b/lib/hash/rte_hash.h index 7ecc021111..8ea97e297d 100644 --- a/lib/hash/rte_hash.h +++ b/lib/hash/rte_hash.h @@ -193,6 +193,19 @@ rte_hash_free(struct rte_hash *h); void rte_hash_reset(struct rte_hash *h); + +/** + * Return the number of records in the defer queue of the hash table + * if RCU is enabled. + * @param h + * Hash table to query from + * @return + * - -EINVAL if parameters are invalid + * - A value indicating how many records were inserted in the table. + */ +int32_t +rte_hash_dq_count(const struct rte_hash *h); + /** * Return the number of keys in the hash table * @param h diff --git a/lib/hash/version.map b/lib/hash/version.map index 6b2afebf6b..7f7b158cf1 100644 --- a/lib/hash/version.map +++ b/lib/hash/version.map @@ -9,6 +9,7 @@ DPDK_24 { rte_hash_add_key_with_hash; rte_hash_add_key_with_hash_data; rte_hash_count; + rte_hash_dq_count; rte_hash_crc32_alg; rte_hash_crc_set_alg; rte_hash_create; diff --git a/lib/rcu/rte_rcu_qsbr.c b/lib/rcu/rte_rcu_qsbr.c index bd0b83be0c..89f8da4c4c 100644 --- a/lib/rcu/rte_rcu_qsbr.c +++ b/lib/rcu/rte_rcu_qsbr.c @@ -450,6 +450,14 @@ rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n, return 0; } +/** + * Return the number of entries in a defer queue. + */ +unsigned int rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq) +{ + return rte_ring_count(dq->r); +} + /* Delete a defer queue. */ int rte_rcu_qsbr_dq_delete(struct rte_rcu_qsbr_dq *dq) diff --git a/lib/rcu/rte_rcu_qsbr.h b/lib/rcu/rte_rcu_qsbr.h index 23c9f89805..ed5a590edd 100644 --- a/lib/rcu/rte_rcu_qsbr.h +++ b/lib/rcu/rte_rcu_qsbr.h @@ -794,6 +794,17 @@ int rte_rcu_qsbr_dq_reclaim(struct rte_rcu_qsbr_dq *dq, unsigned int n, unsigned int *freed, unsigned int *pending, unsigned int *available); +/** + * Return the number of entries in a defer queue. + * + * @param dq + * Defer queue. + * @return + * The number of entries in the defer queue. + */ +unsigned int +rte_rcu_qsbr_dq_count(struct rte_rcu_qsbr_dq *dq); + /** * Delete a defer queue. * diff --git a/lib/rcu/version.map b/lib/rcu/version.map index 982ffd59d9..f410ab41e7 100644 --- a/lib/rcu/version.map +++ b/lib/rcu/version.map @@ -5,6 +5,7 @@ DPDK_24 { rte_rcu_qsbr_dq_create; rte_rcu_qsbr_dq_delete; rte_rcu_qsbr_dq_enqueue; + rte_rcu_qsbr_dq_count; rte_rcu_qsbr_dq_reclaim; rte_rcu_qsbr_dump; rte_rcu_qsbr_get_memsize; -- 2.34.1