From: Vladimir Davydov <vdavydov@parallels.com>
To: Christoph Lameter <cl@linux.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, devel@openvz.org,
Greg Thelen <gthelen@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Michal Hocko <mhocko@suse.cz>, Glauber Costa <glommer@gmail.com>,
Pekka Enberg <penberg@kernel.org>
Subject: Re: [PATCH -mm v2.2] mm: get rid of __GFP_KMEMCG
Date: Fri, 11 Apr 2014 21:33:08 +0400 [thread overview]
Message-ID: <53482754.1090102@parallels.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1404111104550.13278@nuc>
On 04/11/2014 08:07 PM, Christoph Lameter wrote:
> On Thu, 3 Apr 2014, Vladimir Davydov wrote:
>
>> --- a/include/linux/slab.h
>> +++ b/include/linux/slab.h
>> @@ -358,16 +358,7 @@ kmem_cache_alloc_node_trace(struct kmem_cache *s,
>> #include <linux/slub_def.h>
>> #endif
>>
>> -static __always_inline void *
>> -kmalloc_order(size_t size, gfp_t flags, unsigned int order)
>> -{
>> - void *ret;
>> -
>> - flags |= (__GFP_COMP | __GFP_KMEMCG);
>> - ret = (void *) __get_free_pages(flags, order);
>> - kmemleak_alloc(ret, size, 1, flags);
>> - return ret;
>> -}
>> +extern void *kmalloc_order(size_t size, gfp_t flags, unsigned int order);
>
> Hmmm... This was intentional inlined to allow inline expansion for calls
> to kmalloc with large constants. The inline expansion directly converts
> these calls to page allocator calls avoiding slab overhead.
I moved kmalloc_order() to slab_common.c, because I can't call
alloc_kmem_pages() directly from the header (we don't have
page_address() defined there, and including mm.h to slab.h wouldn't be
good I think), and I don't want to introduce __get_free_kmem_pages().
Sorry that I didn't state this explicitly in the comment to the patch.
However, would it be any better if I introduced __get_free_kmem_pages()
and called it from kmalloc_order(), which could be inlined then? I don't
think so, because I would have to place __get_free_kmem_pages() in
page_alloc.c just like __get_free_pages() (again, because including mm.h
to gfp.h for page_address() isn't an option), and we would get exactly
the same number of function calls.
I admit that this patch adds one extra function call to large kmallocs:
- before: __get_free_pages -> alloc_pages
- after: kmalloc_order -> alloc_kmem_pages -> alloc_pages
but that's not because I move kmalloc_order from the header, but rather
because I introduce alloc_kmem_pages, which is not inline.
What can we do to eliminate it? We could place alloc_kmem_pages()
definition to a header file, but since it needs memcontrol.h for kmemcg
charging functions, that would lead to slab.h depending on memcontrol.h
eventually, which is not good IMO.
Alternatively, we could
#ifndef MEMCG_KMEM
# define alloc_kmem_pages alloc_pages
#endif
so that we would avoid any additional overhead if kmemcg is compiled out.
However, do we need to bother about one function call at all? My point
is that one function call can be neglected in case of large kmem
allocations, which are rather rare.
Any thoughts/objections?
Thanks.
--
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>
prev parent reply other threads:[~2014-04-11 17:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 7:38 [PATCH -mm v2 0/2] cleanup kmemcg charging (was: "kmemcg: get rid of __GFP_KMEMCG") Vladimir Davydov
2014-04-01 7:38 ` [PATCH -mm v2 1/2] sl[au]b: charge slabs to kmemcg explicitly Vladimir Davydov
2014-04-02 0:49 ` Greg Thelen
2014-04-01 7:38 ` [PATCH -mm v2 2/2] mm: get rid of __GFP_KMEMCG Vladimir Davydov
2014-04-02 0:48 ` Greg Thelen
2014-04-02 6:11 ` Vladimir Davydov
2014-04-02 6:16 ` [PATCH -mm v2.1] " Vladimir Davydov
2014-04-02 21:25 ` Greg Thelen
2014-04-03 15:04 ` Vladimir Davydov
2014-04-03 15:05 ` [PATCH -mm v2.2] " Vladimir Davydov
2014-04-10 23:38 ` Andrew Morton
2014-04-11 12:52 ` [PATCH -mm] slab: document kmalloc_order Vladimir Davydov
2014-04-11 15:57 ` Christoph Lameter
2014-04-11 17:24 ` Vladimir Davydov
2014-04-11 16:07 ` [PATCH -mm v2.2] mm: get rid of __GFP_KMEMCG Christoph Lameter
2014-04-11 17:33 ` Vladimir Davydov [this message]
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=53482754.1090102@parallels.com \
--to=vdavydov@parallels.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux.com \
--cc=devel@openvz.org \
--cc=glommer@gmail.com \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.cz \
--cc=penberg@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox