On Thu, Apr 21, 2022 at 3:48 PM Maxime Coquelin <maxime.coque...@redhat.com> wrote: > > 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.march...@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. >
Thanks for the review. We need some documentation about those annotations. I'll add this and post a non RFC series. -- David Marchand