aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorMichal Hocko <mhocko@suse.com>2016-09-01 19:14:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-09-01 20:52:01 -0400
commit6b4e3181d7bd5ca5ab6f45929e4a5ffa7ab4ab7f (patch)
tree3320f181ccbf14f313fd91e80a8daa757d449153 /mm
parent071e31e254e0e0c438eecba3dba1d6e2d0da36c2 (diff)
mm, oom: prevent premature OOM killer invocation for high order request
There have been several reports about pre-mature OOM killer invocation in 4.7 kernel when order-2 allocation request (for the kernel stack) invoked OOM killer even during basic workloads (light IO or even kernel compile on some filesystems). In all reported cases the memory is fragmented and there are no order-2+ pages available. There is usually a large amount of slab memory (usually dentries/inodes) and further debugging has shown that there are way too many unmovable blocks which are skipped during the compaction. Multiple reporters have confirmed that the current linux-next which includes [1] and [2] helped and OOMs are not reproducible anymore. A simpler fix for the late rc and stable is to simply ignore the compaction feedback and retry as long as there is a reclaim progress and we are not getting OOM for order-0 pages. We already do that for CONFING_COMPACTION=n so let's reuse the same code when compaction is enabled as well. [1] http://lkml.kernel.org/r/20160810091226.6709-1-vbabka@suse.cz [2] http://lkml.kernel.org/r/f7a9ea9d-bb88-bfd6-e340-3a933559305a@suse.cz Fixes: 0a0337e0d1d1 ("mm, oom: rework oom detection") Link: http://lkml.kernel.org/r/20160823074339.GB23577@dhcp22.suse.cz Signed-off-by: Michal Hocko <mhocko@suse.com> Tested-by: Olaf Hering <olaf@aepfle.de> Tested-by: Ralf-Peter Rohbeck <Ralf-Peter.Rohbeck@quantum.com> Cc: Markus Trippelsdorf <markus@trippelsdorf.de> Cc: Arkadiusz Miskiewicz <a.miskiewicz@gmail.com> Cc: Ralf-Peter Rohbeck <Ralf-Peter.Rohbeck@quantum.com> Cc: Jiri Slaby <jslaby@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Joonsoo Kim <js1304@gmail.com> Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Cc: David Rientjes <rientjes@google.com> Cc: <stable@vger.kernel.org> [4.7.x] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c51
1 files changed, 2 insertions, 49 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3fbe73a6fe4b..7791a03f8deb 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3137,54 +3137,6 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
3137 return NULL; 3137 return NULL;
3138} 3138}
3139 3139
3140static inline bool
3141should_compact_retry(struct alloc_context *ac, int order, int alloc_flags,
3142 enum compact_result compact_result,
3143 enum compact_priority *compact_priority,
3144 int compaction_retries)
3145{
3146 int max_retries = MAX_COMPACT_RETRIES;
3147
3148 if (!order)
3149 return false;
3150
3151 /*
3152 * compaction considers all the zone as desperately out of memory
3153 * so it doesn't really make much sense to retry except when the
3154 * failure could be caused by insufficient priority
3155 */
3156 if (compaction_failed(compact_result)) {
3157 if (*compact_priority > MIN_COMPACT_PRIORITY) {
3158 (*compact_priority)--;
3159 return true;
3160 }
3161 return false;
3162 }
3163
3164 /*
3165 * make sure the compaction wasn't deferred or didn't bail out early
3166 * due to locks contention before we declare that we should give up.
3167 * But do not retry if the given zonelist is not suitable for
3168 * compaction.
3169 */
3170 if (compaction_withdrawn(compact_result))
3171 return compaction_zonelist_suitable(ac, order, alloc_flags);
3172
3173 /*
3174 * !costly requests are much more important than __GFP_REPEAT
3175 * costly ones because they are de facto nofail and invoke OOM
3176 * killer to move on while costly can fail and users are ready
3177 * to cope with that. 1/4 retries is rather arbitrary but we
3178 * would need much more detailed feedback from compaction to
3179 * make a better decision.
3180 */
3181 if (order > PAGE_ALLOC_COSTLY_ORDER)
3182 max_retries /= 4;
3183 if (compaction_retries <= max_retries)
3184 return true;
3185
3186 return false;
3187}
3188#else 3140#else
3189static inline struct page * 3141static inline struct page *
3190__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, 3142__alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
@@ -3195,6 +3147,8 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order,
3195 return NULL; 3147 return NULL;
3196} 3148}
3197 3149
3150#endif /* CONFIG_COMPACTION */
3151
3198static inline bool 3152static inline bool
3199should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags, 3153should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_flags,
3200 enum compact_result compact_result, 3154 enum compact_result compact_result,
@@ -3221,7 +3175,6 @@ should_compact_retry(struct alloc_context *ac, unsigned int order, int alloc_fla
3221 } 3175 }
3222 return false; 3176 return false;
3223} 3177}
3224#endif /* CONFIG_COMPACTION */
3225 3178
3226/* Perform direct synchronous page reclaim */ 3179/* Perform direct synchronous page reclaim */
3227static int 3180static int