Page MenuHomeFreeBSD

ktls: Defer creation of threads and zones until first use.
ClosedPublic

Authored by jhb on Oct 13 2021, 7:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 12:17 PM
Unknown Object (File)
Nov 22 2024, 10:11 PM
Unknown Object (File)
Nov 12 2024, 7:12 AM
Unknown Object (File)
Oct 8 2024, 7:54 PM
Unknown Object (File)
Oct 4 2024, 11:59 PM
Unknown Object (File)
Oct 2 2024, 4:30 AM
Unknown Object (File)
Oct 1 2024, 11:43 PM
Unknown Object (File)
Oct 1 2024, 3:17 PM
Subscribers

Details

Summary

Run ktls_init() when the first KTLS session is created rather than
unconditionally during boot. This avoids creating unused threads and
resources on systems which do not use KTLS.

Sponsored by: Chelsio Communications

Diff Detail

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

Event Timeline

jhb requested review of this revision.Oct 13 2021, 7:43 PM
markj added inline comments.
sys/kern/uipc_ktls.c
423

I know you didn't add this, but this comment doesn't make sense to me. If there an empty domain (meaning that there is a memory domain with no CPUs), we fall back to pinning each thread to a CPU.

This revision is now accepted and ready to land.Oct 14 2021, 6:03 PM
sys/kern/uipc_ktls.c
423

I think the comment is about the code in ktls_get_cpu() where we use the value of this variable to decide if we choose a KTLS thread in a connection's NUMA domain vs choosing any KTLS thread.

It is also true that by moving this check earlier before starting worker threads we are now consistent in how we bind kthreads in the case we failed back to 1.

2474

I wonder if this should just use sched_bind() instead? It doesn't fail. I guess 'cpuset -g -t <tid>' wouldn't show the binding, but that's the only difference I think?

sys/kern/uipc_ktls.c
2474

sched_bind() does have the advantage that it binds immediately. cpuset_setthread() does not, it just (eventually) sets TDF_NEEDSCHED, so we'd have to wait for the next context switch. But I don't see why sched_bind() is really preferable, given that we use cpuset_setthread() for binding to domains as well.

I'm not a fan of this added complexity, but it looks like it was done in a very careful way. I really appreciate it being done when creating the session, rather than upon enqueue.

I definitely tried to minimize the runtime overhead, so create session is definitely the better place than something per-op. It's also only feasible to handle failure in the create session context.

FWIW, when I boot a RISC-V GENERIC kernel in QEMU KTLS is one of the few "unused" kprocs that stands out along with the "soaiod" kprocs (which I also just fixed to be created on demand instead).