From patchwork Mon Feb 13 14:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 123806 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9869241C89; Mon, 13 Feb 2023 15:45:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81AFF40A81; Mon, 13 Feb 2023 15:45:09 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 16402400D6 for ; Mon, 13 Feb 2023 15:45:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676299507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mUsOONSDwqnAiiFdiLC06mAh8MSLcGTJ4palC491fiU=; b=bBPlaYg/sV5c2hHeq6soN29c9b0FmfbK/4VzjzUSbUF+MZTy3spbNuqSpU6oErXzlhfG6d aJQNJehuohx2/wYaSa7ScWhsVIn5aw8neMVKNg8Ph7kEjiQ0DMY+tH9Ay2p2FwlYEvQh/X 5PRyH7wcFgEpXWi8nNBA9fFLoBk1e1s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-54-rYUTQXZ3PTyOual8G3jxgw-1; Mon, 13 Feb 2023 09:45:03 -0500 X-MC-Unique: rYUTQXZ3PTyOual8G3jxgw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0124100F909; Mon, 13 Feb 2023 14:45:02 +0000 (UTC) Received: from dmarchan.redhat.com (ovpn-193-253.brq.redhat.com [10.40.193.253]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB8C5140EBF4; Mon, 13 Feb 2023 14:45:00 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, rasland@nvidia.com, Chenbo Xia , =?utf-8?q?Morten_Br=C3=B8rup?= , Maxime Coquelin Subject: [PATCH] disable lock annotation with clang 3.4.2 Date: Mon, 13 Feb 2023 15:44:55 +0100 Message-Id: <20230213144455.520669-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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 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() == 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 Acked-by: Morten Brørup Tested-by: Raslan Darawsheh --- 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 += name lib_name = '_'.join(['rte', class, name]) cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=' + '.'.join([log_prefix, name]) - if annotate_locks and cc.has_argument('-Wthread-safety') + if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0') cflags += '-DRTE_ANNOTATE_LOCKS' cflags += '-Wthread-safety' endif diff --git a/lib/meson.build b/lib/meson.build index 450c061d2b..2bc0932ad5 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -203,7 +203,7 @@ foreach l:libraries cflags += '-DRTE_USE_FUNCTION_VERSIONING' endif cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=lib.' + l - if annotate_locks and cc.has_argument('-Wthread-safety') + if annotate_locks and cc.get_id() == 'clang' and cc.version().version_compare('>=3.5.0') cflags += '-DRTE_ANNOTATE_LOCKS' cflags += '-Wthread-safety' endif