Date: Fri, 6 Feb 2009 14:51:32 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: cvs-src-old@freebsd.org Subject: cvs commit: src/sys/kern kern_linker.c kern_sysctl.c vfs_init.c src/sys/sys sysctl.h Message-ID: <200902061452.n16EqDXn063919@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
jhb 2009-02-06 14:51:32 UTC FreeBSD src repository Modified files: sys/kern kern_linker.c kern_sysctl.c vfs_init.c sys/sys sysctl.h Log: SVN rev 188232 on 2009-02-06 14:51:32Z by jhb Expand the scope of the sysctllock sx lock to protect the sysctl tree itself. Back in 1.1 of kern_sysctl.c the sysctl() routine wired the "old" userland buffer for most sysctls (everything except kern.vnode.*). I think to prevent issues with wiring too much memory it used a 'memlock' to serialize all sysctl(2) invocations, meaning that only one user buffer could be wired at a time. In 5.0 the 'memlock' was converted to an sx lock and renamed to 'sysctl lock'. However, it still only served the purpose of serializing sysctls to avoid wiring too much memory and didn't actually protect the sysctl tree as its name suggested. These changes expand the lock to actually protect the tree. Later on in 5.0, sysctl was changed to not wire buffers for requests by default (sysctl_handle_opaque() will still wire buffers larger than a single page, however). As a result, user buffers are no longer wired as often. However, many sysctl handlers still wire user buffers, so it is still desirable to serialize userland sysctl requests. Kernel sysctl requests are allowed to run in parallel, however. - Expose sysctl_lock()/sysctl_unlock() routines to exclusively lock the sysctl tree for a few places outside of kern_sysctl.c that manipulate the sysctl tree directly including the kernel linker and vfs_register(). - sysctl_register() and sysctl_unregister() require the caller to lock the sysctl lock using sysctl_lock() and sysctl_unlock(). The rest of the public sysctl API manage the locking internally. - Add a locked variant of sysctl_remove_oid() for internal use so that external uses of the API do not need to be aware of locking requirements. - The kernel linker no longer needs Giant when manipulating the sysctl tree. - Add a missing break to the loop in vfs_register() so that we stop looking at the sysctl MIB once we have changed it. MFC after: 1 month Revision Changes Path 1.165 +4 -4 src/sys/kern/kern_linker.c 1.188 +103 -21 src/sys/kern/kern_sysctl.c 1.86 +3 -0 src/sys/kern/vfs_init.c 1.168 +2 -0 src/sys/sys/sysctl.h
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902061452.n16EqDXn063919>