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 1999145E87; Thu, 12 Dec 2024 17:01:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA97F402EF; Thu, 12 Dec 2024 17:01:47 +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 69FC940269 for ; Thu, 12 Dec 2024 17:01:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734019305; 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: in-reply-to:in-reply-to:references:references; bh=qgAIYpXlZmS9SAoW/d3raAZrXKl/hONTcm6hWPa6ksg=; b=WZiI/bUgbogqGjmme88KikP5VEmv1kMHovlFgE8V7htWMB17WNvtVd39gwss8f3r/h1P+G pzJjMpbqXffGMacE6UVU6SLDreigNCeCv7qC1yN0QkgvWg9HiN1YcXz32fJp0S8q6HgyHc 1cfn8Z4ovs/owU0gIrTMB7qtxYzpzL4= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-R4_P-wM7ONu9-w2ftu27yg-1; Thu, 12 Dec 2024 11:01:43 -0500 X-MC-Unique: R4_P-wM7ONu9-w2ftu27yg-1 X-Mimecast-MFC-AGG-ID: R4_P-wM7ONu9-w2ftu27yg Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0B1EC1955BFA; Thu, 12 Dec 2024 16:01:42 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.129]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 941D81953951; Thu, 12 Dec 2024 16:01:40 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v2 1/3] eal: add enhanced lock annotations Date: Thu, 12 Dec 2024 17:00:46 +0100 Message-ID: <20241212160049.1258449-2-david.marchand@redhat.com> In-Reply-To: <20241212160049.1258449-1-david.marchand@redhat.com> References: <20241202125316.3732529-1-david.marchand@redhat.com> <20241212160049.1258449-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1ZO-vCbuTBAIH7RaNkCQBqAhWfN-9OgDs-XCj1b_gds_1734019302 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 Clang 3.6+ offers enhanced lock annotations when it comes to shared vs exclusive capability/lock release. Introduce macros for those new function attributes. Signed-off-by: David Marchand --- Changes since RFC: - fixed build with clang < 11, --- doc/api/doxy-api.conf.in | 12 ++++++ lib/eal/include/rte_lock_annotations.h | 53 ++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in index d23352d300..ac490e7631 100644 --- a/doc/api/doxy-api.conf.in +++ b/doc/api/doxy-api.conf.in @@ -103,6 +103,18 @@ PREDEFINED = __DOXYGEN__ \ __rte_shared_trylock_function(x)= \ __rte_assert_shared_lock(x)= \ __rte_unlock_function(x)= \ + __rte_capability(x)= \ + __rte_requires_capability(x)= \ + __rte_acquire_capability(x)= \ + __rte_try_acquire_capability(x)= \ + __rte_release_capability(x)= \ + __rte_assert_capability(x)= \ + __rte_requires_shared_capability(x)= \ + __rte_acquire_shared_capability(x)= \ + __rte_try_acquire_shared_capability(x)= \ + __rte_release_shared_capability(x)= \ + __rte_assert_shared_capability(x)= \ + __rte_exclude_capability(x)= \ __attribute__(x)= OPTIMIZE_OUTPUT_FOR_C = YES diff --git a/lib/eal/include/rte_lock_annotations.h b/lib/eal/include/rte_lock_annotations.h index 2456a69352..102eda9c51 100644 --- a/lib/eal/include/rte_lock_annotations.h +++ b/lib/eal/include/rte_lock_annotations.h @@ -43,6 +43,41 @@ extern "C" { #define __rte_locks_excluded(...) \ __attribute__((locks_excluded(__VA_ARGS__))) + +#if defined(__clang__) && __clang_major__ >= 11 +#define __rte_capability(...) \ + __attribute__((capability(__VA_ARGS__))) +#else +#define __rte_capability(...) \ + __attribute__((capability("mutex"))) +#endif + +#define __rte_requires_capability(...) \ + __attribute__((requires_capability(__VA_ARGS__))) +#define __rte_acquire_capability(...) \ + __attribute__((acquire_capability(__VA_ARGS__))) +#define __rte_try_acquire_capability(ret, ...) \ + __attribute__((try_acquire_capability(ret, __VA_ARGS__))) +#define __rte_release_capability(...) \ + __attribute__((release_capability(__VA_ARGS__))) +#define __rte_assert_capability(...) \ + __attribute__((assert_capability(__VA_ARGS__))) + +#define __rte_requires_shared_capability(...) \ + __attribute__((requires_shared_capability(__VA_ARGS__))) +#define __rte_acquire_shared_capability(...) \ + __attribute__((acquire_shared_capability(__VA_ARGS__))) +#define __rte_try_acquire_shared_capability(ret, ...) \ + __attribute__((try_acquire_shared_capability(ret, __VA_ARGS__))) +#define __rte_release_shared_capability(...) \ + __attribute__((release_shared_capability(__VA_ARGS__))) +#define __rte_assert_shared_capability(...) \ + __attribute__((assert_shared_capability(__VA_ARGS__))) + +#define __rte_exclude_capability(...) \ + __attribute__((exclude_capability(__VA_ARGS__))) + + #define __rte_no_thread_safety_analysis \ __attribute__((no_thread_safety_analysis)) @@ -67,6 +102,24 @@ extern "C" { #define __rte_locks_excluded(...) + +#define __rte_capability(...) + +#define __rte_requires_capability(...) +#define __rte_acquire_capability(...) +#define __rte_try_acquire_capability(...) +#define __rte_release_capability(...) +#define __rte_assert_capability(...) + +#define __rte_requires_shared_capability(...) +#define __rte_acquire_shared_capability(...) +#define __rte_try_acquire_shared_capability(...) +#define __rte_release_shared_capability(...) +#define __rte_assert_shared_capability(...) + +#define __rte_exclude_capability(...) + + #define __rte_no_thread_safety_analysis #endif /* RTE_ANNOTATE_LOCKS */ -- 2.47.0