History

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.

Hugh Dickins committed 10 years ago

Commit 52b6f461 parent 9e18eb24 files · +85 −0Browse files

Showing the changes to kernel/sysctl.c (1 of 4 files). Show all

Unified · Split

kernel/sysctl.c+7−0
@@ -1521,6 +1521,13 @@ static struct ctl_table vm_table[] = { · 1520 unmodified lines
15211521 .mode = 0644,
15221522 .proc_handler = proc_dointvec_jiffies,
15231523 },
1524+ {
1525+ .procname = "stat_refresh",
1526+ .data = NULL,
1527+ .maxlen = 0,
1528+ .mode = 0600,
1529+ .proc_handler = vmstat_refresh,
1530+ },
15241531 #endif
15251532 #ifdef CONFIG_MMU
15261533 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t