Page MenuHomeFreeBSD

sysctl_kern_proc_umask: fast path when operating on curproc
ClosedPublic

Authored by kaktus on Nov 6 2017, 1:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 12 2024, 8:02 PM
Unknown Object (File)
Nov 17 2024, 12:06 AM
Unknown Object (File)
Nov 4 2024, 6:29 PM
Unknown Object (File)
Oct 27 2024, 7:58 AM
Unknown Object (File)
Oct 27 2024, 6:40 AM
Unknown Object (File)
Oct 23 2024, 5:40 AM
Unknown Object (File)
Oct 22 2024, 11:38 AM
Unknown Object (File)
Oct 19 2024, 12:29 PM
Subscribers

Details

Summary

Make sysctl_kern_proc_umask execute fast path when requested pid in curproc->p_pid or 0, avoiding unnecessary locking. Update libc consumer to skip calling getpid().

Sponsored by: Mysterious Code Ltd.

Test Plan

rebuild and reinstall kernel and libc, run program using KERN_PROC_UMASK oid, ie. procstat -s pid, observe UMASK field.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Mind adding testing instructions?

mjg requested changes to this revision.Nov 6 2017, 5:44 PM

For consistency this should also remove SLOCK/SUNLOCK in the lookup case, otherwise LGTM.

This revision now requires changes to proceed.Nov 6 2017, 5:44 PM
In D12972#269385, @mjg wrote:

For consistency this should also remove SLOCK/SUNLOCK in the lookup case, otherwise LGTM.

In such case I'm stopping the tests (large poudriere builds) until fixed version is submitted.

Address @mjg comments and remove extra FILEDESC locks.

The updated version seems to survive large Poudriere builds and works as described in test instructions. Waiting for @mjg or @kib to approve it before committing.

This revision is now accepted and ready to land.Nov 7 2017, 12:00 PM
cem added inline comments.
sys/kern/kern_proc.c
2781–2783

What is the justification for removing this locking? Mjg comment above says "for consistency," but I'm not sure with what. Thanks!

sys/kern/kern_proc.c
2781–2783

To consistency with the new fast path and other places in kernel that read fd_cmask without acquiring the lock. fd_cmask is declared as short, hence in small enough to guarantee atomic read.

sys/kern/kern_proc.c
2781–2783

Thanks!