From: Stephen Hemminger <stephen@networkplumber.org>
To: David Marchand <david.marchand@redhat.com>
Cc: "Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
dev@dpdk.org, "Mattias Rönnblom" <hofors@lysator.liu.se>
Subject: Re: [PATCH 2/2] devtools: forbid the use of ffs compiler builtins
Date: Wed, 16 Oct 2024 08:39:25 -0700 [thread overview]
Message-ID: <20241016083925.719a6b0c@hermes.local> (raw)
In-Reply-To: <CAJFAV8wfUHV5DWm4XZyOE2JxymNqLYqBBu4otVMzhBLFxqwhWg@mail.gmail.com>
On Wed, 16 Oct 2024 17:32:27 +0200
David Marchand <david.marchand@redhat.com> wrote:
> On Wed, Oct 16, 2024 at 5:04 PM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > On Wed, 16 Oct 2024 15:54:11 +0200
> > Mattias Rönnblom <mattias.ronnblom@ericsson.com> wrote:
> >
> > > Extend checkpatches.sh to detect the use of __builtin_(ffs|ffsll).
> > >
> > > These intrinsics are not available in MSVC, and there are perfectly
> > > serviceable alternatives in <rte_bitops.h>.
> > >
> > > Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
> > > Suggested-by: David Marchand <david.marchand@redhat.com>
> >
> > Shouldn't this apply to all _builtin_ functions.
> >
> > There are a lot of drivers still doing this.
>
> - The updated check here is about use of __builtin_XXX instead of DPDK
> bit count ops.
> So when you refer to all builtin functions, there may be other
> builtins related to bit count we are missing, but at least the current
> patch is better than before.
>
>
> - On the larger topic of refusing *any* __builtin_, some use of them
> are "legit" under compiler checks.
> So the check would have to skip headers where wrappers are provided to
> the rest of DPDK.
> This seems possible, but a larger and probably more tricky change for now.
>
> Are you ok if we go with this patch as is, in a first step?
>
>
Examples of direct use of builtin
app/dumpcap/main.c: log2 = sizeof(size) * 8 - __builtin_clzl(size - 1);
app/test-dma-perf/benchmark.c: __builtin_ia32_clflush(data + offset);
drivers/bus/fslmc/qbman/include/compat.h:#define likely(x) __builtin_expect(!!(x), 1)
drivers/bus/fslmc/qbman/include/compat.h:#define unlikely(x) __builtin_expect(!!(x), 0)
drivers/common/nfp/nfp_platform.h:#define __bf_shf(x) (__builtin_ffsll(x) - 1)
drivers/crypto/ccp/ccp_dev.c: first_zero = __builtin_ffsl(~word);
app/test/test_memcpy_perf.c: if (__builtin_constant_p(n))
drivers/net/bonding/rte_eth_bond_pmd.c: if (__builtin_popcountl(link_speeds) != 2) {
Think that direct use of __builitin_expect should be flagged.
And the lots of __builtin_in mlx5 should also be flagged.
next prev parent reply other threads:[~2024-10-16 15:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 13:54 [PATCH 1/2] bitset: discontinue the use of GCC builtin Mattias Rönnblom
2024-10-16 13:54 ` [PATCH 2/2] devtools: forbid the use of ffs compiler builtins Mattias Rönnblom
2024-10-16 15:04 ` Stephen Hemminger
2024-10-16 15:32 ` David Marchand
2024-10-16 15:39 ` Stephen Hemminger [this message]
2024-10-16 20:55 ` David Marchand
2024-10-17 5:50 ` Mattias Rönnblom
2024-10-16 15:19 ` [PATCH 1/2] bitset: discontinue the use of GCC builtin David Marchand
2024-10-16 20:55 ` David Marchand
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=20241016083925.719a6b0c@hermes.local \
--to=stephen@networkplumber.org \
--cc=david.marchand@redhat.com \
--cc=dev@dpdk.org \
--cc=hofors@lysator.liu.se \
--cc=mattias.ronnblom@ericsson.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.