[RFC PATCH v3 1/8] eal: annotate spinlock and rwlock

Maxime Coquelin maxime.coquelin at redhat.com
Thu Apr 21 15:48:23 CEST 2022


Hi David,

On 4/11/22 13:00, David Marchand wrote:
> clang offers some thread safety checks, statically verifying that locks
> are taken and released in the code.
> To use those checks, the full code leading to taking or releasing locks
> must be annotated with some attributes.
> 
> Wrap those attributes into our own set of macros.
> 
> rwlock and the "normal" spinlock are instrumented.
> 
> A component may enable this check by setting annotate_locks = true
> in its meson.build.
> 
> Note: those checks might be of interest out of DPDK, but it
> requires that the including application locks are annotated.
> On the other hand, applications out there might have been using
> those same checks.
> To be on the safe side, keep this instrumentation under a
> RTE_ANNOTATE_LOCKS internal build flag.
> 
> Signed-off-by: David Marchand <david.marchand at redhat.com>
> ---
> Changes since RFC v2:
> - fixed rwlock trylock,
> - instrumented _tm spinlocks,
> - aligned attribute names to clang,
> 
> ---
>   drivers/meson.build                    |  5 ++
>   lib/eal/arm/include/rte_rwlock.h       |  4 ++
>   lib/eal/arm/include/rte_spinlock.h     |  6 +++
>   lib/eal/include/generic/rte_rwlock.h   | 27 +++++++++--
>   lib/eal/include/generic/rte_spinlock.h | 40 ++++++++++-----
>   lib/eal/include/meson.build            |  1 +
>   lib/eal/include/rte_lock_annotations.h | 67 ++++++++++++++++++++++++++
>   lib/eal/ppc/include/rte_rwlock.h       |  4 ++
>   lib/eal/ppc/include/rte_spinlock.h     |  9 ++++
>   lib/eal/x86/include/rte_rwlock.h       |  4 ++
>   lib/eal/x86/include/rte_spinlock.h     |  9 ++++
>   lib/meson.build                        |  5 ++
>   12 files changed, 164 insertions(+), 17 deletions(-)
>   create mode 100644 lib/eal/include/rte_lock_annotations.h
> 


Thanks for working on this. I think this lock annotation feature is very
useful, and will help to catch bugs when libs and drivers will adopt it.

Acked-by: Maxime Coquelin <maxime.coquelin at redhat.com>

Regards,
Maxime



More information about the dev mailing list