mm: vmscan: Add warn on inadvertently reclaiming mapped page
Quoted 10 lines · Hillf Danton
In the function
isolate_lru_pages(), we checkscan_control::may_unmapand set isolation mode accordingly in order to not isolate from the lru list any page that does not match the isolation mode. For example, we should skip all sill mapped pages if isolation mode is set to beISOLATE_UNMAPPED.So complain, while scanning the isolated pages, about the very unlikely event that we hit a mapped page that we should never have isolated. Note no change is added in the current scanning behavior without VM debug configured.
And cut off one line of comment that goes stale.
Looks good to me. Reviewed-by: Yang Shi <[email protected]>
Quoted 36 lines
Cc Mel Gorman <[email protected]>Cc Johannes Weiner <[email protected]>Cc Minchan Kim <[email protected]>Cc Yang Shi <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by Hillf Danton <[email protected]>--- mm/vmscan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)mm/vmscan.c +3
-3@@ -1134,8 +1134,10 @@ static unsigned long shrink_page_list(struct list_head *page_list,if (unlikely (!page_evictable (page))) goto activate_locked; -if (!sc->may_unmap &&page_mapped (page)) +if (!sc->may_unmap &&page_mapped (page)) { +VM_WARN_ON (true); goto keep_locked; + }/* Double the slab pressure for mapped and swapcache pages */ if ((page_mapped(page) || PageSwapCache(page)) &&@@ -1632,7 +1634,6 @@ static __always_inline void update_lru_sizes(struct lruvec *lruvec,* @dst: The temp list to put pages on to. * @nr_scanned: The number of pages that were scanned. * @sc: The scan_control struct for this reclaim session -* @mode: One of the LRU isolation modes * @lru: LRU list id for isolating * * returns how many pages were moved onto *@dst. --
Andrew Morton
maintainerQuoted 8 lines · On Sun, 26 May 2019 14:23:53 +0800 Hillf Danton <[email protected]> wrote:
In the function
isolate_lru_pages(), we checkscan_control::may_unmapand set isolation mode accordingly in order to not isolate from the lru list any page that does not match the isolation mode. For example, we should skip all sill mapped pages if isolation mode is set to beISOLATE_UNMAPPED.So complain, while scanning the isolated pages, about the very unlikely event that we hit a mapped page that we should never have isolated. Note no change is added in the current scanning behavior without VM debug configured.
The patch is inoffensive enough, but one wonders what inspired it. Do you have reason to believe that this will trigger?
Quoted 7 lines · Andrew Morton
Quoted 5 lines · On Sun, 26 May 2019 14:23:53 +0800 Hillf Danton <[email protected]> wrote:
In the function
isolate_lru_pages(), we checkscan_control::may_unmapand set isolation mode accordingly in order to not isolate from the lru list any page that does not match the isolation mode. For example, we should skip all sill mapped pages if isolation mode is set to beISOLATE_UNMAPPED.
Quoted 6 lines
Quoted 3 lines
So complain, while scanning the isolated pages, about the very unlikely event that we hit a mapped page that we should never have isolated. Note no change is added in the current scanning behavior without VM debug configured.
The patch is inoffensive enough, but one wonders what inspired it. Do you have reason to believe that this will trigger?
I don't think this patch makes sense.
There isn't anything preventing someone from mapping the page between the LRU isolation and shrink_page_list(). The isolation filter is only an optimization to reduce unnecessary LRU churn, not a guarantee.