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 C90E241C8A; Mon, 13 Feb 2023 17:09:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB6DE40EF1; Mon, 13 Feb 2023 17:09:36 +0100 (CET) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id B0E9D40EE4 for ; Mon, 13 Feb 2023 17:09:34 +0100 (CET) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] disable lock annotation with clang 3.4.2 Date: Mon, 13 Feb 2023 17:09:29 +0100 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87736@smartserver.smartshare.dk> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] disable lock annotation with clang 3.4.2 Thread-Index: Adk/uyqc6n+saPbpSGSdYBSIERw84wACNOZg References: <20230213144455.520669-1-david.marchand@redhat.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Bruce Richardson" , "David Marchand" Cc: , , , "Chenbo Xia" , "Maxime Coquelin" 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 > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Monday, 13 February 2023 15.55 >=20 > On Mon, Feb 13, 2023 at 03:44:55PM +0100, David Marchand wrote: > > Venerable RHEL7 clang 3.4.2 has (at least) two issues with lock > > annotations. > > > > A first one with regards to the attribute position: > > ../lib/vhost/vhost.h:518:2: error: GCC does not allow > > assert_exclusive_lock attribute in this position on a > > function definition [-Werror,-Wgcc-compat] > > __rte_assert_exclusive_lock(&vq->access_lock) > > ^ > > ../lib/eal/include/rte_lock_annotations.h:29:38: note: expanded > > from macro '__rte_assert_exclusive_lock' > > __attribute__((assert_exclusive_lock(__VA_ARGS__))) > > ^ > > > > This can be worked around by splitting and having the allocation on > the > > function declaration. > > > > But on the other hand, clang 3.4.2 does not seem to propagate those > > annotations in presence of a __builtin_expect (i.e. unlikely()), = like > > for example when calling if (unlikely(rte_spinlock_trylock() =3D=3D = 0)). > > > > Those annotations were only working with clang in any case, so > restrict > > to clang versions newer than 3.5.0. > > > > Fixes: 657a98f38940 ("eal: annotate spinlock, rwlock and seqlock") > > > > Signed-off-by: David Marchand > > --- > > drivers/meson.build | 2 +- > > lib/meson.build | 2 +- > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/meson.build b/drivers/meson.build > > index bddc4a6cc4..0618c31a69 100644 > > --- a/drivers/meson.build > > +++ b/drivers/meson.build > > @@ -168,7 +168,7 @@ foreach subpath:subdirs > > enabled_drivers +=3D name > > lib_name =3D '_'.join(['rte', class, name]) > > cflags +=3D '-DRTE_LOG_DEFAULT_LOGTYPE=3D' + > '.'.join([log_prefix, name]) > > - if annotate_locks and cc.has_argument('-Wthread-safety') > > + if annotate_locks and cc.get_id() =3D=3D 'clang' and > cc.version().version_compare('>=3D3.5.0') > > cflags +=3D '-DRTE_ANNOTATE_LOCKS' > > cflags +=3D '-Wthread-safety' > > endif >=20 > Are we likely to see any issues with this with any other compilers? > Should > we look to do a built-test in meson to determine feature support = rather > than checking clang versions explicitly? >=20 > On the plus side, checking clang version like this makes it clear when > we > can drop the conditional. I prefer this over auto-detection in meson, for the reason mentioned by = Bruce. Furthermore, different compilers may use different syntax in the code, = so it is impossible to detect generically; the auto-detection would be = per compiler anyway. Acked-by: Morten Br=F8rup