mm, vmscan: do not count freed pages as PGDEACTIVATE
authorMichal Hocko <[email protected]>
Wed, 22 Feb 2017 23:45:55 +0000 (15:45 -0800)
committerLinus Torvalds <[email protected]>
Thu, 23 Feb 2017 00:41:30 +0000 (16:41 -0800)
PGDEACTIVATE represents the number of pages moved from the active list
to the inactive list.  At least this sounds like the original motivation
of the counter.  move_active_pages_to_lru, however, counts pages which
got freed in the mean time as deactivated as well.  This is a very rare
event and counting them as deactivation in itself is not harmful but it
makes the code more convoluted than necessary - we have to count both
all pages and those which are freed which is a bit confusing.

After this patch the PGDEACTIVATE should have a slightly more clear
semantic and only count those pages which are moved from the active to
the inactive list which is a plus.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Michal Hocko <[email protected]>
Suggested-by: Vlastimil Babka <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Mel Gorman <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/vmscan.c

index de400d1eac0e8d6ef3b67cd5a370140ef9e1fa9f..277e105646a5d986685505a46f2325eebd79792f 100644 (file)
@@ -1878,7 +1878,6 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec,
                                     enum lru_list lru)
 {
        struct pglist_data *pgdat = lruvec_pgdat(lruvec);
-       unsigned long pgmoved = 0;
        struct page *page;
        int nr_pages;
        int nr_moved = 0;
@@ -1893,7 +1892,6 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec,
                nr_pages = hpage_nr_pages(page);
                update_lru_size(lruvec, lru, page_zonenum(page), nr_pages);
                list_move(&page->lru, &lruvec->lists[lru]);
-               pgmoved += nr_pages;
 
                if (put_page_testzero(page)) {
                        __ClearPageLRU(page);
@@ -1913,7 +1911,7 @@ static unsigned move_active_pages_to_lru(struct lruvec *lruvec,
        }
 
        if (!is_active_lru(lru))
-               __count_vm_events(PGDEACTIVATE, pgmoved);
+               __count_vm_events(PGDEACTIVATE, nr_moved);
 
        return nr_moved;
 }