From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 5F4E245B51;
	Wed, 16 Oct 2024 17:39:30 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 14E1C40150;
	Wed, 16 Oct 2024 17:39:30 +0200 (CEST)
Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com
 [209.85.214.173])
 by mails.dpdk.org (Postfix) with ESMTP id D3C6E40150
 for <dev@dpdk.org>; Wed, 16 Oct 2024 17:39:28 +0200 (CEST)
Received: by mail-pl1-f173.google.com with SMTP id
 d9443c01a7336-20c7ee8fe6bso49839395ad.2
 for <dev@dpdk.org>; Wed, 16 Oct 2024 08:39:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729093168;
 x=1729697968; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:from:to:cc:subject:date
 :message-id:reply-to;
 bh=MeyMSRRb3ae+1bTR/jgV6R9iH4dAV13EFqRFAtk3Y0w=;
 b=DtA1NmuZ66RHLwI0hTCVONbBONDzV+53VCl9WbBHOI83VSkW2K7SXu8P4rR4fVwd8M
 7kyCfZh6olOi+R2OJsA3NcoyBJFqAhgN5NNi0EtIJphqXky9kiGh5kWuN+nwpNerX9mP
 BpcbpTPxArMCwWSeBg6mROB9xJvIMJ6CdxYITkXJ15XSPva47xPcEvW8MFRMhUzpODj0
 aLItT4O0gMt/W0AN1EWgmJcX87Je2VpzDSOCcVhZXXHzC7CBmDLsANQcSRxWMHHae0K1
 L6BZCwKzDx8VGDzzVniKQqYfLtmU9vachFdIsFjfWSoevF/RvaAZWmB9UCM18LKn7m7j
 UKbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1729093168; x=1729697968;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=MeyMSRRb3ae+1bTR/jgV6R9iH4dAV13EFqRFAtk3Y0w=;
 b=f2Ngfl0M8CtX27HtvUMrgcCbiEEamb1bvlCpYjwkxngsThYVTrf3D8Tinfvfil/JTb
 6rLiz7qx8Jp+Pr6mE3CsT25N06/jIliZp8jOfQCixgiPyB1pCzPFOt0aSNTXFTqFPNhB
 NPztNDWvDy49L0TG1VNFvvCxu+OzmQtr1XX6G9H92G/KOYGrLTxL7YFRXSsbZhqSpfe+
 oREfscL9kvIZ3e8LDPq3juWmsOpxPaMvvqJjihmJ9n68BXZdbVbHpBSMahuJP1lMbh6v
 atkF5qYdymX1cFu+lsenHKXSH3DYoFwu8Ohh1kgmkWV8FzlnTWb9mU/pFmbadflepjcA
 Meug==
X-Forwarded-Encrypted: i=1;
 AJvYcCUZ+WnymqGEPmoMI7IGlfWFPBZe8sKvCORshdCX9BFxhYoWU2qA4MH5oFX22C91pnkcJEI=@dpdk.org
X-Gm-Message-State: AOJu0YxawyhtWg6znEvK2BYvbMPTUUbE7ZkDAuNnJ9wV1e3HjfgJ6j8K
 jgZtGd+4NvHRdN1Czy3nzaHiVJHT7Hq1A4Vyd7uiF6IGf2orStdqlY7kqMqTq+s=
X-Google-Smtp-Source: AGHT+IGr3NhPqZXR3FDWW/ZztByhgyZoj+08yNtzvenySZ/CbJ9InVEb8UwtP9srF52HMoJkNb6M+g==
X-Received: by 2002:a17:90a:f40d:b0:2e2:da6e:8807 with SMTP id
 98e67ed59e1d1-2e3ab8bc80fmr4823751a91.26.1729093167908; 
 Wed, 16 Oct 2024 08:39:27 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-2e392d25683sm4425702a91.0.2024.10.16.08.39.27
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 16 Oct 2024 08:39:27 -0700 (PDT)
Date: Wed, 16 Oct 2024 08:39:25 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: David Marchand <david.marchand@redhat.com>
Cc: Mattias =?UTF-8?B?UsO2bm5ibG9t?= <mattias.ronnblom@ericsson.com>,
 dev@dpdk.org, Mattias =?UTF-8?B?UsO2bm5ibG9t?= <hofors@lysator.liu.se>
Subject: Re: [PATCH 2/2] devtools: forbid the use of ffs compiler builtins
Message-ID: <20241016083925.719a6b0c@hermes.local>
In-Reply-To: <CAJFAV8wfUHV5DWm4XZyOE2JxymNqLYqBBu4otVMzhBLFxqwhWg@mail.gmail.com>
References: <20241016135411.827850-1-mattias.ronnblom@ericsson.com>
 <20241016135411.827850-2-mattias.ronnblom@ericsson.com>
 <20241016080424.3f614ac2@hermes.local>
 <CAJFAV8wfUHV5DWm4XZyOE2JxymNqLYqBBu4otVMzhBLFxqwhWg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Wed, 16 Oct 2024 17:32:27 +0200
David Marchand <david.marchand@redhat.com> wrote:

> On Wed, Oct 16, 2024 at 5:04=E2=80=AFPM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > On Wed, 16 Oct 2024 15:54:11 +0200
> > Mattias R=C3=B6nnblom <mattias.ronnblom@ericsson.com> wrote:
> > =20
> > > 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=C3=B6nnblom <mattias.ronnblom@ericsson.com>
> > > Suggested-by: David Marchand <david.marchand@redhat.com> =20
> >
> > Shouldn't this apply to all _builtin_ functions.
> >
> > There are a lot of drivers still doing this. =20
>=20
> - 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.
>=20
>=20
> - 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.
>=20
> Are you ok if we go with this patch as is, in a first step?
>=20
>=20

Examples of direct use of builtin
	app/dumpcap/main.c:     log2 =3D sizeof(size) * 8 - __builtin_clzl(size - =
1);
	app/test-dma-perf/benchmark.c:                  __builtin_ia32_clflush(dat=
a + 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 =3D __builtin_ffsl(~word);
	app/test/test_memcpy_perf.c:    if (__builtin_constant_p(n)) =20

	drivers/net/bonding/rte_eth_bond_pmd.c:         if (__builtin_popcountl(li=
nk_speeds) !=3D 2) {


Think that direct use of __builitin_expect should be flagged.
And the lots of __builtin_in mlx5 should also be flagged.

	=09

	=20