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 0705542B22; Tue, 16 May 2023 15:41:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8C0842B8E; Tue, 16 May 2023 15:41:52 +0200 (CEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id 8CB30410EE for ; Tue, 16 May 2023 15:41:51 +0200 (CEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3062db220a3so9246547f8f.0 for ; Tue, 16 May 2023 06:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684244511; x=1686836511; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=aTptp2zGUDDguEWbf45lqXxLcUVisH2oGuLiDRTkRcc=; b=d0dApwsRn8eb3HaK9V+qpep0o67u411ghrqYTmhM34XAevGLLv73qtghXocgQfjMSb 1hD+Wyn6YrRsIw+MTBYs4LFM+h3LuKc7rHSKCuOvzc7223woa1hiqbZddAklhbRAKNlo G2EvmN3/tDvK+EYzmdo75dxoHZVrYbr+cRdo8gXx7kch9wNxsfpEOugkF1zujo2KgS5z gp37HsNqyMuZ/q9x8NhBnVWgknARwkAA188i4empFy4GYJXmeDEhxzjKcmivGSqlG/P9 pCGZHW9mt1UuER5iKJH9eQvsXqjMVS+PgbBvj57t+87fowk0Pnyijkge/UroD+9LovUm eWQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684244511; x=1686836511; 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=aTptp2zGUDDguEWbf45lqXxLcUVisH2oGuLiDRTkRcc=; b=ZnNL7FYbToZFnnu09sucaXdvNzDtDYYh/QUHSdMFlcTWK5C7KdOLa6/hVGDDtBzzhj +2qTdrEjIWA9/r2pzKpWEl+WxQONB1fVI0pt5ME5VIfzWrNVJLwB8xKuaujJBo/3zLbM bzZsYKuI+KTeu5Q4Uz3+9r3BiDrPAYQBzYNrIUOowegIKFWnDuQWyMnxzQBLm+HIsMPU RPx0mZhYtewEbnisnfKv2H3g+dR7YCFhGBYJXHq5b76iJKDMHo6HOCEvuW/bbf+s77ks Dq9hbCwOOBPOmZJrv0fFod9larNXOTSvQ0Ifd7jJFSQnGhE9WCDbytLGOZYxSQyB6HWM HgmQ== X-Gm-Message-State: AC+VfDyZxFmiZ3ROVHnPB1iuKtRtGIh8KVbdMJ6/+2hUHuSHxmrygsEB DtwojGDjPqwpSK703liS/dMAzQsVQUE= X-Google-Smtp-Source: ACHHUZ5LMz7hjRRlH64MHf16fBs3owMFABhRetq9yq/MNsNtMWQOLqb1Zydr9HmJOd+AtDoFzSL3ig== X-Received: by 2002:adf:f1c5:0:b0:2f2:4db4:1f5b with SMTP id z5-20020adff1c5000000b002f24db41f5bmr25629878wro.29.1684244510777; Tue, 16 May 2023 06:41:50 -0700 (PDT) Received: from spgw-dpdk.epc.mnc001.mcc001.3gppnetwork.org ([176.236.170.162]) by smtp.gmail.com with ESMTPSA id n12-20020a05600c294c00b003f4069417absm2367012wmd.24.2023.05.16.06.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 06:41:50 -0700 (PDT) From: Yasin CANER To: dev@dpdk.org Cc: Yasin CANER , Olivier Matz , Andrew Rybchenko Subject: [PATCH] lib/mempool : rte_mempool_avail_count, fixing return bigger than mempool size Date: Tue, 16 May 2023 13:41:46 +0000 Message-Id: <20230516134146.480047-1-yasinncaner@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 From: Yasin CANER after a while working rte_mempool_avail_count function returns bigger than mempool size that cause miscalculation rte_mempool_in_use_count. it helps to avoid miscalculation rte_mempool_in_use_count. Bugzilla ID: 1229 Signed-off-by: Yasin CANER --- lib/mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c index cf5dea2304..17ed1eb845 100644 --- a/lib/mempool/rte_mempool.c +++ b/lib/mempool/rte_mempool.c @@ -1009,8 +1009,11 @@ rte_mempool_avail_count(const struct rte_mempool *mp) count = rte_mempool_ops_get_count(mp); - if (mp->cache_size == 0) + if (mp->cache_size == 0) { + if (count > mp->size) + return mp->size; return count; + } for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) count += mp->local_cache[lcore_id].len; -- 2.25.1