Re: __GFP_NOFAIL and oom_killer_disabled?

Tetsuo Handa
2015-02-23T13:57:33Z

Michal Hocko wrote:
> What about something like the following?

I'm fine with whatever approaches as long as retry is guaranteed.

But maybe we can use memory reserves like below? I think there will be
little risk because userspace processes are already frozen...

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a47f0b2..cea0a1b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2760,8 +2760,17 @@ retry:
&did_some_progress);
if (page)
goto got_pg;
- if (!did_some_progress)
+ if (!did_some_progress && !(gfp_mask & __GFP_NOFAIL))
goto nopage;
+ /*
+ * What!? __GFP_NOFAIL allocation failed to invoke
+ * the OOM killer due to oom_killer_disabled == true?
+ * Then, pretend ALLOC_NO_WATERMARKS request and let
+ * __alloc_pages_high_priority() retry forever...
+ */
+ WARN(1, "Retrying GFP_NOFAIL allocation...\n");
+ gfp_mask &= ~__GFP_NOMEMALLOC;
+ gfp_mask |= __GFP_MEMALLOC;
}
/* Wait for some write requests to complete then retry */
wait_iff_congested(ac->preferred_zone, BLK_RW_ASYNC, HZ/50);