Dealing with memory allocation failures is a requirement for all kernel
code (and user-space code as well). But there are some places in the
kernel where failures cannot be allowed to happen. So it is not uncommon
to see kernel code which doesn't take "no" for an answer. As Andrew Morton
There are quite a lot of places in the kernel which will infinitely retry a
memory allocation. Generally, they get it wrong.
As a way of helping kernel code get it right, Andrew has created a patch - since merged for 2.5.69 - which adds
a new set of __GFP flags for get_free_page() and the
other memory allocation functions. These flags are:
- This flag tells the page allocater to "try harder," repeating failed
allocation attempts if need be. Allocations can still fail, but
failure should be less likely.
- Try even harder; allocations with this flag must not fail. Needless
to say, such an allocation could take a long time to satisfy.
- Failed allocations should not be retried; instead, a failure status
will be returned to the caller immediately.
These flags should make memory allocation operations a little more
predictable. There is a moral hazard here, however, that programmers will
start simply supplying __GFP_NOFAIL instead of making the extra
effort to deal with failed allocations. __GFP_NOFAIL has its
place, but, in most cases, it is probably better to be able to deal with
low-memory situations directly.
to post comments)