diff options
| author | Hugh Dickins <hughd@google.com> | 2016-05-19 20:12:50 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-19 22:12:14 -0400 |
| commit | 52b6f46bc163eef17ecba4cd552beeafe2b24453 (patch) | |
| tree | f1f8a9dc258f548fcdb7fa63b9b9a5eebd17976f /Documentation/sysctl | |
| parent | 9e18eb29356b7dfd55183bd42cf73919d1590835 (diff) | |
mm: /proc/sys/vm/stat_refresh to force vmstat update
Provide /proc/sys/vm/stat_refresh to force an immediate update of
per-cpu into global vmstats: useful to avoid a sleep(2) or whatever
before checking counts when testing. Originally added to work around a
bug which left counts stranded indefinitely on a cpu going idle (an
inaccuracy magnified when small below-batch numbers represent "huge"
amounts of memory), but I believe that bug is now fixed: nonetheless,
this is still a useful knob.
Its schedule_on_each_cpu() is probably too expensive just to fold into
reading /proc/meminfo itself: give this mode 0600 to prevent abuse.
Allow a write or a read to do the same: nothing to read, but "grep -h
Shmem /proc/sys/vm/stat_refresh /proc/meminfo" is convenient. Oh, and
since global_page_state() itself is careful to disguise any underflow as
0, hack in an "Invalid argument" and pr_warn() if a counter is negative
after the refresh - this helped to fix a misaccounting of
NR_ISOLATED_FILE in my migration code.
But on recent kernels, I find that NR_ALLOC_BATCH and NR_PAGES_SCANNED
often go negative some of the time. I have not yet worked out why, but
have no evidence that it's actually harmful. Punt for the moment by
just ignoring the anomaly on those.
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Andres Lagar-Cavilla <andreslc@google.com>
Cc: Yang Shi <yang.shi@linaro.org>
Cc: Ning Qu <quning@gmail.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Andres Lagar-Cavilla <andreslc@google.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'Documentation/sysctl')
| -rw-r--r-- | Documentation/sysctl/vm.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Documentation/sysctl/vm.txt b/Documentation/sysctl/vm.txt index 34a5fece3121..720355cbdf45 100644 --- a/Documentation/sysctl/vm.txt +++ b/Documentation/sysctl/vm.txt | |||
| @@ -57,6 +57,7 @@ Currently, these files are in /proc/sys/vm: | |||
| 57 | - panic_on_oom | 57 | - panic_on_oom |
| 58 | - percpu_pagelist_fraction | 58 | - percpu_pagelist_fraction |
| 59 | - stat_interval | 59 | - stat_interval |
| 60 | - stat_refresh | ||
| 60 | - swappiness | 61 | - swappiness |
| 61 | - user_reserve_kbytes | 62 | - user_reserve_kbytes |
| 62 | - vfs_cache_pressure | 63 | - vfs_cache_pressure |
| @@ -755,6 +756,19 @@ is 1 second. | |||
| 755 | 756 | ||
| 756 | ============================================================== | 757 | ============================================================== |
| 757 | 758 | ||
| 759 | stat_refresh | ||
| 760 | |||
| 761 | Any read or write (by root only) flushes all the per-cpu vm statistics | ||
| 762 | into their global totals, for more accurate reports when testing | ||
| 763 | e.g. cat /proc/sys/vm/stat_refresh /proc/meminfo | ||
| 764 | |||
| 765 | As a side-effect, it also checks for negative totals (elsewhere reported | ||
| 766 | as 0) and "fails" with EINVAL if any are found, with a warning in dmesg. | ||
| 767 | (At time of writing, a few stats are known sometimes to be found negative, | ||
| 768 | with no ill effects: errors and warnings on these stats are suppressed.) | ||
| 769 | |||
| 770 | ============================================================== | ||
| 771 | |||
| 758 | swappiness | 772 | swappiness |
| 759 | 773 | ||
| 760 | This control is used to define how aggressive the kernel will swap | 774 | This control is used to define how aggressive the kernel will swap |
