Page MenuHomeFreeBSD

opencrypto: Fix assignment of crypto completions to worker threads
ClosedPublic

Authored by markj on Jan 14 2021, 4:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 1:51 PM
Unknown Object (File)
Jan 29 2024, 6:09 AM
Unknown Object (File)
Dec 20 2023, 4:23 AM
Unknown Object (File)
Dec 8 2023, 8:40 PM
Unknown Object (File)
Oct 29 2023, 9:42 PM
Unknown Object (File)
Oct 29 2023, 1:39 PM
Unknown Object (File)
Oct 5 2023, 11:57 PM
Unknown Object (File)
Sep 29 2023, 12:08 AM

Details

Summary

Since r336439 we simply take the session pointer value mod the number of
worker threads (ncpu by default). This does not work very well.
Instead, maintain an incrementing counter with a unique value per
session, and use that to distribute work to completion threads.

We could alternately hash the pointer in some way, but a counter gives
consistent distributions across reboots. It also plays more nicely with
GELI, which creates ncpu sessions per GEOM. It would be preferable to
dynamically re-assign sessions to worker threads periodically based on
load, but we're not there yet. In the meantime, using more than one
worker helps IPSec throughput.

Diff Detail

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

Event Timeline

👍

sys/opencrypto/crypto.c
949

Any reason not to use either a native word size or just 32-bit everywhere? The bias should be pretty minimal for even a few doubling of core counts on bigger machines.

This revision is now accepted and ready to land.Jan 14 2021, 5:37 PM
sys/opencrypto/crypto.c
949

Not really, I did it this way to be defensive in case something starts assuming the value is a unique session ID. There's no problem using atomic_fetchadd_64() in machine-independent code.

markmi_dsl-only.net added inline comments.
sys/opencrypto/crypto.c
949

32-bit powerpc and powerpcspe do not have atomic_fetchadd_64 implementations. The stable/12 ci.freebsd.org results are "undefined reference to `atomic_fetchadd_64'" failures.