Thread (15 messages) 15 messages, 3 authors, 2013-01-09

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

From: Kamezawa Hiroyuki <hidden>
Date: 2012-12-26 02:16:42
Also in: linux-fsdevel

(2012/12/19 23:01), Glauber Costa wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
CC: Christoph Lameter <redacted>
CC: David Rientjes <rientjes@google.com>
CC: Pekka Enberg <redacted>
CC: Andrew Morton <akpm@linux-foundation.org>
CC: Mel Gorman <mgorman@suse.de>
---
  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@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help