Now that the free block count for each migration types in
/proc/pagetypeinfo may not show the exact count if it excceeds
100,000. Users may not know how much more the counts will be. As the
free_area structure has already tracked the total free block count in
nr_free, we may as well print it out with no additional cost. That will
give users a rough idea of where the upper bounds will be.

If there is no overflow, the presence of the total counts will also
enable us to check if the nr_free counts match the total number of
entries in the free lists.

Signed-off-by: Waiman Long <long...@redhat.com>
---
 mm/vmstat.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/mm/vmstat.c b/mm/vmstat.c
index c5b82fdf54af..172946d8f358 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -1373,6 +1373,7 @@ static void pagetypeinfo_showfree_print(struct seq_file 
*m,
                                        pg_data_t *pgdat, struct zone *zone)
 {
        int order, mtype;
+       struct free_area *area;
        unsigned long iteration_count = 0;
 
        for (mtype = 0; mtype < MIGRATE_TYPES; mtype++) {
@@ -1382,7 +1383,6 @@ static void pagetypeinfo_showfree_print(struct seq_file 
*m,
                                        migratetype_names[mtype]);
                for (order = 0; order < MAX_ORDER; ++order) {
                        unsigned long freecount = 0;
-                       struct free_area *area;
                        struct list_head *curr;
                        bool overflow = false;
 
@@ -1419,6 +1419,17 @@ static void pagetypeinfo_showfree_print(struct seq_file 
*m,
                }
                seq_putc(m, '\n');
        }
+
+       /*
+        * List total free blocks per order
+        */
+       seq_printf(m, "Node %4d, zone %8s, total             ",
+                  pgdat->node_id, zone->name);
+       for (order = 0; order < MAX_ORDER; ++order) {
+               area = &(zone->free_area[order]);
+               seq_printf(m, "%6lu ", area->nr_free);
+       }
+       seq_putc(m, '\n');
 }
 
 /* Print out the free pages at each order for each migatetype */
-- 
2.18.1

Reply via email to