A mirror of Man pages
Go to file
Jann Horn 20e43cd694 proc.5: Document inaccurate RSS due to SPLIT_RSS_COUNTING
[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>
2020-10-27 14:52:08 +01:00
man1 ldd.1: Minor tweak to 'ldd' output example 2020-09-24 09:57:27 +02:00
man2 clone.2: CAP_CHECKPOINT_RESTORE can now be used to employ 'set_tid' 2020-10-27 14:51:44 +01:00
man3 posix_fallocate.3: wfix 2020-10-27 14:51:44 +01:00
man4 openat2.2, loop.4: tfix: s/non-zero/nonzero/ 2020-10-22 23:06:02 +02:00
man5 proc.5: Document inaccurate RSS due to SPLIT_RSS_COUNTING 2020-10-27 14:52:08 +01:00
man6 intro.6: wfix 2017-08-25 21:41:03 +02:00
man7 system_data_types.7: ffix 2020-10-27 14:51:44 +01:00
man8 ld.so.8: Add self to copyright 2020-10-17 23:16:47 +02:00
scripts man_show_fixme.sh: Fix misquoted double quotes in regexps 2020-09-30 09:39:05 +02:00
CONTRIBUTING CONTRIBUTING: New file with some starting tips on how to contribute 2019-09-13 15:59:08 +02:00
Changes Start of man-pages-5.09: updating Changes and Changes.old 2020-08-13 13:49:52 +02:00
Changes.old Changes.old: tfix 2020-09-04 09:41:46 +02:00
Makefile Makefile: Fix lintian.debian.org URL in comment 2020-08-25 13:55:07 +02:00
README README: Remove "Man page overlap and duplication" section 2020-04-13 09:06:45 +02:00
man-pages-5.09.Announce Start of man-pages-5.09: updating .Announce and .lsm files 2020-08-13 13:49:52 +02:00
man-pages-5.09.lsm Start of man-pages-5.09: updating .Announce and .lsm files 2020-08-13 13:49:52 +02:00

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.