Page MenuHomeFreeBSD

ipsec: replace SECASVAR mtx by rmlock
ClosedPublic

Authored by kp on Jul 10 2022, 11:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 17, 3:49 AM
Unknown Object (File)
Dec 18 2024, 9:29 AM
Unknown Object (File)
Dec 8 2024, 1:24 PM
Unknown Object (File)
Nov 25 2024, 11:24 AM
Unknown Object (File)
Nov 25 2024, 11:24 AM
Unknown Object (File)
Nov 24 2024, 6:50 AM
Unknown Object (File)
Nov 22 2024, 7:11 PM
Unknown Object (File)
Nov 20 2024, 3:22 PM

Details

Summary

This mutex is a significant point of contention in the ipsec code, and
can be relatively trivially replaced by a read-mostly lock.
It does require a separate lock for the replay protection, which we do
here by adding a separate mutex.

This improves throughput (without replay protection) by 10-15%.

Sponsored by: Orange Business Services

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 46348
Build 43237: arc lint + arc unit

Event Timeline

kp requested review of this revision.Jul 10 2022, 11:26 AM

This is a largely mechanical substitution, there's going to be room for further improvement, but it's a somewhat significant gain already so it's worth doing anyway.

There are some places where the current locking looks odd to me, but I've not yet been able to dig further. This change doesn't improve that, but also doesn't make it any worse.

mjg added inline comments.
sys/netipsec/xform_ah.c
966

this is an example why the patch in the current form does not work: replay count gets bumped without the lock by many cpus at the same time. all places of the sort will need to be coverted to use atomics. Specifically this one will unfortunately need to be a fcmpset loop to make sure you don't bump across the limit.

i was looking at replacing this lock myself and my general idea was to use sequence counters. it would avoid degeneration from IPIs on write locking (although I don't know how frequently that's needed) and be faster single-threaded at least on amd64. However, it may happen to be slower on arm64 as it requires 2 load fences.

Ensure that all uses of 'replay' are protected by the replay mutex.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 19 2022, 3:28 AM
This revision was automatically updated to reflect the committed changes.