From: Vitaliy Makkoveev Subject: Re: unlock tcp drop sysctl To: Alexander Bluhm Cc: OpenBSD tech Date: Thu, 9 Jan 2025 23:43:35 +0300 > On 9 Jan 2025, at 21:59, Alexander Bluhm wrote: > > On Thu, Jan 09, 2025 at 07:00:42PM +0300, Vitaliy Makkoveev wrote: >> Would you like to split tcp_sysctl() with tcp_sysctl_locked() and >> start slightly moving some paths out of sysctl lock? > > If I understand correctly, PR_MPSYSCTL prevents kernel lock, does > not serialize sysctl calls, and does not wire the memory for copyin(). > Yes, PR_MPSYSCTL exists for that purpose. > TCP sysctl does not care about kernel lock. It uses either atomic > integers, mutex protection or exclusive net lock. Calling copyin() > or copyout() without wired memory while holding the net lock is bad > due to NFS. > Memory wiring requires kernel lock, because uvm_vslock() acquires kernel lock with mutex held deep within, but the kernel lock taken before mutex acquisition hides this locking issue. I triggered this long time ago during sys_sysctl() unlocking, may be this is not actual anymore. So, yes we wire memory to prevent possible context switch during copy{in,out}(), but uvm_vslock() requires complicated locking around. > I think is easier to remove net lock sysctl per sysctl and then > switch the whole tcp_sysctl() instead of introducing tcp_sysctl_locked(). > > bluhm