Asynchronous crypto only needs a worker for callers which cannot
sleep, notably sendfile I/O completion. Dispatch directly from
sleepable callers to avoid a redundant worker handoff &ctx switch.
Details
Tested with the on-board (and out of tree) QAT device in a small Arm64 board under WITNESS/INVAR and non-DEBUG kernels as well.
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
| FreeBSD/sys/kern/uipc_ktls.c | ||
|---|---|---|
| 2941 | I would move this assignment queued = 1 to after the new block, just to make it clearer where it's used. | |
| FreeBSD/sys/sys/ktls.h | ||
| 252 ↗ | (On Diff #189236) | As a rule I don't like naked bool flags as function parameters. It would be clearer to have separate functions: ktls_enqueue() always enqueues the request, while ktls_dispatch() tries to handle the request directly if possible. Of course, this requires more refactoring. If you go this route, it's easier to introduce a minor optimization for the direct dispatch case: callers of ktls_dispatch() don't need to acquire a socket ref if they're going to do direct dispatch. It turns out that the callers of ktls_enqueue(can_block=true) are exactly the ones that call soref() immediately before. So, you can have ktls_enqueue() require that the caller provide a socket reference, while ktls_dispatch() acquires a socket ref internally, but only when needed. |
| FreeBSD/sys/sys/ktls.h | ||
|---|---|---|
| 252 ↗ | (On Diff #189236) | That's probably fine too. |
Updated patch to use @glebius suggestion of THREAD_CAN_SLEEP() rather than
a sleepable flap.