mm: vmscan: throttle reclaim if encountering too many dirty pages under writeback
mm: vmscan: throttle reclaim if encountering too many dirty pages under writeback

Workloads that are allocating frequently and writing files place a large
number of dirty pages on the LRU.  With use-once logic, it is possible for
them to reach the end of the LRU quickly requiring the reclaimer to scan
more to find clean pages.  Ordinarily, processes that are dirtying memory
will get throttled by dirty balancing but this is a global heuristic and
does not take into account that LRUs are maintained on a per-zone basis.
This can lead to a situation whereby reclaim is scanning heavily, skipping
over a large number of pages under writeback and recycling them around the
LRU consuming CPU.

This patch checks how many of the number of pages isolated from the LRU
were dirty and under writeback.  If a percentage of them under writeback,
the process will be throttled if a backing device or the zone is
congested.  Note that this applies whether it is anonymous or file-backed
pages that are under writeback meaning that swapping is potentially
throttled.  This is intentional due to the fact if the swap device is
congested, scanning more pages and dispatching more IO is not going to
help matters.

The percentage that must be in writeback depends on the priority.  At
default priority, all of them must be dirty.  At DEF_PRIORITY-1, 50% of
them must be, DEF_PRIORITY-2, 25% etc.  i.e.  as pressure increases the
greater the likelihood the process will get throttled to allow the flusher
threads to make some progress.

Signed-off-by: Mel Gorman <39ea6a09710987173e32e37c86918024a0f441c1@suse.de>
Reviewed-by: Minchan Kim <12330474acf818c36105a159b1ab0efedce0665c@gmail.com>
Acked-by: Johannes Weiner <5332d5d6802f0c4180a1f65eb38cf05f0ccdfd97@redhat.com>
Cc: Dave Chinner <aa743a0aaec8f7d7a1f01442503957f4d7a2d634@fromorbit.com>
Cc: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@infradead.org>
Cc: Wu Fengguang <24f7fe9d205c8a9f6ade0c2894e14303ca16087f@intel.com>
Cc: Jan Kara <596727c8a0ea4db3ba2ceceedccbacd3d7b371b8@suse.cz>
Cc: Rik van Riel <a21938f5d463ddf41aa718934c205ca2cce8ebbc@redhat.com>
Cc: Mel Gorman <39ea6a09710987173e32e37c86918024a0f441c1@suse.de>
Cc: Alex Elder <f556392d917047d964350b9c68912016c96d5e94@sgi.com>
Cc: Theodore Ts'o <4ed386e0495d3e109932df055831d9ec2f824927@mit.edu>
Cc: Chris Mason <a169954b4cb1a46cee25f659d3bddfebe02b5fba@oracle.com>
Cc: Dave Hansen <bfcdf3e6ca6cef45543bfbb57509c92aec9a39fb@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs