From: Andrew Morton <akpm@osdl.org>
To: Kirill Korotaev <dev@sw.ru>
Cc: saw@sawoct.com, xemul@sw.ru, linux-kernel@vger.kernel.org,
den@sw.ru, Nick Piggin <nickpiggin@yahoo.com.au>
Subject: Re: [PATCH]: buddy allocator: ext3 failed to alloc with __GFP_NOFAIL
Date: Wed, 9 Nov 2005 19:18:02 -0800 [thread overview]
Message-ID: <20051109191802.02612594.akpm@osdl.org> (raw)
In-Reply-To: <43725227.5040605@sw.ru>
Kirill Korotaev <dev@sw.ru> wrote:
>
> So kswapd (which has PF_MEMALLOC flag) can fail to allocate memory even
> when it allocates it with __GFP_NOFAIL flag.
>
> --- ./mm/page_alloc.c.alpg 2005-11-09 21:42:50.000000000 +0300
> +++ ./mm/page_alloc.c 2005-11-09 21:44:22.000000000 +0300
> @@ -870,6 +870,7 @@ zone_reclaim_retry:
> if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
> && !in_interrupt()) {
> if (!(gfp_mask & __GFP_NOMEMALLOC)) {
> +nofail_alloc:
> /* go through the zonelist yet again, ignoring mins */
> for (i = 0; (z = zones[i]) != NULL; i++) {
> if (!cpuset_zone_allowed(z, gfp_mask))
> @@ -878,6 +879,10 @@ zone_reclaim_retry:
> if (page)
> goto got_pg;
> }
> + if (gfp_mask & __GFP_NOFAIL) {
> + blk_congestion_wait(WRITE, HZ/50);
> + goto nofail_alloc;
> + }
> }
> goto nopage;
> }
The problem here is that we'll loop if TIF_MEMDIE is set.
But given that the caller has specified __GFP_NOFAIL, I think that's
correct behaviour - __GFP_NOFAIL means "I am lame, and will oops if you
cannot allocate memory". So we just ignore TIF_MEMDIE..
That being said, why do we need another loop here? Would it not
be sufficient to do:
--- devel/mm/page_alloc.c~a 2005-11-09 19:15:03.000000000 -0800
+++ devel-akpm/mm/page_alloc.c 2005-11-09 19:15:32.000000000 -0800
@@ -907,7 +907,8 @@ zone_reclaim_retry:
goto got_pg;
}
}
- goto nopage;
+ if (!(gfp_mask & __GFP_NOFAIL))
+ goto nopage;
}
/* Atomic allocations - we can't balance anything */
_
Answer: because that way we'll go recursive if PF_MEMALLOC is set. Ho-hum.
prev parent reply other threads:[~2005-11-10 3:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 13:48 Kirill Korotaev
2005-11-09 19:46 ` Kirill Korotaev
2005-11-09 20:20 ` Andrew Morton
2005-11-10 3:18 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20051109191802.02612594.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=den@sw.ru \
--cc=dev@sw.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=saw@sawoct.com \
--cc=xemul@sw.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®