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 A2FAE438F1; Thu, 18 Jan 2024 10:32:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 29C71402B0; Thu, 18 Jan 2024 10:32:49 +0100 (CET) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id 84119400D7 for ; Thu, 18 Jan 2024 10:32:47 +0100 (CET) Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TFyBt4r35z6K8yC; Thu, 18 Jan 2024 17:29:58 +0800 (CST) Received: from frapeml100006.china.huawei.com (unknown [7.182.85.201]) by mail.maildlp.com (Postfix) with ESMTPS id 30A611400CD; Thu, 18 Jan 2024 17:32:46 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml100006.china.huawei.com (7.182.85.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 18 Jan 2024 10:32:45 +0100 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.035; Thu, 18 Jan 2024 10:32:45 +0100 From: Konstantin Ananyev To: Stephen Hemminger , "dev@dpdk.org" CC: Dariusz Sosnowski , Viacheslav Ovsiienko , Ori Kam , Suanming Mou , Matan Azrad , Andrew Rybchenko , =?iso-8859-1?Q?Morten_Br=F8rup?= Subject: RE: [PATCH v4 5/6] mempool: avoid floating point expression in static assertion Thread-Topic: [PATCH v4 5/6] mempool: avoid floating point expression in static assertion Thread-Index: AQHaSXLIXtIxV+NMUkODaPa68aOHabDfT4Gg Date: Thu, 18 Jan 2024 09:32:45 +0000 Message-ID: References: <20231111172153.57461-1-stephen@networkplumber.org> <20240117182541.211125-1-stephen@networkplumber.org> <20240117182541.211125-6-stephen@networkplumber.org> In-Reply-To: <20240117182541.211125-6-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.206.138.42] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 > Clang does not handle casts in static_assert() expressions. > It doesn't like use of floating point to calculate threshold. > Use a different expression with same effect. >=20 > Modify comment in mlx5 so that developers don't go searching > for old value. >=20 > Signed-off-by: Stephen Hemminger > --- > drivers/net/mlx5/mlx5_rxq.c | 2 +- > lib/mempool/rte_mempool.c | 7 ++++--- > 2 files changed, 5 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c > index 1bb036afebb3..7d972b6d927c 100644 > --- a/drivers/net/mlx5/mlx5_rxq.c > +++ b/drivers/net/mlx5/mlx5_rxq.c > @@ -1444,7 +1444,7 @@ mlx5_mprq_alloc_mp(struct rte_eth_dev *dev) > /* > * rte_mempool_create_empty() has sanity check to refuse large cache > * size compared to the number of elements. > - * CACHE_FLUSHTHRESH_MULTIPLIER is defined in a C file, so using a > + * CALC_CACHE_FLUSHTHRESH() is defined in a C file, so using a > * constant number 2 instead. > */ > obj_num =3D RTE_MAX(obj_num, MLX5_MPRQ_MP_CACHE_SZ * 2); > diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c > index b7a19bea7185..12390a2c8155 100644 > --- a/lib/mempool/rte_mempool.c > +++ b/lib/mempool/rte_mempool.c > @@ -50,9 +50,10 @@ static void > mempool_event_callback_invoke(enum rte_mempool_event event, > struct rte_mempool *mp); >=20 > -#define CACHE_FLUSHTHRESH_MULTIPLIER 1.5 > -#define CALC_CACHE_FLUSHTHRESH(c) \ > - ((typeof(c))((c) * CACHE_FLUSHTHRESH_MULTIPLIER)) > +/* Note: avoid using floating point since that compiler > + * may not think that is constant. > + */ > +#define CALC_CACHE_FLUSHTHRESH(c) (((c) * 3) / 2) >=20 > #if defined(RTE_ARCH_X86) > /* Acked-by: Konstantin Ananyev > -- > 2.43.0