Skip to content

locking-urgent-2020-08-10

  - Untangle the header spaghetti which causes build failures in various
    situations caused by the lockdep additions to seqcount to validate that
    the write side critical sections are non-preemptible.

  - The seqcount associated lock debug addons which were blocked by the
    above fallout.

    seqcount writers contrary to seqlock writers must be externally
    serialized, which usually happens via locking - except for strict per
    CPU seqcounts. As the lock is not part of the seqcount, lockdep cannot
    validate that the lock is held.

    This new debug mechanism adds the concept of associated locks.
    sequence count has now lock type variants and corresponding
    initializers which take a pointer to the associated lock used for
    writer serialization. If lockdep is enabled the pointer is stored and
    write_seqcount_begin() has a lockdep assertion to validate that the
    lock is held.

    Aside of the type and the initializer no other code changes are
    required at the seqcount usage sites. The rest of the seqcount API is
    unchanged and determines the type at compile time with the help of
    _Generic which is possible now that the minimal GCC version has been
    moved up.

    Adding this lockdep coverage unearthed a handful of seqcount bugs which
    have been addressed already independent of this.

    While generaly useful this comes with a Trojan Horse twist: On RT
    kernels the write side critical section can become preemtible if the
    writers are serialized by an associated lock, which leads to the well
    known reader preempts writer livelock. RT prevents this by storing the
    associated lock pointer independent of lockdep in the seqcount and
    changing the reader side to block on the lock when a reader detects
    that a writer is in the write side critical section.

 - Conversion of seqcount usage sites to associated types and initializers.
Assets 2
Loading