From: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Glauber Costa <glommer@parallels.com>
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
Mel Gorman <mgorman@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Dave Shrinnker <david@fromorbit.com>,
Michal Hocko <mhocko@suse.cz>, Pekka Enberg <penberg@kernel.org>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Pekka Enberg <penberg@cs.helsinki.fi>
Subject: Re: [PATCH 3/3] sl[auo]b: retry allocation once in case of failure.
Date: Wed, 26 Dec 2012 11:16:03 +0900 [thread overview]
Message-ID: <50DA5DE3.9060809@jp.fujitsu.com> (raw)
In-Reply-To: <1355925702-7537-4-git-send-email-glommer@parallels.com>
(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@parallels.com>
> CC: Christoph Lameter <cl@linux.com>
> CC: David Rientjes <rientjes@google.com>
> CC: Pekka Enberg <penberg@cs.helsinki.fi>
> 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
WARNING: multiple messages have this Message-ID (diff)
From: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Glauber Costa <glommer@parallels.com>
Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
Mel Gorman <mgorman@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Dave Shrinnker <david@fromorbit.com>,
Michal Hocko <mhocko@suse.cz>, Pekka Enberg <penberg@kernel.org>,
Christoph Lameter <cl@linux.com>,
David Rientjes <rientjes@google.com>,
Pekka Enberg <penberg@cs.helsinki.fi>
Subject: Re: [PATCH 3/3] sl[auo]b: retry allocation once in case of failure.
Date: Wed, 26 Dec 2012 11:16:03 +0900 [thread overview]
Message-ID: <50DA5DE3.9060809@jp.fujitsu.com> (raw)
In-Reply-To: <1355925702-7537-4-git-send-email-glommer@parallels.com>
(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@parallels.com>
> CC: Christoph Lameter <cl@linux.com>
> CC: David Rientjes <rientjes@google.com>
> CC: Pekka Enberg <penberg@cs.helsinki.fi>
> 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>
next prev parent reply other threads:[~2012-12-26 2:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-19 14:01 [PATCH 0/3] retry slab allocation after first failure Glauber Costa
2012-12-19 14:01 ` Glauber Costa
2012-12-19 14:01 ` [PATCH 1/3] slab: single entry-point for slab allocation Glauber Costa
2012-12-19 14:01 ` Glauber Costa
2012-12-19 14:01 ` [PATCH 2/3] slub: remove slab_alloc wrapper Glauber Costa
2012-12-19 14:01 ` Glauber Costa
2013-01-02 16:03 ` Christoph Lameter
2012-12-19 14:01 ` [PATCH 3/3] sl[auo]b: retry allocation once in case of failure Glauber Costa
2012-12-19 14:01 ` Glauber Costa
2012-12-26 2:16 ` Kamezawa Hiroyuki [this message]
2012-12-26 2:16 ` Kamezawa Hiroyuki
2012-12-26 7:55 ` Glauber Costa
2012-12-26 7:55 ` Glauber Costa
2013-01-02 16:10 ` Christoph Lameter
2013-01-09 10:25 ` Glauber Costa
2013-01-09 10:25 ` Glauber Costa
2013-01-02 16:32 ` [PATCH 0/3] retry slab allocation after first failure Christoph Lameter
2013-01-02 16:32 ` Christoph Lameter
2013-01-09 10:22 ` Glauber Costa
2013-01-09 10:22 ` Glauber Costa
2013-01-09 15:38 ` Christoph Lameter
2013-01-09 15:38 ` Christoph Lameter
2013-01-09 15:59 ` Glauber Costa
2013-01-09 15:59 ` Glauber Costa
2013-01-09 18:59 ` Christoph Lameter
2013-01-02 16:33 ` Christoph Lameter
2013-01-02 16:33 ` Christoph Lameter
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=50DA5DE3.9060809@jp.fujitsu.com \
--to=kamezawa.hiroyu@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=david@fromorbit.com \
--cc=glommer@parallels.com \
--cc=hannes@cmpxchg.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=penberg@cs.helsinki.fi \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.