summaryrefslogtreecommitdiffstats
path: root/mm/page_alloc.c
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-05-19 20:13:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-19 22:12:14 -0400
commit3da88fb3bacfaa33ff9d13730d17110bb2d9604d (patch)
treea24bf5d75dc11ecec7d26e32e18f8cf4b0c3c42b /mm/page_alloc.c
parent86dd995d63241039e0ad9123f9b424013c611510 (diff)
mm, oom: move GFP_NOFS check to out_of_memory
__alloc_pages_may_oom is the central place to decide when the out_of_memory should be invoked. This is a good approach for most checks there because they are page allocator specific and the allocation fails right after for all of them. The notable exception is GFP_NOFS context which is faking did_some_progress and keep the page allocator looping even though there couldn't have been any progress from the OOM killer. This patch doesn't change this behavior because we are not ready to allow those allocation requests to fail yet (and maybe we will face the reality that we will never manage to safely fail these request). Instead __GFP_FS check is moved down to out_of_memory and prevent from OOM victim selection there. There are two reasons for that - OOM notifiers might release some memory even from this context as none of the registered notifier seems to be FS related - this might help a dying thread to get an access to memory reserves and move on which will make the behavior more consistent with the case when the task gets killed from a different context. Keep a comment in __alloc_pages_may_oom to make sure we do not forget how GFP_NOFS is special and that we really want to do something about it. Note to the current oom_notifier users: The observable difference for you is that oom notifiers cannot depend on any fs locks because we could deadlock. Not that this would be allowed today because that would just lockup machine in most of the cases and ruling out the OOM killer along the way. Another difference is that callbacks might be invoked sooner now because GFP_NOFS is a weaker reclaim context and so there could be reclaimable memory which is just not reachable now. That would require GFP_NOFS only loads which are really rare and more importantly the observable result would be dropping of reconstructible object and potential performance drop which is not such a big deal when we are struggling to fulfill other important allocation requests. Signed-off-by: Michal Hocko <mhocko@suse.com> Cc: Raushaniya Maksudova <rmaksudova@parallels.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: David Rientjes <rientjes@google.com> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Daniel Vetter <daniel.vetter@intel.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r--mm/page_alloc.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index da6d339f1936..6d1c8b06b458 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2875,22 +2875,18 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
2875 /* The OOM killer does not needlessly kill tasks for lowmem */ 2875 /* The OOM killer does not needlessly kill tasks for lowmem */
2876 if (ac->high_zoneidx < ZONE_NORMAL) 2876 if (ac->high_zoneidx < ZONE_NORMAL)
2877 goto out; 2877 goto out;
2878 /* The OOM killer does not compensate for IO-less reclaim */
2879 if (!(gfp_mask & __GFP_FS)) {
2880 /*
2881 * XXX: Page reclaim didn't yield anything,
2882 * and the OOM killer can't be invoked, but
2883 * keep looping as per tradition.
2884 *
2885 * But do not keep looping if oom_killer_disable()
2886 * was already called, for the system is trying to
2887 * enter a quiescent state during suspend.
2888 */
2889 *did_some_progress = !oom_killer_disabled;
2890 goto out;
2891 }
2892 if (pm_suspended_storage()) 2878 if (pm_suspended_storage())
2893 goto out; 2879 goto out;
2880 /*
2881 * XXX: GFP_NOFS allocations should rather fail than rely on
2882 * other request to make a forward progress.
2883 * We are in an unfortunate situation where out_of_memory cannot
2884 * do much for this context but let's try it to at least get
2885 * access to memory reserved if the current task is killed (see
2886 * out_of_memory). Once filesystems are ready to handle allocation
2887 * failures more gracefully we should just bail out here.
2888 */
2889
2894 /* The OOM killer may not free memory on a specific node */ 2890 /* The OOM killer may not free memory on a specific node */
2895 if (gfp_mask & __GFP_THISNODE) 2891 if (gfp_mask & __GFP_THISNODE)
2896 goto out; 2892 goto out;