]> Git Repo - linux.git/commit
mm: /proc/sys/vm/stat_refresh to force vmstat update
authorHugh Dickins <[email protected]>
Fri, 20 May 2016 00:12:50 +0000 (17:12 -0700)
committerLinus Torvalds <[email protected]>
Fri, 20 May 2016 02:12:14 +0000 (19:12 -0700)
commit52b6f46bc163eef17ecba4cd552beeafe2b24453
treef1f8a9dc258f548fcdb7fa63b9b9a5eebd17976f
parent9e18eb29356b7dfd55183bd42cf73919d1590835
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 <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Andres Lagar-Cavilla <[email protected]>
Cc: Yang Shi <[email protected]>
Cc: Ning Qu <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Andres Lagar-Cavilla <[email protected]>
Cc: Konstantin Khlebnikov <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Documentation/sysctl/vm.txt
include/linux/vmstat.h
kernel/sysctl.c
mm/vmstat.c
This page took 0.057794 seconds and 4 git commands to generate.