mm: vmscan: never isolate more pages than necessary
mm: vmscan: never isolate more pages than necessary

If transparent huge pages are enabled, we can isolate many more pages
than we actually need to scan, because we count both single and huge
pages equally in isolate_lru_pages().

Since commit 5bc7b8aca942d ("mm: thp: add split tail pages to shrink
page list in page reclaim"), we scan all the tail pages immediately
after a huge page split (see shrink_page_list()).  As a result, we can
reclaim up to SWAP_CLUSTER_MAX * HPAGE_PMD_NR (512 MB) in one run!

This is easy to catch on memcg reclaim with zswap enabled.  The latter
makes swapout instant so that if we happen to scan an unreferenced huge
page we will evict both its head and tail pages immediately, which is
likely to result in excessive reclaim.

Signed-off-by: Vladimir Davydov <0d62248ee021b6e01c0ee596a62a5b145b996974@parallels.com>
Cc: Johannes Weiner <331be22c6b63ca3e0a03d408c2d906b1b02cd5f2@cmpxchg.org>
Reviewed-by: Michal Hocko <829500b200af6c2a0eca4dfd5c388e6b8fbe8dc6@suse.cz>
Cc: Vlastimil Babka <db766431e3f0373ca1ec8fa855cfd5f84b2f2eb6@suse.cz>
Cc: Minchan Kim <eee62f459f15dcddf87a8df69e8328e2a2562028@kernel.org>
Cc: Mel Gorman <39ea6a09710987173e32e37c86918024a0f441c1@techsingularity.net>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs