The same bug is contained in both try_to_free_pages and balance_pgdat. On reclaiming the requisite number of pages we correctly set prev_priority back to DEF_PRIORITY. However, we ALSO do this even if we loop over all priorities and fail to reclaim. Setting prev_priority artificially high causes reclaimers to set distress artificially low, and fail to reclaim mapped pages, when they are, in fact, under severe memory pressure (their priority may be as low as 0). This causes the OOM killer to fire incorrectly. This patch changes that to set prev_priority to 0 instead, if we fail to reclaim. Signed-off-by: Martin J. Bligh