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)
Mar 7 2024, 6:43 PM
Unknown Object (File)
Feb 27 2024, 4:54 PM
Unknown Object (File)
Jan 30 2024, 9:07 PM
Unknown Object (File)
Jan 29 2024, 1:24 PM
Unknown Object (File)
Dec 22 2023, 11:50 PM
Unknown Object (File)
Dec 21 2023, 3:08 PM
Unknown Object (File)
Dec 12 2023, 6:59 AM
Unknown Object (File)
Oct 30 2023, 7:32 AM
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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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

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
428

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.

2585

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
2585

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).