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 A4B75A00C2; Wed, 2 Nov 2022 08:52:49 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 42C4D40693; Wed, 2 Nov 2022 08:52:49 +0100 (CET) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id A7F6940223 for ; Wed, 2 Nov 2022 08:52:48 +0100 (CET) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 4FA6C3E19 for ; Wed, 2 Nov 2022 08:52:48 +0100 (CET) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id 4EC063DA2; Wed, 2 Nov 2022 08:52:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on hermod.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=ALL_TRUSTED, AWL, NICE_REPLY_A autolearn=disabled version=3.4.6 X-Spam-Score: -1.5 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id DF5713AC4; Wed, 2 Nov 2022 08:52:43 +0100 (CET) Message-ID: <6c37816f-4136-772a-1ff2-501eb1d3a244@lysator.liu.se> Date: Wed, 2 Nov 2022 08:52:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 2/3] mempool: include non-DPDK threads in statistics To: =?UTF-8?Q?Morten_Br=c3=b8rup?= , olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru, stephen@networkplumber.org, jerinj@marvell.com, bruce.richardson@intel.com Cc: thomas@monjalon.net, dev@dpdk.org References: <20221030115445.2115-1-mb@smartsharesystems.com> <20221031112634.18329-1-mb@smartsharesystems.com> <20221031112634.18329-2-mb@smartsharesystems.com> Content-Language: en-US From: =?UTF-8?Q?Mattias_R=c3=b6nnblom?= In-Reply-To: <20221031112634.18329-2-mb@smartsharesystems.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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 On 2022-10-31 12:26, Morten Brørup wrote: > Offset the stats array index by one, and count non-DPDK threads at index > zero. > > This patch provides two benefits: > * Non-DPDK threads are also included in the statistics. > * A conditional in the fast path is removed. Static branch prediction was > correct, so the performance improvement is negligible. > > v2: > * New. No v1 of this patch in the series. > > Suggested-by: Stephen Hemminger > Signed-off-by: Morten Brørup > --- > lib/mempool/rte_mempool.c | 2 +- > lib/mempool/rte_mempool.h | 12 ++++++------ > 2 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c > index 62d1ce764e..e6208125e0 100644 > --- a/lib/mempool/rte_mempool.c > +++ b/lib/mempool/rte_mempool.c > @@ -1272,7 +1272,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) > #ifdef RTE_LIBRTE_MEMPOOL_STATS > rte_mempool_ops_get_info(mp, &info); > memset(&sum, 0, sizeof(sum)); > - for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) { > + for (lcore_id = 0; lcore_id < RTE_MAX_LCORE + 1; lcore_id++) { > sum.put_bulk += mp->stats[lcore_id].put_bulk; > sum.put_objs += mp->stats[lcore_id].put_objs; > sum.put_common_pool_bulk += mp->stats[lcore_id].put_common_pool_bulk; > diff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h > index 9c4bf5549f..16e7e62e3c 100644 > --- a/lib/mempool/rte_mempool.h > +++ b/lib/mempool/rte_mempool.h > @@ -238,8 +238,11 @@ struct rte_mempool { > struct rte_mempool_memhdr_list mem_list; /**< List of memory chunks */ > > #ifdef RTE_LIBRTE_MEMPOOL_STATS > - /** Per-lcore statistics. */ > - struct rte_mempool_debug_stats stats[RTE_MAX_LCORE]; > + /** Per-lcore statistics. > + * > + * Offset by one, to include non-DPDK threads. > + */ > + struct rte_mempool_debug_stats stats[RTE_MAX_LCORE + 1]; > #endif > } __rte_cache_aligned; > > @@ -304,10 +307,7 @@ struct rte_mempool { > */ > #ifdef RTE_LIBRTE_MEMPOOL_STATS > #define RTE_MEMPOOL_STAT_ADD(mp, name, n) do { \ > - unsigned __lcore_id = rte_lcore_id(); \ > - if (__lcore_id < RTE_MAX_LCORE) { \ > - mp->stats[__lcore_id].name += n; \ > - } \ > + (mp)->stats[rte_lcore_id() + 1].name += n; \ This relies on LCORE_ID_ANY being UINT32_MAX, and a wrap to 0, for an unregistered non-EAL thread? Might be worth a comment, or better a rewrite with an explicit LCORE_ID_ANY comparison. You anyways need a conditional. An atomic add must be used in the unregistered EAL thread case. > } while (0) > #else > #define RTE_MEMPOOL_STAT_ADD(mp, name, n) do {} while (0)