mirror of https://github.com/mkerrisk/man-pages
20e43cd694
[mtk: Manually applied patch, because of conflicts with other merged changes; also added an edit suggested by Jann; see the thread at https://lore.kernel.org/linux-man/20201012114940.1317510-1-jannh@google.com/] Since 34e55232e59f7b19050267a05ff1226e5cd122a5 (introduced back in v2.6.34), Linux uses per-thread RSS counters to reduce cache contention on the per-mm counters. With a 4K page size, that means that you can end up with the counters off by up to 252KiB per thread. Example: $ cat rsstest.c #include <stdlib.h> #include <err.h> #include <stdio.h> #include <signal.h> #include <unistd.h> #include <sys/mman.h> #include <sys/eventfd.h> #include <sys/prctl.h> void dump(int pid) { char cmd[1000]; sprintf(cmd, "grep '^VmRSS' /proc/%d/status;" "grep '^Rss:' /proc/%d/smaps_rollup;" "echo", pid, pid ); system(cmd); } int main(void) { eventfd_t dummy; int child_wait = eventfd(0, EFD_SEMAPHORE|EFD_CLOEXEC); int child_resume = eventfd(0, EFD_SEMAPHORE|EFD_CLOEXEC); if (child_wait == -1 || child_resume == -1) err(1, "eventfd"); pid_t child = fork(); if (child == -1) err(1, "fork"); if (child == 0) { if (prctl(PR_SET_PDEATHSIG, SIGKILL)) err(1, "PDEATHSIG"); if (getppid() == 1) exit(0); char *mapping = mmap(NULL, 80 * 0x1000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); eventfd_write(child_wait, 1); eventfd_read(child_resume, &dummy); for (int i=0; i<40; i++) mapping[0x1000 * i] = 1; eventfd_write(child_wait, 1); eventfd_read(child_resume, &dummy); for (int i=40; i<80; i++) mapping[0x1000 * i] = 1; eventfd_write(child_wait, 1); eventfd_read(child_resume, &dummy); exit(0); } eventfd_read(child_wait, &dummy); dump(child); eventfd_write(child_resume, 1); eventfd_read(child_wait, &dummy); dump(child); eventfd_write(child_resume, 1); eventfd_read(child_wait, &dummy); dump(child); eventfd_write(child_resume, 1); exit(0); } $ gcc -o rsstest rsstest.c && ./rsstest VmRSS: 68 kB Rss: 616 kB VmRSS: 68 kB Rss: 776 kB VmRSS: 812 kB Rss: 936 kB $ Let's document that those counters aren't entirely accurate. Reported-by: Mark Mossberg <mark.mossberg@gmail.com> Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com> |
||
---|---|---|
man1 | ||
man2 | ||
man3 | ||
man4 | ||
man5 | ||
man6 | ||
man7 | ||
man8 | ||
scripts | ||
CONTRIBUTING | ||
Changes | ||
Changes.old | ||
Makefile | ||
README | ||
man-pages-5.09.Announce | ||
man-pages-5.09.lsm |
README
This package contains Linux man pages for sections 1 through 8. Some more information is given in the 'man-pages-x.y.Announce' file. Homepage ======== For information about the Linux man-pages project, see http://www.kernel.org/doc/man-pages/index.html. Bug reports and contributing ============================ If you have corrections and additions to suggest, see http://www.kernel.org/doc/man-pages/contributing.html (Although there is a mirror of this repository on GitHub, please don't report issues via the GitHub issue tracker!) For further information on contributing, see the CONTRIBUTING file. Installing and uninstalling =========================== "make install" will copy these man pages to /usr/share/man/man[1-8]. To install to a path different from /usr, use "make install prefix=/install/path". "make remove" or "make uninstall" will remove any man page in this distribution from its destination. Use with caution, and remember to use "prefix" if desired, as with the "install" target. "make" or "make all" will perform "make uninstall" followed by "make install". Copyrights ========== See the 'man-pages-x.y.Announce' file.