From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>, Li Zefan <lizf@cn.fujitsu.com>,
Paul Menage <menage@google.com>,
Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>,
linux-mm@kvack.org, mel@csn.ul.ie
Subject: Re: [memcg BUG] unable to handle kernel NULL pointer derefence at 00000000
Date: Tue, 21 Oct 2008 19:04:57 +0530 [thread overview]
Message-ID: <48FDDA81.5040606@linux.vnet.ibm.com> (raw)
In-Reply-To: <20081021220927.97df17fa.kamezawa.hiroyu@jp.fujitsu.com>
KAMEZAWA Hiroyuki wrote:
> On Tue, 21 Oct 2008 17:44:40 +0530
> Balbir Singh <balbir@linux.vnet.ibm.com> wrote:
>>> I got an idea and maybe can send a patch soon. I'm now finding x86-32 box..
>> Please send it to me, I am able to reproduce the problem with my kvm setup on my
>> 32 bit system. I can do a quick test/verification for you.
>>
> Thanks. how about this ? test on x86-64 is done.
> -Kame
> ==
>
>
>
> page_cgroup_init() is called from mem_cgroup_init(). But at this
> point, we cannot call alloc_bootmem().
> (and this caused panic at boot.)
>
> This patch moves page_cgroup_init() to init/main.c.
>
> Time table is following:
> ==
> parse_args(). # we can trust mem_cgroup_subsys.disabled bit after this.
> ....
> cgroup_init_early() # "early" init of cgroup.
> ....
> setup_arch() # memmap is allocated.
> ...
> page_cgroup_init();
> mem_init(); # we cannot call alloc_bootmem after this.
> ....
> cgroup_init() # mem_cgroup is initialized.
> ==
>
> Before page_cgroup_init(), mem_map must be initialized. So,
> I added page_cgroup_init() to init/main.c directly.
>
> (*) maybe this is not very clean but cgroup_init_early() is too early
> and we have to use vmalloc instead of alloc_bootmem() in cgroup_init().
> usage of vmalloc area in x86-32 is important and we should avoid
> vmalloc() in x86-32. So, we want to use alloc_bootmem() from
> sutaible place.
>
> Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>
> include/linux/page_cgroup.h | 1 +
> init/main.c | 2 ++
> mm/memcontrol.c | 1 -
> mm/page_cgroup.c | 35 ++++++++++++++++++++++++++++-------
> 4 files changed, 31 insertions(+), 8 deletions(-)
>
> Index: linux-2.6/init/main.c
> ===================================================================
> --- linux-2.6.orig/init/main.c
> +++ linux-2.6/init/main.c
> @@ -62,6 +62,7 @@
> #include <linux/signal.h>
> #include <linux/idr.h>
> #include <linux/ftrace.h>
> +#include <linux/page_cgroup.h>
>
> #include <asm/io.h>
> #include <asm/bugs.h>
> @@ -647,6 +648,7 @@ asmlinkage void __init start_kernel(void
> vmalloc_init();
> vfs_caches_init_early();
> cpuset_init_early();
> + page_cgroup_init();
> mem_init();
> enable_debug_pagealloc();
> cpu_hotplug_init();
> Index: linux-2.6/mm/memcontrol.c
> ===================================================================
> --- linux-2.6.orig/mm/memcontrol.c
> +++ linux-2.6/mm/memcontrol.c
> @@ -1088,7 +1088,6 @@ mem_cgroup_create(struct cgroup_subsys *
> int node;
>
> if (unlikely((cont->parent) == NULL)) {
> - page_cgroup_init();
> mem = &init_mem_cgroup;
> } else {
> mem = mem_cgroup_alloc();
> Index: linux-2.6/include/linux/page_cgroup.h
> ===================================================================
> --- linux-2.6.orig/include/linux/page_cgroup.h
> +++ linux-2.6/include/linux/page_cgroup.h
> @@ -3,6 +3,7 @@
>
> #ifdef CONFIG_CGROUP_MEM_RES_CTLR
> #include <linux/bit_spinlock.h>
> +
> /*
> * Page Cgroup can be considered as an extended mem_map.
> * A page_cgroup page is associated with every page descriptor. The
> Index: linux-2.6/mm/page_cgroup.c
> ===================================================================
> --- linux-2.6.orig/mm/page_cgroup.c
> +++ linux-2.6/mm/page_cgroup.c
> @@ -4,7 +4,12 @@
> #include <linux/bit_spinlock.h>
> #include <linux/page_cgroup.h>
> #include <linux/hash.h>
> +#include <linux/slab.h>
> #include <linux/memory.h>
> +#include <linux/cgroup.h>
> +
> +extern struct cgroup_subsys mem_cgroup_subsys;
> +
>
> static void __meminit
> __init_page_cgroup(struct page_cgroup *pc, unsigned long pfn)
> @@ -66,6 +71,9 @@ void __init page_cgroup_init(void)
>
> int nid, fail;
>
> + if (mem_cgroup_subsys.disabled)
> + return;
> +
> for_each_online_node(nid) {
> fail = alloc_node_page_cgroup(nid);
> if (fail)
> @@ -106,9 +114,14 @@ int __meminit init_section_page_cgroup(u
> nid = page_to_nid(pfn_to_page(pfn));
>
> table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
> - base = kmalloc_node(table_size, GFP_KERNEL, nid);
> - if (!base)
> - base = vmalloc_node(table_size, nid);
> + if (slab_is_available()) {
> + base = kmalloc_node(table_size, GFP_KERNEL, nid);
> + if (!base)
> + base = vmalloc_node(table_size, nid);
> + } else {
> + base = __alloc_bootmem_node_nopanic(NODE_DATA(nid), table_size,
> + PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
> + }
>
> if (!base) {
> printk(KERN_ERR "page cgroup allocation failure\n");
> @@ -135,11 +148,16 @@ void __free_page_cgroup(unsigned long pf
> if (!ms || !ms->page_cgroup)
> return;
> base = ms->page_cgroup + pfn;
> - ms->page_cgroup = NULL;
> - if (is_vmalloc_addr(base))
> + if (is_vmalloc_addr(base)) {
> vfree(base);
> - else
> - kfree(base);
> + ms->page_cgroup = NULL;
> + } else {
> + struct page *page = virt_to_page(base);
> + if (!PageReserved(page)) { /* Is bootmem ? */
> + kfree(base);
> + ms->page_cgroup = NULL;
> + }
> + }
> }
>
> int online_page_cgroup(unsigned long start_pfn,
> @@ -213,6 +231,9 @@ void __init page_cgroup_init(void)
> unsigned long pfn;
> int fail = 0;
>
> + if (mem_cgroup_subsys.disabled)
> + return;
> +
> for (pfn = 0; !fail && pfn < max_pfn; pfn += PAGES_PER_SECTION) {
> if (!pfn_present(pfn))
> continue;
Booted on x86_32 for me
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Tested-by: Balbir Singh <balbir@linux.vnet.ibm.com>
--
Balbir
--
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:[~2008-10-21 13:34 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-17 10:48 [RFC][PATCH -mm 0/5] mem+swap resource controller(trial patch) Daisuke Nishimura
2008-10-17 10:56 ` [PATCH -mm 1/5] memcg: replace res_counter Daisuke Nishimura
2008-10-20 19:53 ` Paul Menage
2008-10-21 1:14 ` KAMEZAWA Hiroyuki
2008-10-21 1:29 ` Paul Menage
2008-10-21 1:49 ` KAMEZAWA Hiroyuki
2008-10-21 2:15 ` Paul Menage
2008-10-21 2:50 ` KAMEZAWA Hiroyuki
2008-10-21 2:20 ` Paul Menage
2008-10-21 3:03 ` KAMEZAWA Hiroyuki
2008-10-21 6:30 ` Paul Menage
2008-10-21 5:30 ` Balbir Singh
2008-10-21 5:39 ` KAMEZAWA Hiroyuki
2008-10-21 6:20 ` [memcg BUG] unable to handle kernel NULL pointer derefence at 00000000 Li Zefan
2008-10-21 6:25 ` KAMEZAWA Hiroyuki
2008-10-21 6:28 ` Li Zefan
2008-10-21 6:38 ` Daisuke Nishimura
2008-10-21 6:54 ` KAMEZAWA Hiroyuki
2008-10-21 7:04 ` Li Zefan
2008-10-21 7:16 ` KAMEZAWA Hiroyuki
2008-10-21 7:21 ` Li Zefan
2008-10-21 8:18 ` KAMEZAWA Hiroyuki
2008-10-21 8:34 ` Mel Gorman
2008-10-21 8:38 ` KAMEZAWA Hiroyuki
2008-10-21 8:35 ` Li Zefan
2008-10-21 8:36 ` KAMEZAWA Hiroyuki
2008-10-21 8:57 ` KAMEZAWA Hiroyuki
2008-10-21 9:13 ` Li Zefan
2008-10-21 9:25 ` KAMEZAWA Hiroyuki
2008-10-21 9:54 ` Li Zefan
2008-10-21 10:14 ` KAMEZAWA Hiroyuki
2008-10-21 10:57 ` Li Zefan
2008-10-21 11:00 ` KAMEZAWA Hiroyuki
2008-10-21 11:09 ` KAMEZAWA Hiroyuki
2008-10-21 11:13 ` KAMEZAWA Hiroyuki
2008-10-21 11:19 ` Ingo Molnar
2008-10-21 11:23 ` KAMEZAWA Hiroyuki
2008-10-21 11:28 ` Ingo Molnar
2008-10-21 11:32 ` KAMEZAWA Hiroyuki
2008-10-21 11:38 ` Ingo Molnar
2008-10-22 2:13 ` Daisuke Nishimura
2008-10-22 2:31 ` KAMEZAWA Hiroyuki
2008-10-21 11:29 ` Balbir Singh
2008-10-21 11:34 ` KAMEZAWA Hiroyuki
2008-10-21 12:00 ` KAMEZAWA Hiroyuki
2008-10-21 12:14 ` Balbir Singh
2008-10-21 13:09 ` KAMEZAWA Hiroyuki
2008-10-21 13:25 ` Balbir Singh
2008-10-21 13:34 ` Balbir Singh [this message]
2008-10-21 13:44 ` [memcg BUG] unable to handle kernel NULL pointer derefence at00000000 亀澤 寛之
2008-10-21 10:58 ` [memcg BUG] unable to handle kernel NULL pointer derefence at 00000000 Balbir Singh
2008-10-21 9:33 ` Daisuke Nishimura
2008-10-21 9:41 ` KAMEZAWA Hiroyuki
2008-10-21 10:15 ` Daisuke Nishimura
2008-10-17 10:59 ` [PATCH -mm 2/5] memcg: mem_cgroup private ID Daisuke Nishimura
2008-10-17 11:01 ` [PATCH -mm 3/5] memcg: mem+swap controller Kconfig Daisuke Nishimura, KAMEZAWA Hiroyuki
2008-10-17 11:04 ` [PATCH -mm 4/5] memcg: mem+swap counter Daisuke Nishimura
2008-10-17 11:06 ` [PATCH -mm 5/5] memcg: mem+swap accounting Daisuke Nishimura
2008-10-20 0:24 ` [RFC][PATCH -mm 0/5] mem+swap resource controller(trial patch) KAMEZAWA Hiroyuki
2008-10-20 2:53 ` Daisuke Nishimura
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=48FDDA81.5040606@linux.vnet.ibm.com \
--to=balbir@linux.vnet.ibm.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lizf@cn.fujitsu.com \
--cc=mel@csn.ul.ie \
--cc=menage@google.com \
--cc=mingo@elte.hu \
--cc=nishimura@mxp.nes.nec.co.jp \
/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.