From: Minchan Kim <[email protected]>

This patch adds the number of purged page in vmstat so admin can see
how many of volatile pages are discarded by VM until now.

Cc: Andrew Morton <[email protected]>
Cc: Android Kernel Team <[email protected]>
Cc: Robert Love <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Dmitry Adamushko <[email protected]>
Cc: Dave Chinner <[email protected]>
Cc: Neil Brown <[email protected]>
Cc: Andrea Righi <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Aneesh Kumar K.V <[email protected]>
Cc: Mike Hommey <[email protected]>
Cc: Taras Glek <[email protected]>
Cc: Dhaval Giani <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: Michel Lespinasse <[email protected]>
Cc: Rob Clark <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: [email protected] <[email protected]>
Signed-off-by: Minchan Kim <[email protected]>
Signed-off-by: John Stultz <[email protected]>
---
 include/linux/vm_event_item.h |  2 ++
 mm/vmstat.c                   |  2 ++
 mm/vrange.c                   | 10 ++++++++++
 3 files changed, 14 insertions(+)

diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h
index bd6cf61..c4aea92 100644
--- a/include/linux/vm_event_item.h
+++ b/include/linux/vm_event_item.h
@@ -25,6 +25,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
                FOR_ALL_ZONES(PGALLOC),
                PGFREE, PGACTIVATE, PGDEACTIVATE,
                PGFAULT, PGMAJFAULT,
+               PGDISCARD_DIRECT,
+               PGDISCARD_KSWAPD,
                FOR_ALL_ZONES(PGREFILL),
                FOR_ALL_ZONES(PGSTEAL_KSWAPD),
                FOR_ALL_ZONES(PGSTEAL_DIRECT),
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 20c2ef4..4f35f46 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -756,6 +756,8 @@ const char * const vmstat_text[] = {
 
        "pgfault",
        "pgmajfault",
+       "pgdiscard_direct",
+       "pgdiscard_kswapd",
 
        TEXTS_FOR_ZONES("pgrefill")
        TEXTS_FOR_ZONES("pgsteal_kswapd")
diff --git a/mm/vrange.c b/mm/vrange.c
index c30e3dd..8931fab 100644
--- a/mm/vrange.c
+++ b/mm/vrange.c
@@ -894,6 +894,10 @@ int discard_vpage(struct page *page)
 
                if (page_freeze_refs(page, 1)) {
                        unlock_page(page);
+                       if (current_is_kswapd())
+                               count_vm_event(PGDISCARD_KSWAPD);
+                       else
+                               count_vm_event(PGDISCARD_DIRECT);
                        return 0;
                }
        }
@@ -1144,6 +1148,12 @@ static int discard_vrange(struct vrange *vrange)
                ret = __discard_vrange_file(mapping, vrange, &nr_discard);
        }
 
+       if (!ret) {
+               if (current_is_kswapd())
+                       count_vm_events(PGDISCARD_KSWAPD, nr_discard);
+               else
+                       count_vm_events(PGDISCARD_DIRECT, nr_discard);
+       }
 out:
        __vroot_put(vroot);
        return nr_discard;
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to