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 09EE745522; Fri, 28 Jun 2024 12:05:26 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6A84410D3; Fri, 28 Jun 2024 12:05:25 +0200 (CEST) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) by mails.dpdk.org (Postfix) with ESMTP id 714AC4029E for ; Fri, 28 Jun 2024 12:05:24 +0200 (CEST) Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6b553b1a159so1959456d6.0 for ; Fri, 28 Jun 2024 03:05:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1719569123; x=1720173923; darn=dpdk.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=oh28CIxgWeZS5UK32EGQHax1fGLTpPeAXXStIp8xoeQ=; b=XAcsy/WXNbsa2kc9BsSeKanLUe4fp3guXpGPP2ftoU6P2FZ8COTv97wsKTawi3JPQh 6lN4GInVBnl8zV7/7Y6FGHD29l/mNg2Zz8IOgY62SECVAMKKvqXoLuIS4SJzSN6wTRID sUtwPmajjucxTXg7VmLeVNTfu67RCxnSvNyAkgpPaheRomKz2A9KpFRuzLTtfT6r2d4o z/0vTKX3cDhjeSzVumV7zfooaHZOQ6U7xjeCeoxzx4StTkiZNtePspeNl1u7EqZKGjzb qFE4VIzERZxuU4foO8yIefBi5wOJBZ2hRRo7FGrpL42rG9Bcvt3in7A1NJ3e9WD3b7NE +63g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719569123; x=1720173923; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oh28CIxgWeZS5UK32EGQHax1fGLTpPeAXXStIp8xoeQ=; b=Nzj1K8UD+8Hb8ZEIuLMfXUb1MgbyPKZ9QW4yKzkGLY8hFsxMlpQgdIbew+TgLHP9+Q zhI7y3UDprbodEh9ifvZIN2L32MVeWfGM29w6vdNQj8d8ZpfyNQCha+GU4dB7BRbVKd0 EALAwb8whyPoq5y3Zf469lEOBw+voNq4sW0kd1+WljelnCUw2ztG1ZNGUK0VVEXrW+DN 7zKn1xoE5IyXPkiwyMOSf2Q157oVYBvrbblF/gOZATvKgXnwO1Cj+TtBD97WjkLYVKnq Ds5qCHYo6mU4LZEA0xq0RySv/1qwJZwhDT4sACIQmz7+l6dR0aM2zFeegHdkJO1/7ARl Mn2w== X-Forwarded-Encrypted: i=1; AJvYcCVqaf+TLJR9YT2F0YESH47hLlhS1/BAv3URkJjAT49FVro9sRZ3lLiFawxyVOOR56T67wshgKLf0t/Rurs= X-Gm-Message-State: AOJu0Yw4xLpJ8yC9G1HRfg+8m9K/qytAWa7ARMbvkmnR2VZrAHakHVng ydit2ElanbSuR+5h2PxCvJ3HP8DQc47t5c3n2v277BBaoFx7iPIwr5ncAnapUvk= X-Google-Smtp-Source: AGHT+IHsliU3oWlVYZJ8VZBbhNcbpCZ9a0Yp0hvxqzmrbm0w+dtRAf7BUyOzBK4Z4JDyrqXnkcWoHg== X-Received: by 2002:a0c:9ccd:0:b0:6b0:90d8:b698 with SMTP id 6a1803df08f44-6b540aaa89cmr169022656d6.45.1719569123611; Fri, 28 Jun 2024 03:05:23 -0700 (PDT) Received: from ste-uk-lab-gw ([93.115.195.2]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b59e563230sm6596346d6.35.2024.06.28.03.05.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jun 2024 03:05:23 -0700 (PDT) Date: Fri, 28 Jun 2024 11:05:20 +0100 From: Daniel Gregory To: Thomas Monjalon Cc: Ruifeng Wang , dev@dpdk.org, Punit Agrawal , Liang Ma , feifei.wang2@arm.com, Stephen Hemminger , david.marchand@redhat.com Subject: Re: [PATCH v2] eal/arm: replace RTE_BUILD_BUG on non-constant Message-ID: <20240628100520.GA3779302@ste-uk-lab-gw> Mail-Followup-To: Thomas Monjalon , Ruifeng Wang , dev@dpdk.org, Punit Agrawal , Liang Ma , feifei.wang2@arm.com, Stephen Hemminger , david.marchand@redhat.com References: <20240502142116.63760-1-daniel.gregory@bytedance.com> <20240503182730.31693-1-daniel.gregory@bytedance.com> <20240503175905.28c590cf@hermes.local> <6615976.zIJbB62Pao@thomas> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6615976.zIJbB62Pao@thomas> User-Agent: Mutt/1.10.1 (2018-07-13) 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 Thu, Jun 27, 2024 at 05:08:51PM +0200, Thomas Monjalon wrote: > 04/05/2024 02:59, Stephen Hemminger: > > On Fri, 3 May 2024 19:27:30 +0100 > > Daniel Gregory wrote: > > > > > The ARM implementation of rte_pause uses RTE_BUILD_BUG_ON to check > > > memorder, which is not constant. This causes compile errors when it is > > > enabled with RTE_ARM_USE_WFE. eg. > > > > > > ../lib/eal/arm/include/rte_pause_64.h: In function ‘rte_wait_until_equal_16’: > > > ../lib/eal/include/rte_common.h:530:56: error: expression in static assertion is not constant > > > 530 | #define RTE_BUILD_BUG_ON(condition) do { static_assert(!(condition), #condition); } while (0) > > > | ^~~~~~~~~~~~ > > > ../lib/eal/arm/include/rte_pause_64.h:156:9: note: in expansion of macro ‘RTE_BUILD_BUG_ON’ > > > 156 | RTE_BUILD_BUG_ON(memorder != rte_memory_order_acquire && > > > | ^~~~~~~~~~~~~~~~ > > > > > > Fix the compile errors by replacing the check with an assert, like in > > > the generic implementation (lib/eal/include/generic/rte_pause.h). > > > > No, don't hide the problem. > > > > What code is calling these. Looks like a real bug. Could be behind layers of wrappers. > > I support Stephen's opinion. > Please look for the real issue. In DPDK, I have found 26 calls of rte_wait_until_equal_16, largely split between app/test-bbdev/test_bbdev_perf.c and app/test/test_timer.c, with a couple calls in lib/eal/include/rte_pflock.h and lib/eal/include/rte_ticketlock.h as well. 16 calls of rte_wait_until_equal_32, spread amongst various test cases (test_func_reentrancy.c test_mcslock.c, test_mempool_perf.c, ...), two drivers (drivers/event/opdl/opdl_ring.c and drivers/net/thunderx/nicvf_rxrx.c), lib/eal/common/eal_common_mcfg.c, lib/eal/include/generic/rte_spinlock.h, lib/ring/rte_ring_c11_pvt.h, lib/ring/rte_ring_generic_pvt.h and lib/eal/include/rte_mcslock.h. There is a single call to rte_wait_until_equal_64 in app/test/test_pmd_perf.c They all correctly use the primitives from rte_stdatomic.h As I discussed on another chain https://lore.kernel.org/dpdk-dev/20240509110251.GA3795959@ste-uk-lab-gw/ from what I've seen, it seems that neither Clang nor GCC allow for static checks on the parameters of inline functions. For instance, the following does not compile: static inline __attribute__((always_inline)) int fn(int val) { _Static_assert(val == 0, "val nonzero"); return 0; } int main(void) { return fn(0); } ( https://godbolt.org/z/TrfWqYoGo ) With the same "expression in static assertion is not constant" error that I get when cross-compiling DPDK for ARM with WFE enabled on main: diff --git a/config/arm/meson.build b/config/arm/meson.build index a45aa9e466..661c735977 100644 --- a/config/arm/meson.build +++ b/config/arm/meson.build @@ -18,7 +18,7 @@ flags_common = [ # ['RTE_ARM64_MEMCPY_STRICT_ALIGN', false], # Enable use of ARM wait for event instruction. - # ['RTE_ARM_USE_WFE', false], + ['RTE_ARM_USE_WFE', true], ['RTE_ARCH_ARM64', true], ['RTE_CACHE_LINE_SIZE', 128]