[Devel] [PATCH RHEL7 COMMIT] mm/vmstat, io_acct: fix PGPGIN/PGPGOUT in container's /proc/vmstat.

Konstantin Khorenko khorenko at virtuozzo.com
Wed Sep 26 19:23:10 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.11.6.vz7.71.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.11.6.vz7.71.14
------>
commit 95e75ce66e7a108279ef24a9534ff421d0320a0c
Author: Andrey Ryabinin <aryabinin at virtuozzo.com>
Date:   Wed Sep 26 19:23:10 2018 +0300

    mm/vmstat, io_acct: fix PGPGIN/PGPGOUT in container's /proc/vmstat.
    
    In container the pgpgin/pgpgout in /proc/vmstat were incorrectly printed
    in nr_dirty_threshold, and nr_dirty_background_threshold fields, because
    offset of the vm_events events array calculated incorrectly. We didn't
    take into account array of writeback_stat_item which comes before the
    vm_events. Fix up the offset.
    
    Note: cgroup pgpgin/pgpgout counters are different - they match any page
    in/out, while pgpgin/pgpgout in /proc/vmstat count only pages actions which
    imply real io.
    
    https://jira.sw.ru/browse/PSBM-88323
    Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
    Acked-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 include/linux/vmstat.h | 7 +++++++
 kernel/bc/io_acct.c    | 3 ++-
 mm/vmstat.c            | 6 ------
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 99c3389fb3ec..f0a517753c9d 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -10,6 +10,13 @@
 
 extern int sysctl_stat_interval;
 
+enum writeback_stat_item {
+	NR_DIRTY_THRESHOLD,
+	NR_DIRTY_BG_THRESHOLD,
+	NR_VM_WRITEBACK_STAT_ITEMS,
+};
+
+
 #ifdef CONFIG_VM_EVENT_COUNTERS
 /*
  * Light weight per cpu counter implementation.
diff --git a/kernel/bc/io_acct.c b/kernel/bc/io_acct.c
index 22122242356f..9ccfd15e6e26 100644
--- a/kernel/bc/io_acct.c
+++ b/kernel/bc/io_acct.c
@@ -313,7 +313,8 @@ static int bc_ioacct_notify(struct vnotifier_block *self,
 	bout >>= 10;
 	bin >>= 10;
 
-	vm_events = ((unsigned long *)arg) + NR_VM_ZONE_STAT_ITEMS;
+	vm_events = ((unsigned long *)arg) + NR_VM_ZONE_STAT_ITEMS +
+		NR_VM_WRITEBACK_STAT_ITEMS;
 	vm_events[PGPGOUT] = (unsigned long)bout;
 	vm_events[PGPGIN] = (unsigned long)bin;
 	return NOTIFY_OK;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index ed6a5945a684..9e8e5eab0636 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1157,12 +1157,6 @@ static const struct file_operations proc_zoneinfo_file_operations = {
 	.release	= seq_release,
 };
 
-enum writeback_stat_item {
-	NR_DIRTY_THRESHOLD,
-	NR_DIRTY_BG_THRESHOLD,
-	NR_VM_WRITEBACK_STAT_ITEMS,
-};
-
 static void *vmstat_start(struct seq_file *m, loff_t *pos)
 {
 	unsigned long *v;


More information about the Devel mailing list