DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, "Hemant Agrawal" <hemant.agrawal@nxp.com>,
	"Sachin Saxena" <sachin.saxena@nxp.com>,
	"Tyler Retzlaff" <roretzla@linux.microsoft.com>,
	"Mattias Rönnblom" <mattias.ronnblom@ericsson.com>,
	"Jerin Jacob" <jerinj@marvell.com>,
	"Kiran Kumar K" <kirankumark@marvell.com>,
	"Nithin Dabilpuram" <ndabilpuram@marvell.com>,
	"Zhirun Yan" <yanzhirun_163@163.com>,
	"Maxime Coquelin" <maxime.coquelin@redhat.com>,
	"Chenbo Xia" <chenbox@nvidia.com>
Subject: [RFC 2/3] eal: enhance lock annotations for spinlock and seqlock
Date: Mon,  2 Dec 2024 13:53:15 +0100	[thread overview]
Message-ID: <20241202125316.3732529-3-david.marchand@redhat.com> (raw)
In-Reply-To: <20241202125316.3732529-1-david.marchand@redhat.com>

Convert spinlock (and as a consequence seqlock) to the clang
capability annotations.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/bus/dpaa/base/qbman/qman.c     |  4 ++--
 drivers/net/fm10k/fm10k_ethdev.c       |  4 ++--
 lib/eal/include/generic/rte_spinlock.h | 14 +++++++-------
 lib/eal/include/rte_eal_memconfig.h    |  4 ++--
 lib/eal/include/rte_seqlock.h          |  4 ++--
 lib/graph/graph_private.h              |  4 ++--
 lib/vhost/vdpa.c                       |  2 +-
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index f92b25343a..11fabcaff5 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -45,7 +45,7 @@ static inline int fq_isset(struct qman_fq *fq, u32 mask)
 }
 
 static inline void fq_lock(struct qman_fq *fq)
-	__rte_exclusive_lock_function(&fq->fqlock)
+	__rte_acquire_capability(&fq->fqlock)
 	__rte_no_thread_safety_analysis
 {
 	if (fq_isset(fq, QMAN_FQ_FLAG_LOCKED))
@@ -53,7 +53,7 @@ static inline void fq_lock(struct qman_fq *fq)
 }
 
 static inline void fq_unlock(struct qman_fq *fq)
-	 __rte_unlock_function(&fq->fqlock)
+	__rte_release_capability(&fq->fqlock)
 	__rte_no_thread_safety_analysis
 {
 	if (fq_isset(fq, QMAN_FQ_FLAG_LOCKED))
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 7b490bea17..747042d621 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -116,7 +116,7 @@ fm10k_mbx_initlock(struct fm10k_hw *hw)
 
 static void
 fm10k_mbx_lock(struct fm10k_hw *hw)
-	__rte_exclusive_lock_function(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back))
+	__rte_acquire_capability(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back))
 {
 	while (!rte_spinlock_trylock(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back)))
 		rte_delay_us(FM10K_MBXLOCK_DELAY_US);
@@ -124,7 +124,7 @@ fm10k_mbx_lock(struct fm10k_hw *hw)
 
 static void
 fm10k_mbx_unlock(struct fm10k_hw *hw)
-	__rte_unlock_function(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back))
+	__rte_release_capability(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back))
 {
 	rte_spinlock_unlock(FM10K_DEV_PRIVATE_TO_MBXLOCK(hw->back));
 }
diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h
index c2980601b2..c907d4e45c 100644
--- a/lib/eal/include/generic/rte_spinlock.h
+++ b/lib/eal/include/generic/rte_spinlock.h
@@ -32,7 +32,7 @@ extern "C" {
 /**
  * The rte_spinlock_t type.
  */
-typedef struct __rte_lockable {
+typedef struct __rte_capability("spinlock") {
 	volatile RTE_ATOMIC(int) locked; /**< lock status 0 = unlocked, 1 = locked */
 } rte_spinlock_t;
 
@@ -61,7 +61,7 @@ rte_spinlock_init(rte_spinlock_t *sl)
  */
 static inline void
 rte_spinlock_lock(rte_spinlock_t *sl)
-	__rte_exclusive_lock_function(sl);
+	__rte_acquire_capability(sl);
 
 #ifdef RTE_FORCE_INTRINSICS
 static inline void
@@ -87,7 +87,7 @@ rte_spinlock_lock(rte_spinlock_t *sl)
  */
 static inline void
 rte_spinlock_unlock(rte_spinlock_t *sl)
-	__rte_unlock_function(sl);
+	__rte_release_capability(sl);
 
 #ifdef RTE_FORCE_INTRINSICS
 static inline void
@@ -109,7 +109,7 @@ rte_spinlock_unlock(rte_spinlock_t *sl)
 __rte_warn_unused_result
 static inline int
 rte_spinlock_trylock(rte_spinlock_t *sl)
-	__rte_exclusive_trylock_function(1, sl);
+	__rte_try_acquire_capability(true, sl);
 
 #ifdef RTE_FORCE_INTRINSICS
 static inline int
@@ -158,7 +158,7 @@ static inline int rte_tm_supported(void);
  */
 static inline void
 rte_spinlock_lock_tm(rte_spinlock_t *sl)
-	__rte_exclusive_lock_function(sl);
+	__rte_acquire_capability(sl);
 
 /**
  * Commit hardware memory transaction or release the spinlock if
@@ -169,7 +169,7 @@ rte_spinlock_lock_tm(rte_spinlock_t *sl)
  */
 static inline void
 rte_spinlock_unlock_tm(rte_spinlock_t *sl)
-	__rte_unlock_function(sl);
+	__rte_release_capability(sl);
 
 /**
  * Try to execute critical section in a hardware memory transaction,
@@ -190,7 +190,7 @@ rte_spinlock_unlock_tm(rte_spinlock_t *sl)
 __rte_warn_unused_result
 static inline int
 rte_spinlock_trylock_tm(rte_spinlock_t *sl)
-	__rte_exclusive_trylock_function(1, sl);
+	__rte_try_acquire_capability(true, sl);
 
 /**
  * The rte_spinlock_recursive_t type.
diff --git a/lib/eal/include/rte_eal_memconfig.h b/lib/eal/include/rte_eal_memconfig.h
index 0b1d0d4ff0..55d78de334 100644
--- a/lib/eal/include/rte_eal_memconfig.h
+++ b/lib/eal/include/rte_eal_memconfig.h
@@ -132,14 +132,14 @@ rte_mcfg_mempool_write_unlock(void)
  */
 void
 rte_mcfg_timer_lock(void)
-	__rte_exclusive_lock_function(rte_mcfg_timer_get_lock());
+	__rte_acquire_capability(rte_mcfg_timer_get_lock());
 
 /**
  * Unlock the internal EAL Timer Library lock for exclusive access.
  */
 void
 rte_mcfg_timer_unlock(void)
-	__rte_unlock_function(rte_mcfg_timer_get_lock());
+	__rte_release_capability(rte_mcfg_timer_get_lock());
 
 /**
  * If true, pages are put in single files (per memseg list),
diff --git a/lib/eal/include/rte_seqlock.h b/lib/eal/include/rte_seqlock.h
index e0e94900d1..670a680443 100644
--- a/lib/eal/include/rte_seqlock.h
+++ b/lib/eal/include/rte_seqlock.h
@@ -197,7 +197,7 @@ rte_seqlock_read_retry(const rte_seqlock_t *seqlock, uint32_t begin_sn)
  */
 static inline void
 rte_seqlock_write_lock(rte_seqlock_t *seqlock)
-	__rte_exclusive_lock_function(&seqlock->lock)
+	__rte_acquire_capability(&seqlock->lock)
 {
 	/* To synchronize with other writers. */
 	rte_spinlock_lock(&seqlock->lock);
@@ -219,7 +219,7 @@ rte_seqlock_write_lock(rte_seqlock_t *seqlock)
  */
 static inline void
 rte_seqlock_write_unlock(rte_seqlock_t *seqlock)
-	__rte_unlock_function(&seqlock->lock)
+	__rte_release_capability(&seqlock->lock)
 {
 	rte_seqcount_write_end(&seqlock->count);
 
diff --git a/lib/graph/graph_private.h b/lib/graph/graph_private.h
index da48d73587..813dd78b9d 100644
--- a/lib/graph/graph_private.h
+++ b/lib/graph/graph_private.h
@@ -221,7 +221,7 @@ graph_spinlock_get(void);
  * Take a lock on the graph internal spin lock.
  */
 void graph_spinlock_lock(void)
-	__rte_exclusive_lock_function(graph_spinlock_get());
+	__rte_acquire_capability(graph_spinlock_get());
 
 /**
  * @internal
@@ -229,7 +229,7 @@ void graph_spinlock_lock(void)
  * Release a lock on the graph internal spin lock.
  */
 void graph_spinlock_unlock(void)
-	__rte_unlock_function(graph_spinlock_get());
+	__rte_release_capability(graph_spinlock_get());
 
 /* Graph operations */
 /**
diff --git a/lib/vhost/vdpa.c b/lib/vhost/vdpa.c
index 8abb073675..329dd572b7 100644
--- a/lib/vhost/vdpa.c
+++ b/lib/vhost/vdpa.c
@@ -32,7 +32,7 @@ static struct vdpa_device_list * const vdpa_device_list
 
 static struct rte_vdpa_device *
 __vdpa_find_device_by_name(const char *name)
-	__rte_exclusive_locks_required(&vdpa_device_list_lock)
+	__rte_requires_capability(&vdpa_device_list_lock)
 {
 	struct rte_vdpa_device *dev, *ret = NULL;
 
-- 
2.47.0


  parent reply	other threads:[~2024-12-02 12:53 UTC|newest]

Thread overview: 10+ 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 ` David Marchand [this message]
2024-12-05  6:18   ` [RFC 2/3] eal: enhance lock annotations for spinlock and seqlock 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   ` [PATCH v2 1/3] eal: add enhanced " David Marchand
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

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=20241202125316.3732529-3-david.marchand@redhat.com \
    --to=david.marchand@redhat.com \
    --cc=chenbox@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerinj@marvell.com \
    --cc=kirankumark@marvell.com \
    --cc=mattias.ronnblom@ericsson.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=ndabilpuram@marvell.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=sachin.saxena@nxp.com \
    --cc=thomas@monjalon.net \
    --cc=yanzhirun_163@163.com \
    /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).