created | 2025-02-05T23:41:34Z |
---|---|
begin | 2025-01-13T17:50:54Z |
end | 2025-01-13T18:10:20Z |
path | src/sys |
commits | 2 |
date | 2025-01-13T18:09:24Z | |||
---|---|---|---|---|
author | mvs | |||
files | src/sys/kern/kern_sysctl.c | log | diff | annotate |
message |
Rework the INP tables walkthrough in the KERN_FILE_BYFILE case of the sysctl_file(). I don't like how KERN_FILE_BYFILE case of the sysctl_file() delivers sockets data to the userland. It not only takes exclusive netlock around all except divert socket tables walkthrough, but also does copyout() with mutex(9) held. Sounds strange, but the context switch is avoided because userland pages are wired. The table is protected with `inpt_mtx' mutex(9), so the socket lock or netlock should be take outside. Since we have no socket pointer, we can't use solock(). We can't use the only shared netlock because this left socket unprotected against concurrent threads which rely on solock_shared(). Now it is possible to rework sysctl_file(). We can use reference counting for all socket types, and bluhm@ introduced `inp_sofree_mtx' mutex(9) to protect `inp_socket'. The INP tables have the special iterator to safely release `inpt_mtx' during table walkthrough. The FILLSO() or FILLIT2() macros can't be used unrolled, because we need to push mutexes re-locking and solock() deep within. Introduce the FILLINPTABLE() macro which is the unrolling, but with the socket related locking dances. FILLIT2() macro is not required anymore and was merged with FILLIT(). Current implementation takes the reference on `inp_socket' and releases `inpt_mtx' mutex(9). Now it's possible to fairly use shared_solock() on socket instead of netlock while performing fill_file(). The copyout() is external for fill_file() and touches nothing required to be protected so it could be made lockless. The KERN_FILE_BYFILE case became mp-safe, but the rest sysctl_file() cases still not, so the sysctl_vslock() dances left as is. ok bluhm |
date | 2025-01-13T18:10:20Z | |||
---|---|---|---|---|
author | mvs | |||
files | src/sys/kern/uipc_socket.c | log | diff | annotate |
message |
Unlock the tcp(4) case of somove(). Tested and OK bluhm@. |