mbox

[RFC,0/5] vhost lock annotations

Message ID 20220328121758.26632-1-david.marchand@redhat.com (mailing list archive)
Headers

Message

David Marchand March 28, 2022, 12:17 p.m. UTC
  vhost internals involves multiple locks to protect data access by
multiple threads.

This series is a try at using clang thread safety checks [1] to catch
issues during compilation: spinlock and rwlock are wrapped into vhost types
and annotations are put all over the code.


Patch 1 is a fix from Maxime that I had to take in the series so
that the CI won't fail.

Patch 2 annotates existing manipulations of the access_lock vq lock.
It does the minimal stuff, more annotations are used/introduced later
in the series.

Patch 4 is an example of extending the work by annotating the async field.
This patch raised the issues fixed in patch 3.

Patch 5 further extends this by annotating rwlocks used in IOTLB.
This raised two suspicious call sites (in vdpa and vhost_crypto code,
see added FIXME). Because of a limitation in the check, the IOTLB lock is
changed to be always taken. I don't expect a big impact, but this needs a
confirmation.


This is still a work in progress.
Those annotations are quite heavy to maintain because the full path of
code must be annotated, but I think it would be worth using.


1: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html