DPDK patches and discussions
 help / color / mirror / Atom feed
From: Daniel Gregory <daniel.gregory@bytedance.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: Ruifeng Wang <ruifeng.wang@arm.com>,
	dev@dpdk.org, Punit Agrawal <punit.agrawal@bytedance.com>,
	Liang Ma <liangma@bytedance.com>,
	feifei.wang2@arm.com,
	Stephen Hemminger <stephen@networkplumber.org>,
	david.marchand@redhat.com
Subject: Re: [PATCH v2] eal/arm: replace RTE_BUILD_BUG on non-constant
Date: Fri, 28 Jun 2024 11:05:20 +0100	[thread overview]
Message-ID: <20240628100520.GA3779302@ste-uk-lab-gw> (raw)
In-Reply-To: <6615976.zIJbB62Pao@thomas>

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 <daniel.gregory@bytedance.com> 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]

  reply	other threads:[~2024-06-28 10:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-02 14:21 [PATCH] " Daniel Gregory
2024-05-02 16:20 ` Stephen Hemminger
2024-05-02 17:44   ` Daniel Gregory
2024-05-02 18:27     ` Stephen Hemminger
2024-05-02 21:48     ` Stephen Hemminger
2024-05-03  9:46       ` Daniel Gregory
2024-05-04  0:56         ` Stephen Hemminger
2024-05-09 11:02           ` Daniel Gregory
2024-05-03 13:32 ` David Marchand
2024-05-03 14:21   ` Daniel Gregory
2024-05-03 18:27 ` [PATCH v2] " Daniel Gregory
2024-05-03 18:30   ` Daniel Gregory
2024-05-04  0:59   ` Stephen Hemminger
2024-06-27 15:08     ` Thomas Monjalon
2024-06-28 10:05       ` Daniel Gregory [this message]
2024-06-28 15:19         ` Stephen Hemminger
2024-05-06  9:30   ` Ruifeng Wang
2024-05-11 17:00   ` Wathsala Wathawana Vithanage
2024-05-04  1:02 ` [PATCH] " Stephen Hemminger
2024-05-09 11:11   ` Daniel Gregory
2024-05-09 16:47     ` Tyler Retzlaff
2024-05-11 16:48 ` Wathsala Wathawana Vithanage

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240628100520.GA3779302@ste-uk-lab-gw \
    --to=daniel.gregory@bytedance.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=feifei.wang2@arm.com \
    --cc=liangma@bytedance.com \
    --cc=punit.agrawal@bytedance.com \
    --cc=ruifeng.wang@arm.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).