diff --git a/mm/vmscan.c b/mm/vmscan.c index 70336ae6507cc..033d58ca57e71 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -917,9 +917,21 @@ static unsigned long shrink_page_list(struct list_head *page_list, nr_immediate++; goto keep_locked; - /* Case 2 above */ + /* + * memcg doesn't have any dirty pages throttling so we + * could easily OOM just because too many pages are in + * writeback and there is nothing else to reclaim. + * + * Require may_enter_fs to wait on writeback, because + * fs may not have submitted IO yet. And a loop driver + * thread might enter reclaim, and deadlock if it waits + * on a page for which it is needed to do the write + * (loop masks off __GFP_IO|__GFP_FS for this reason); + * but more thought would probably show more reasons. + */ + } else if (global_reclaim(sc) || - !PageReclaim(page) || !(sc->gfp_mask & __GFP_IO)) { + !PageReclaim(page) || !may_enter_fs) { /* * This is slightly racy - end_page_writeback() * might have just cleared PageReclaim, then