Skip to content

Commit

Permalink
mm/vmscan: Account large folios correctly
Browse files Browse the repository at this point in the history
The statistics we gather should count the number of pages, not the
number of folios.  The logic in this function is somewhat convoluted,
but even if we split the folio, I think the accounting is now correct.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
  • Loading branch information
Matthew Wilcox (Oracle) committed Mar 21, 2022
1 parent 343b288 commit c79b7b9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,10 +1575,10 @@ static unsigned int shrink_page_list(struct list_head *page_list,
*/
folio_check_dirty_writeback(folio, &dirty, &writeback);
if (dirty || writeback)
stat->nr_dirty++;
stat->nr_dirty += nr_pages;

if (dirty && !writeback)
stat->nr_unqueued_dirty++;
stat->nr_unqueued_dirty += nr_pages;

/*
* Treat this page as congested if the underlying BDI is or if
Expand All @@ -1590,7 +1590,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
if (((dirty || writeback) && mapping &&
inode_write_congested(mapping->host)) ||
(writeback && PageReclaim(page)))
stat->nr_congested++;
stat->nr_congested += nr_pages;

/*
* If a page at the tail of the LRU is under writeback, there
Expand Down Expand Up @@ -1639,7 +1639,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
if (current_is_kswapd() &&
PageReclaim(page) &&
test_bit(PGDAT_WRITEBACK, &pgdat->flags)) {
stat->nr_immediate++;
stat->nr_immediate += nr_pages;
goto activate_locked;

/* Case 2 above */
Expand All @@ -1657,7 +1657,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
* and it's also appropriate in global reclaim.
*/
SetPageReclaim(page);
stat->nr_writeback++;
stat->nr_writeback += nr_pages;
goto activate_locked;

/* Case 3 above */
Expand Down Expand Up @@ -1823,7 +1823,7 @@ static unsigned int shrink_page_list(struct list_head *page_list,
case PAGE_ACTIVATE:
goto activate_locked;
case PAGE_SUCCESS:
stat->nr_pageout += thp_nr_pages(page);
stat->nr_pageout += nr_pages;

if (PageWriteback(page))
goto keep;
Expand Down

0 comments on commit c79b7b9

Please sign in to comment.