DPDK patches and discussions
 help / color / mirror / Atom feed
* [RFC 0/3] Improve lock annotations
@ 2024-12-02 12:53 David Marchand
  2024-12-02 12:53 ` [RFC 1/3] eal: add enhanced " David Marchand
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: David Marchand @ 2024-12-02 12:53 UTC (permalink / raw)
  To: dev; +Cc: thomas

A recent bug (see 22aa9a9c7099 ("vhost: fix deadlock in Rx async path"))
made more visible a gap in the clang thread safety annotations that
DPDK uses: no distinction is made between releasing a read lock and
releasing a write lock.

Clang 3.6 and later offers improved thread safety checks.

Marking objects as "lockable" has evolved into flagging some named
"capability". clang reports the capability name when an error is
reported (making this report a bit easier to understand).

For example, a spinlock is now flagged as:
typedef struct __rte_capability("spinlock") {
  volatile RTE_ATOMIC(int) locked;
} rte_spinlock_t;


For "exclusive" locking (spinlocks / write locks), the conversion is:
- exclusive_lock_function -> acquire_capability
- exclusive_trylock_function -> try_acquire_capability
- unlock_function -> release_capability
...

For "shared" locking (read locks):
- shared_lock_function -> acquire_shared_capability
- shared_trylock_function -> try_acquire_shared_capability
- unlock_function -> release_shared_capability
...


This RFC proposes to use those annotations (sticking to the
convention of simply prefixing the compiler attributes with __rte_).
The existing "old" annotations macros are left in place in case users
started to rely on them.

Note: DPDK requirements state that clang version must be >= 3.6
(following use of C11 standard).
No check about availability of the new attributes has been added to
this series, let's see what the CI thinks of this assumption...

Comments welcome.


-- 
David Marchand

David Marchand (3):
  eal: add enhanced lock annotations
  eal: enhance lock annotations for spinlock and seqlock
  eal: enhance lock annotations for rwlock

 doc/api/doxy-api.conf.in               |  12 ++
 drivers/bus/dpaa/base/qbman/qman.c     |   4 +-
 drivers/net/fm10k/fm10k_ethdev.c       |   4 +-
 lib/eal/common/eal_memalloc.h          |   2 +-
 lib/eal/common/eal_private.h           |   2 +-
 lib/eal/include/generic/rte_rwlock.h   |  23 ++--
 lib/eal/include/generic/rte_spinlock.h |  14 +-
 lib/eal/include/rte_eal_memconfig.h    |  28 ++--
 lib/eal/include/rte_lock_annotations.h |  48 +++++++
 lib/eal/include/rte_seqlock.h          |   4 +-
 lib/ethdev/ethdev_driver.c             |   4 +-
 lib/ethdev/ethdev_private.h            |   4 +-
 lib/ethdev/rte_ethdev.c                |   4 +-
 lib/graph/graph_private.h              |   4 +-
 lib/hash/rte_cuckoo_hash.c             |   8 +-
 lib/vhost/iotlb.h                      |   8 +-
 lib/vhost/vdpa.c                       |   2 +-
 lib/vhost/vhost.c                      |  10 +-
 lib/vhost/vhost.h                      |  24 ++--
 lib/vhost/vhost_crypto.c               |  14 +-
 lib/vhost/virtio_net.c                 | 170 ++++++++++++-------------
 lib/vhost/virtio_net_ctrl.c            |   2 +-
 22 files changed, 228 insertions(+), 167 deletions(-)

-- 
2.47.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-12-12 16:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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   ` [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

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).