* + page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch added to -mm tree
@ 2011-03-09 0:35 akpm
2011-03-22 9:24 ` Johannes Weiner
0 siblings, 1 reply; 3+ messages in thread
From: akpm @ 2011-03-09 0:35 UTC (permalink / raw)
To: mm-commits; +Cc: mhocko, balbir, dave, kamezawa.hiroyu
The patch titled
page_cgroup: reduce allocation overhead for page_cgroup array for CONFIG_SPARSEMEM
has been added to the -mm tree. Its filename is
page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: page_cgroup: reduce allocation overhead for page_cgroup array for CONFIG_SPARSEMEM
From: Michal Hocko <mhocko@suse.cz>
Currently we are allocating a single page_cgroup array per memory section
(stored in mem_section->base) when CONFIG_SPARSEMEM is selected. This is
correct but memory inefficient solution because the allocated memory
(unless we fall back to vmalloc) is not kmalloc friendly:
- 32b - 16384 entries (20B per entry) fit into 327680B so the
524288B slab cache is used
- 32b with PAE - 131072 entries with 2621440B fit into 4194304B
- 64b - 32768 entries (40B per entry) fit into 2097152 cache
This is ~37% wasted space per memory section and it sumps up for the whole
memory. On a x86_64 machine it is something like 6MB per 1GB of RAM.
We can reduce the internal fragmentation by using alloc_pages_exact which
allocates PAGE_SIZE aligned blocks so we will get down to <4kB wasted
memory per section which is much better.
We still need a fallback to vmalloc because we have no guarantees that we
will have a continuous memory of that size (order-10) later on during the
hotplug events.
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/page_cgroup.c | 56 +++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 22 deletions(-)
diff -puN mm/page_cgroup.c~page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem mm/page_cgroup.c
--- a/mm/page_cgroup.c~page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem
+++ a/mm/page_cgroup.c
@@ -130,7 +130,36 @@ struct page *lookup_cgroup_page(struct p
return page;
}
-/* __alloc_bootmem...() is protected by !slab_available() */
+static void *__init_refok alloc_page_cgroup(size_t size, int nid)
+{
+ void *addr = NULL;
+
+ addr = alloc_pages_exact(size, GFP_KERNEL | __GFP_NOWARN);
+ if (addr)
+ return addr;
+
+ if (node_state(nid, N_HIGH_MEMORY))
+ addr = vmalloc_node(size, nid);
+ else
+ addr = vmalloc(size);
+
+ return addr;
+}
+
+static void free_page_cgroup(void *addr)
+{
+ if (is_vmalloc_addr(addr)) {
+ vfree(addr);
+ } else {
+ struct page *page = virt_to_page(addr);
+ if (!PageReserved(page)) { /* Is bootmem ? */
+ size_t table_size =
+ sizeof(struct page_cgroup) * PAGES_PER_SECTION;
+ free_pages_exact(addr, table_size);
+ }
+ }
+}
+
static int __init_refok init_section_page_cgroup(unsigned long pfn)
{
struct page_cgroup *base, *pc;
@@ -147,17 +176,8 @@ static int __init_refok init_section_pag
nid = page_to_nid(pfn_to_page(pfn));
table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
- VM_BUG_ON(!slab_is_available());
- if (node_state(nid, N_HIGH_MEMORY)) {
- base = kmalloc_node(table_size,
- GFP_KERNEL | __GFP_NOWARN, nid);
- if (!base)
- base = vmalloc_node(table_size, nid);
- } else {
- base = kmalloc(table_size, GFP_KERNEL | __GFP_NOWARN);
- if (!base)
- base = vmalloc(table_size);
- }
+ base = alloc_page_cgroup(table_size, nid);
+
/*
* The value stored in section->page_cgroup is (base - pfn)
* and it does not point to the memory block allocated above,
@@ -189,16 +209,8 @@ void __free_page_cgroup(unsigned long pf
if (!ms || !ms->page_cgroup)
return;
base = ms->page_cgroup + pfn;
- if (is_vmalloc_addr(base)) {
- vfree(base);
- ms->page_cgroup = NULL;
- } else {
- struct page *page = virt_to_page(base);
- if (!PageReserved(page)) { /* Is bootmem ? */
- kfree(base);
- ms->page_cgroup = NULL;
- }
- }
+ free_page_cgroup(base);
+ ms->page_cgroup = NULL;
}
int __meminit online_page_cgroup(unsigned long start_pfn,
_
Patches currently in -mm which might be from mhocko@suse.cz are
memsw-remove-noswapaccount-kernel-parameter.patch
page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: + page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch added to -mm tree
2011-03-09 0:35 + page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch added to -mm tree akpm
@ 2011-03-22 9:24 ` Johannes Weiner
2011-03-22 9:27 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Weiner @ 2011-03-22 9:24 UTC (permalink / raw)
To: akpm; +Cc: mhocko, balbir, dave, kamezawa.hiroyu, linux-mm
From: Johannes Weiner <hannes@cmpxchg.org>
Subject: [patch] mm: do not define unused free_page_cgroup without memory hotplug
Without memory hotplug configured in, the page cgroup array is never
actually freed again:
mm/page_cgroup.c:149:13: warning: a??free_page_cgroupa?? defined but not used
Wrap the definition in ifdefs. Rather than moving it into an existing
ifdef section, to keep it close to its allocation counterpart.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
mm/page_cgroup.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 885b2ac..a12cc3f 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -146,6 +146,7 @@ static void *__init_refok alloc_page_cgroup(size_t size, int nid)
return addr;
}
+#ifdef CONFIG_MEMORY_HOTPLUG
static void free_page_cgroup(void *addr)
{
if (is_vmalloc_addr(addr)) {
@@ -159,6 +160,7 @@ static void free_page_cgroup(void *addr)
free_pages_exact(addr, table_size);
}
}
+#endif
static int __init_refok init_section_page_cgroup(unsigned long pfn)
{
--
1.7.4
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: + page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch added to -mm tree
2011-03-22 9:24 ` Johannes Weiner
@ 2011-03-22 9:27 ` Michal Hocko
0 siblings, 0 replies; 3+ messages in thread
From: Michal Hocko @ 2011-03-22 9:27 UTC (permalink / raw)
To: Johannes Weiner; +Cc: akpm, balbir, dave, kamezawa.hiroyu, linux-mm
On Tue 22-03-11 10:24:21, Johannes Weiner wrote:
> From: Johannes Weiner <hannes@cmpxchg.org>
> Subject: [patch] mm: do not define unused free_page_cgroup without memory hotplug
>
> Without memory hotplug configured in, the page cgroup array is never
> actually freed again:
>
> mm/page_cgroup.c:149:13: warning: ???free_page_cgroup??? defined but not used
>
> Wrap the definition in ifdefs. Rather than moving it into an existing
> ifdef section, to keep it close to its allocation counterpart.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Makes perfect sense. Thanks!
Ackedy-by: Michal Hocko <mhocko@suse.cz>
> ---
> mm/page_cgroup.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
> index 885b2ac..a12cc3f 100644
> --- a/mm/page_cgroup.c
> +++ b/mm/page_cgroup.c
> @@ -146,6 +146,7 @@ static void *__init_refok alloc_page_cgroup(size_t size, int nid)
> return addr;
> }
>
> +#ifdef CONFIG_MEMORY_HOTPLUG
> static void free_page_cgroup(void *addr)
> {
> if (is_vmalloc_addr(addr)) {
> @@ -159,6 +160,7 @@ static void free_page_cgroup(void *addr)
> free_pages_exact(addr, table_size);
> }
> }
> +#endif
>
> static int __init_refok init_section_page_cgroup(unsigned long pfn)
> {
> --
> 1.7.4
--
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9
Czech Republic
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-22 9:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-09 0:35 + page_cgroup-reduce-allocation-overhead-for-page_cgroup-array-for-config_sparsemem.patch added to -mm tree akpm
2011-03-22 9:24 ` Johannes Weiner
2011-03-22 9:27 ` Michal Hocko
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.