diff options
| author | Andrew Morton <akpm@digeo.com> | 2003-04-20 00:28:12 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-04-20 00:28:12 -0700 |
| commit | 75908778d91e92ca3c9ed587c4550866f4c903fc (patch) | |
| tree | 41ab8b3306f8eb23429dd250ef262ed37dc0634f /include/linux | |
| parent | efbb77b282f9173b4c183aa8ae30772bcb5e580f (diff) | |
[PATCH] implement __GFP_REPEAT, __GFP_NOFAIL, __GFP_NORETRY
This is a cleanup patch.
There are quite a lot of places in the kernel which will infinitely retry a
memory allocation.
Generally, they get it wrong. Some do yield(), the semantics of which have
changed over time. Some do schedule(), which can lock up if the caller is
SCHED_FIFO/RR. Some do schedule_timeout(), etc.
And often it is unnecessary, because the page allocator will do the retry
internally anyway. But we cannot rely on that - this behaviour may change
(-aa and -rmap kernels do not do this, for instance).
So it is good to formalise and to centralise this operation. If an
allocation specifies __GFP_REPEAT then the page allocator must infinitely
retry the allocation.
The semantics of __GFP_REPEAT are "try harder". The allocation _may_ fail
(the 2.4 -aa and -rmap VM's do not retry infinitely by default).
The semantics of __GFP_NOFAIL are "cannot fail". It is a no-op in this VM,
but needs to be honoured (or fix up the callers) if the VM ischanged to not
retry infinitely by default.
The semantics of __GFP_NOREPEAT are "try once, don't loop". This isn't used
at present (although perhaps it should be, in swapoff). It is mainly for
completeness.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/gfp.h | 15 | ||||
| -rw-r--r-- | include/linux/slab.h | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/include/linux/gfp.h b/include/linux/gfp.h index c475f7b41e59..ade6d9e97475 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -11,13 +11,26 @@ #define __GFP_DMA 0x01 #define __GFP_HIGHMEM 0x02 -/* Action modifiers - doesn't change the zoning */ +/* + * Action modifiers - doesn't change the zoning + * + * __GFP_REPEAT: Try hard to allocate the memory, but the allocation attempt + * _might_ fail. This depends upon the particular VM implementation. + * + * __GFP_NOFAIL: The VM implementation _must_ retry infinitely: the caller + * cannot handle allocation failures. + * + * __GFP_NORETRY: The VM implementation must not retry indefinitely. + */ #define __GFP_WAIT 0x10 /* Can wait and reschedule? */ #define __GFP_HIGH 0x20 /* Should access emergency pools? */ #define __GFP_IO 0x40 /* Can start physical IO? */ #define __GFP_FS 0x80 /* Can call down to low-level FS? */ #define __GFP_COLD 0x100 /* Cache-cold page required */ #define __GFP_NOWARN 0x200 /* Suppress page allocation failure warning */ +#define __GFP_REPEAT 0x400 /* Retry the allocation. Might fail */ +#define __GFP_NOFAIL 0x800 /* Retry for ever. Cannot fail */ +#define __GFP_NORETRY 0x1000 /* Do not retry. Might fail */ #define GFP_ATOMIC (__GFP_HIGH) #define GFP_NOIO (__GFP_WAIT) diff --git a/include/linux/slab.h b/include/linux/slab.h index bdc5256de12a..603748b9b349 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -22,7 +22,7 @@ typedef struct kmem_cache_s kmem_cache_t; #define SLAB_KERNEL GFP_KERNEL #define SLAB_DMA GFP_DMA -#define SLAB_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|__GFP_COLD|__GFP_NOWARN) +#define SLAB_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|__GFP_COLD|__GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|__GFP_NORETRY) #define SLAB_NO_GROW 0x00001000UL /* don't grow a cache */ /* flags to pass to kmem_cache_create(). |
