We need to make sure that the page is deleted from or added to the correct lruvec list. So add a VM_BUG_ON_PAGE() to catch invalid users. Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> --- include/linux/mm_inline.h | 6 ++++++ mm/vmscan.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h index 355ea1ee32bd..1ca1e2ab8565 100644 --- a/include/linux/mm_inline.h +++ b/include/linux/mm_inline.h @@ -84,6 +84,8 @@ static __always_inline void add_page_to_lru_list(struct page *page, { enum lru_list lru = page_lru(page); + VM_BUG_ON_PAGE(!page_matches_lruvec(page, lruvec), page); + update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page)); list_add(&page->lru, &lruvec->lists[lru]); } @@ -93,6 +95,8 @@ static __always_inline void add_page_to_lru_list_tail(struct page *page, { enum lru_list lru = page_lru(page); + VM_BUG_ON_PAGE(!page_matches_lruvec(page, lruvec), page); + update_lru_size(lruvec, lru, page_zonenum(page), thp_nr_pages(page)); list_add_tail(&page->lru, &lruvec->lists[lru]); } @@ -100,6 +104,8 @@ static __always_inline void add_page_to_lru_list_tail(struct page *page, static __always_inline void del_page_from_lru_list(struct page *page, struct lruvec *lruvec) { + VM_BUG_ON_PAGE(!page_matches_lruvec(page, lruvec), page); + list_del(&page->lru); update_lru_size(lruvec, page_lru(page), page_zonenum(page), -thp_nr_pages(page)); diff --git a/mm/vmscan.c b/mm/vmscan.c index 6878a6bff2f8..f38ec21babf3 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2199,7 +2199,6 @@ static unsigned int move_pages_to_lru(struct list_head *list) continue; } - VM_BUG_ON_PAGE(!page_matches_lruvec(page, lruvec), page); add_page_to_lru_list(page, lruvec); nr_pages = thp_nr_pages(page); nr_moved += nr_pages; -- 2.11.0