Adds some vmstat for analysise vrange working. [PGDISCARD|PGVSCAN]_[KSWAPD|DIRECT] means purged page/scanning so we could see effectiveness of vrange. PGDISCARD_RESCUED means how many of pages we are missing in core discarding logic of vrange so if it is big in no big memory pressure, it may have a problem in scanning logic. PGDISCARD_SAVE_RECLAIM means how many time we avoid reclaim via discarding volatile pages but not sure how it is exact because sc->nr_to_reclaim is very high if it were sc->prioirty is low(ie, high memory pressure) so it it hard to meet the condition. Maybe I would change the check via zone_watermark_ok. Cc: Mel Gorman <mel@xxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxx> Cc: Michel Lespinasse <walken@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: John Stultz <john.stultz@xxxxxxxxxx> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx> --- include/linux/vm_event_item.h | 6 ++++++ mm/vmscan.c | 8 ++++++-- mm/vmstat.c | 6 ++++++ mm/vrange.c | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 1855f0a22add..df0d8e9e0540 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -25,6 +25,12 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, FOR_ALL_ZONES(PGALLOC), PGFREE, PGACTIVATE, PGDEACTIVATE, PGFAULT, PGMAJFAULT, + PGVSCAN_KSWAPD, + PGVSCAN_DIRECT, + PGDISCARD_KSWAPD, + PGDISCARD_DIRECT, + PGDISCARD_RESCUED, /* rescued from shrink_page_list */ + PGDISCARD_SAVE_RECLAIM, /* how many save reclaim */ FOR_ALL_ZONES(PGREFILL), FOR_ALL_ZONES(PGSTEAL_KSWAPD), FOR_ALL_ZONES(PGSTEAL_DIRECT), diff --git a/mm/vmscan.c b/mm/vmscan.c index d8f45af1ab84..c88e48be010b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -886,8 +886,10 @@ static unsigned long shrink_page_list(struct list_head *page_list, * because page->mapping could be NULL if it's purged. */ case PAGEREF_DISCARD: - if (may_enter_fs && discard_vpage(page) == 0) + if (may_enter_fs && discard_vpage(page) == 0) { + count_vm_event(PGDISCARD_RESCUED); goto free_it; + } case PAGEREF_KEEP: goto keep_locked; case PAGEREF_RECLAIM: @@ -1768,8 +1770,10 @@ static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan, unsigned long nr_reclaimed; nr_reclaimed = shrink_vrange(lru, lruvec, sc); - if (nr_reclaimed >= sc->nr_to_reclaim) + if (nr_reclaimed >= sc->nr_to_reclaim) { + count_vm_event(PGDISCARD_SAVE_RECLAIM); return nr_reclaimed; + } if (is_active_lru(lru)) { if (inactive_list_is_low(lruvec, lru)) diff --git a/mm/vmstat.c b/mm/vmstat.c index 9bb314577911..fa4eea4c5499 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -789,6 +789,12 @@ const char * const vmstat_text[] = { "pgfault", "pgmajfault", + "pgvscan_kswapd", + "pgvscan_direct", + "pgdiscard_kswapd", + "pgdiscard_direct", + "pgdiscard_rescued", + "pgdiscard_save_reclaim", TEXTS_FOR_ZONES("pgrefill") TEXTS_FOR_ZONES("pgsteal_kswapd") diff --git a/mm/vrange.c b/mm/vrange.c index 6cdbf6feed26..16de0a085453 100644 --- a/mm/vrange.c +++ b/mm/vrange.c @@ -1223,6 +1223,7 @@ static int discard_vrange(struct vrange *vrange, unsigned long *nr_discard, { int ret = 0; struct vrange_root *vroot; + unsigned long total_scan = *scan; vroot = vrange->owner; vroot = vrange_get_vroot(vrange); @@ -1244,6 +1245,19 @@ static int discard_vrange(struct vrange *vrange, unsigned long *nr_discard, ret = __discard_vrange_file(mapping, vrange, nr_discard, scan); } + if (!ret) { + if (current_is_kswapd()) + count_vm_events(PGDISCARD_KSWAPD, *nr_discard); + else + count_vm_events(PGDISCARD_DIRECT, *nr_discard); + } + + if (current_is_kswapd()) + count_vm_events(PGVSCAN_KSWAPD, + (total_scan - *scan) >> PAGE_SHIFT); + else + count_vm_events(PGVSCAN_DIRECT, + (total_scan - *scan) >> PAGE_SHIFT); out: __vroot_put(vroot); return ret; -- 1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>