xfrm: policy: Use sequence counters with associated lock
authorAhmed S. Darwish <a.darwish@linutronix.de>
Mon, 20 Jul 2020 15:55:22 +0000 (17:55 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Wed, 29 Jul 2020 14:14:27 +0000 (16:14 +0200)
commit77cc278f7b202e4f16f8596837219d02cb090b96
tree04cd7ad6f53051945c9fee9a05c18df7c1a02422
parentb901892b51317b321c7bc96e2ccd2f522d1380ee
xfrm: policy: Use sequence counters with associated lock

A sequence counter write side critical section must be protected by some
form of locking to serialize writers. If the serialization primitive is
not disabling preemption implicitly, preemption has to be explicitly
disabled before entering the sequence counter write side critical
section.

A plain seqcount_t does not contain the information of which lock must
be held when entering a write side critical section.

Use the new seqcount_spinlock_t and seqcount_mutex_t data types instead,
which allow to associate a lock with the sequence counter. This enables
lockdep to verify that the lock used for writer serialization is held
when the write side critical section is entered.

If lockdep is disabled this lock association is compiled out and has
neither storage size nor runtime overhead.

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200720155530.1173732-17-a.darwish@linutronix.de
net/xfrm/xfrm_policy.c