Re: [PATCH 3/3] sl[auo]b: retry allocation once in case of failure.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



(2012/12/19 23:01), Glauber Costa wrote:
> When we are out of space in the caches, we will try to allocate a new
> page.  If we still fail, the page allocator will try to free pages
> through direct reclaim. Which means that if an object allocation failed
> we can be sure that no new pages could be given to us, even though
> direct reclaim was likely invoked.
> 
> However, direct reclaim will also try to shrink objects from registered
> shrinkers. They won't necessarily free a full page, but if our cache
> happens to be one with a shrinker, this may very well open up the space
> we need. So we retry the allocation in this case.
> 
> We can't know for sure if this happened. So the best we can do is try to
> derive from our allocation flags how likely it is for direct reclaim to
> have been called, and retry if we conclude that this is highly likely
> (GFP_NOWAIT | GFP_FS | !GFP_NORETRY).
> 
> The common case is for the allocation to succeed. So we carefuly insert
> a likely branch for that case.
> 
> Signed-off-by: Glauber Costa <glommer@xxxxxxxxxxxxx>
> CC: Christoph Lameter <cl@xxxxxxxxx>
> CC: David Rientjes <rientjes@xxxxxxxxxx>
> CC: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
> CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> CC: Mel Gorman <mgorman@xxxxxxx>
> ---
>   mm/slab.c |  2 ++
>   mm/slab.h | 42 ++++++++++++++++++++++++++++++++++++++++++
>   mm/slob.c | 27 +++++++++++++++++++++++----
>   mm/slub.c | 26 ++++++++++++++++++++------
>   4 files changed, 87 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index a98295f..7e82f99 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -3535,6 +3535,8 @@ slab_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid,
>   	cache_alloc_debugcheck_before(cachep, flags);
>   	local_irq_save(save_flags);
>   	objp = __do_slab_alloc_node(cachep, flags, nodeid);
> +	if (slab_should_retry(objp, flags))
> +		objp = __do_slab_alloc_node(cachep, flags, nodeid);

3 questions. 

1. why can't we do retry in memcg's code (or kmem/memcg code) rather than slab.c ?
2. It should be retries even if memory allocator returns NULL page ?
3. What's relationship with oom-killer ? The first __do_slab_alloc() will not
   invoke oom-killer and returns NULL ?

Thanks,
-Kame




--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]