dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, Tyler Retzlaff <roretzla@linux.microsoft.com>
Subject: [PATCH v2 1/3] eal: add enhanced lock annotations
Date: Thu, 12 Dec 2024 17:00:46 +0100	[thread overview]
Message-ID: <20241212160049.1258449-2-david.marchand@redhat.com> (raw)
In-Reply-To: <20241212160049.1258449-1-david.marchand@redhat.com>

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 <david.marchand@redhat.com>
---
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


  reply	other threads:[~2024-12-12 16:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02 12:53 [RFC 0/3] Improve lock annotations David Marchand
2024-12-02 12:53 ` [RFC 1/3] eal: add enhanced " David Marchand
2024-12-02 16:13   ` Stephen Hemminger
2024-12-02 12:53 ` [RFC 2/3] eal: enhance lock annotations for spinlock and seqlock David Marchand
2024-12-05  6:18   ` Mattias Rönnblom
2024-12-02 12:53 ` [RFC 3/3] eal: enhance lock annotations for rwlock David Marchand
2024-12-12 16:00 ` [PATCH v2 0/3] Improve lock annotations David Marchand
2024-12-12 16:00   ` David Marchand [this message]
2024-12-12 16:00   ` [PATCH v2 2/3] eal: enhance lock annotations for spinlock and seqlock David Marchand
2024-12-12 16:00   ` [PATCH v2 3/3] eal: enhance lock annotations for rwlock David Marchand
2024-12-13 10:47   ` [PATCH v2 0/3] Improve lock annotations David Marchand
2025-02-07 10:45   ` 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=20241212160049.1258449-2-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=roretzla@linux.microsoft.com \
    --cc=thomas@monjalon.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).