Add per-process page fault counters to sysctl and procstat
This commit introduces new sysctl OIDs and enhances procstat to display per-process minor and major page fault counts.
Kernel changes:
- Added new sysctl OIDs:
- kern.proc.pid.<PID>.minflt (minor page faults)
- kern.proc.pid.<PID>.majflt (major page faults)
- Implemented a sysctl handler in sys/kern/kern_proc.c that retrieves these values from the process's aggregated rusage statistics (p_ru.ru_minflt and p_ru.ru_majflt) after ensuring they are up-to-date by calling rufetchcalc().
- Defined KERN_PROC_PID_MINFLT (48) and KERN_PROC_PID_MAJFLT (49) in sys/sys/sysctl.h.
Userland changes (procstat):
- Added a new command-line option '-f' to procstat to display page fault counts.
- The previous '-f' option (for files) has been changed to '-F'.
- Created usr.bin/procstat/procstat_faults.c to implement the functionality for fetching and displaying these counts using the new sysctls.
- Updated usr.bin/procstat/Makefile to include the new source file.
- Updated the procstat.1 man page to document the new '-f' (faults) and revised '-F' (files) options.
This provides a convenient way for users and administrators to query the number of minor and major page faults a specific process has incurred, which can be useful for performance analysis and debugging.
Thank you for taking the time to contribute to FreeBSD! There are a few issues that need to be fixed:
- Missing Signed-off-by linesdb1ae20153713779007924c7f647b3165a6f9ac2
- Real email address is neededdb1ae20153713779007924c7f647b3165a6f9ac2
Please don't spam our repository with AI-generated slop. It serves only to waste our time and yours. After reviewing some of your PRs, I have concluded that the rest do not warrant even a cursory review. Therefore I will close them all. If you wish to contribute again in the future, you must take more care with your submissions. You must build and test them all, at least! And you need to consider what the PR does. Is it even useful? Furthermore, the copyright status of AI-generated code is currently unclear, so the project is not accepting any such submissions at this time. But AI can of course be used as an aid, such as for debugging. Finally, I encourage you to read these documents to familiarize yourself with our project and its practices.
https://docs.freebsd.org/en/books/developers-handbook/ https://docs.freebsd.org/en/articles/problem-reports/