Create a new syscall to avoid two calls to __sysctl: first to resolve the name, and second to actually execute the action. This call pattern is quite common so call kernel just once.
Tested with older and newer binaries on amd64 and compat32.
Differential D17282
new syscall: __sysctlbyname kaktus on Sep 22 2018, 3:43 AM. Authored by Tags None Referenced Files
Subscribers
Details Create a new syscall to avoid two calls to __sysctl: first to resolve the name, and second to actually execute the action. This call pattern is quite common so call kernel just once. Tested with older and newer binaries on amd64 and compat32.
Diff Detail
Event Timeline
Comment Actions I think the kernel part is operational well enough. With this cleaned up I think it may be fine for inclusion - after we get userspace to use the syscall we can improve internals much later. Do you still have interest in working on this? Comment Actions It would be helpful to generate this diff against HEAD. That would exclude the generated files and the freebsd32 capabilities.conf entry.
Comment Actions Kernel code has to get deduplicated. You can pass relevant sizes down and just have one variant do the trick. Drop the NAMEBUFLEN macro. You can just sizeof(buf) instead for comparison. This needs a TODO comment explaining the lookup should be done once. Apart from this I have no further comments about kernel part. One may consdier a temporary fallbackin libc in case of ENOSYS where the code redoes work the old way. Should save some headache during upgrades. To be removed in few months time. Comment Actions Split the function for one that do the actual work and teach sys___sysctlbyname and freebsd32___sysctlbyname to call it properly. Provide a compat layer in libc by ignoring the SIGSYS that can be generated by the kernel when the new libc is used with older kernel. As calling sigaction(2) twice every time is rather expensive and possibly intrusive I'd suggest to keep it around for a rather short period of time, say a few weeks and announce the change on current@ to remind folks to reboot with the new kernel before installworld. I provided an #ifndef HAVE___SYSCTLBYNAME for someone who wants to force the build without libc compat shims, but I'm not entirely happy with this solution either.
Comment Actions Thanks for doing the compat shim. I think this would have been one area where it would have been hard to recover from a make installworld before a new kernel was in place... Comment Actions Kernel part looks legit to me modulo some nits which I'm not going to bother with. If others accept the userspace part I'll commit this later. |