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)
Jan 30 2024, 11:23 AM
Unknown Object (File)
Jan 23 2024, 9:25 PM
Unknown Object (File)
Jan 11 2024, 9:46 PM
Unknown Object (File)
Dec 21 2023, 5:04 AM
Unknown Object (File)
Dec 20 2023, 2:52 AM
Unknown Object (File)
Dec 3 2023, 1:09 PM
Unknown Object (File)
Nov 15 2023, 9:09 AM
Unknown Object (File)
Sep 9 2023, 6:21 AM
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!