Skip to contentSkip to conversation

init: call vfs_caches_init_early() later in the boot sequence

PATCH In review Pekka Enberg 4 participants 12 messages May 28, 2009 – Jun 2, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 init: call vfs_caches_init_early() later in the boot sequence

From: Pekka Enberg <[email protected]>

There's no need to call vfs_caches_init_early() before kmem_cache_init(). All we have to do is make sure we don't attempt to use the bootmem allocator after we've called mem_init().

Cc Christoph Lameter <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Matt Mackall <[email protected]>
Cc Nick Piggin <[email protected]>
Cc Yinghai Lu <[email protected]>
---
 fs/dcache.c |    2 +-
 fs/inode.c  |    2 +-
 init/main.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
fs/dcache.c +1 -1
index ee60ce4..6c48ba1 100644
@@ -2255,7 +2255,7 @@ static void __init dcache_init_early(void)
 					sizeof(struct hlist_head),
 					dhash_entries,
 					13,
-					HASH_EARLY,
+					0,
 					&d_hash_shift,
 					&d_hash_mask,
 					0);
fs/inode.c +1 -1
index 0571983..92379c8 100644
@@ -1487,7 +1487,7 @@ void __init inode_init_early(void)
 					sizeof(struct hlist_head),
 					ihash_entries,
 					14,
-					HASH_EARLY,
+					0,
 					&i_hash_shift,
 					&i_hash_mask,
 					0);
init/main.c +1 -1
index 5a19578..f6bd51f 100644
@@ -588,7 +588,6 @@ asmlinkage void __init start_kernel(void)
 	 * kmem_cache_init()
 	 */
 	pidhash_init();
-	vfs_caches_init_early();
 	/*
 	 * Set up kernel memory allocators
 	 */
@@ -658,6 +657,7 @@ asmlinkage void __init start_kernel(void)
 		initrd_start = 0;
 	}
 #endif
+	vfs_caches_init_early();
 	cpuset_init_early();
 	page_cgroup_init();
 	enable_debug_pagealloc();
Signature · 1 line
1.6.0.4
#1 lore raw

Subject: [PATCH] slab: remove bootmem calling

mem_init/kmem_cache_init is moved up

---
 mm/page_cgroup.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
mm/page_cgroup.c +8 -4
Index: linux-2.6/mm/page_cgroup.c
===================================================================
@@ -47,6 +47,8 @@ static int __init alloc_node_page_cgroup
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	unsigned long start_pfn, nr_pages, index;
+	struct page *page;
+	unsigned int order;
 
 	start_pfn = NODE_DATA(nid)->node_start_pfn;
 	nr_pages = NODE_DATA(nid)->node_spanned_pages;
@@ -55,11 +57,13 @@ static int __init alloc_node_page_cgroup
 		return 0;
 
 	table_size = sizeof(struct page_cgroup) * nr_pages;
-
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
-	if (!base)
+	order = get_order(table_size);
+	page = alloc_pages_node(nid, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
+		page = alloc_pages_node(-1, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
 		return -ENOMEM;
+	base = page_address(page);
 	for (index = 0; index < nr_pages; index++) {
 		pc = base + index;
 		__init_page_cgroup(pc, start_pfn + index);
#2 lore raw

Re: Subject: [PATCH] slab: remove bootmem calling

Quoted 1 line · Yinghai Lu

mem_init/kmem_cache_init is moved up

Is there a way we could start documenting/improving these dependencies of bootup stuff? A comment with depends/provides lines?

Quoted 37 lines
---
 mm/page_cgroup.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-2.6/mm/page_cgroup.c
===================================================================

mm/page_cgroup.c +8 -4
@@ -47,6 +47,8 @@ static int __init alloc_node_page_cgroup
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	unsigned long start_pfn, nr_pages, index;
+	struct page *page;
+	unsigned int order;
 
 	start_pfn = NODE_DATA(nid)->node_start_pfn;
 	nr_pages = NODE_DATA(nid)->node_spanned_pages;
@@ -55,11 +57,13 @@ static int __init alloc_node_page_cgroup
 		return 0;
 
 	table_size = sizeof(struct page_cgroup) * nr_pages;
-
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
-	if (!base)
+	order = get_order(table_size);
+	page = alloc_pages_node(nid, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
+		page = alloc_pages_node(-1, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
 		return -ENOMEM;
+	base = page_address(page);
 	for (index = 0; index < nr_pages; index++) {
 		pc = base + index;
 		__init_page_cgroup(pc, start_pfn + index);
#3 lore raw

PATCH 1/1 slab: remove bootmem calling

In reply to Pekka Enberg

mem_init/kmem_cache_init is moved up

---
 mm/page_cgroup.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
mm/page_cgroup.c +8 -4
Index: linux-2.6/mm/page_cgroup.c
===================================================================
@@ -47,6 +47,8 @@ static int __init alloc_node_page_cgroup
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	unsigned long start_pfn, nr_pages, index;
+	struct page *page;
+	unsigned int order;
 
 	start_pfn = NODE_DATA(nid)->node_start_pfn;
 	nr_pages = NODE_DATA(nid)->node_spanned_pages;
@@ -55,11 +57,13 @@ static int __init alloc_node_page_cgroup
 		return 0;
 
 	table_size = sizeof(struct page_cgroup) * nr_pages;
-
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
-	if (!base)
+	order = get_order(table_size);
+	page = alloc_pages_node(nid, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
+		page = alloc_pages_node(-1, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
 		return -ENOMEM;
+	base = page_address(page);
 	for (index = 0; index < nr_pages; index++) {
 		pc = base + index;
 		__init_page_cgroup(pc, start_pfn + index);
#4 lore raw

PATCH 1/1 slab: remove bootmem calling

In reply to Pekka Enberg

mem_init/kmem_cache_init is moved up

---
 mm/page_cgroup.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
mm/page_cgroup.c +8 -4
Index: linux-2.6/mm/page_cgroup.c
===================================================================
@@ -47,6 +47,8 @@ static int __init alloc_node_page_cgroup
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	unsigned long start_pfn, nr_pages, index;
+	struct page *page;
+	unsigned int order;
 
 	start_pfn = NODE_DATA(nid)->node_start_pfn;
 	nr_pages = NODE_DATA(nid)->node_spanned_pages;
@@ -55,11 +57,13 @@ static int __init alloc_node_page_cgroup
 		return 0;
 
 	table_size = sizeof(struct page_cgroup) * nr_pages;
-
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
-	if (!base)
+	order = get_order(table_size);
+	page = alloc_pages_node(nid, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
+		page = alloc_pages_node(-1, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
 		return -ENOMEM;
+	base = page_address(page);
 	for (index = 0; index < nr_pages; index++) {
 		pc = base + index;
 		__init_page_cgroup(pc, start_pfn + index);
#5 lore raw

Re: [PATCH] slab: remove bootmem calling

Quoted 25 lines · Yinghai Lu

mem_init/kmem_cache_init is moved up

---
 mm/page_cgroup.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-2.6/mm/page_cgroup.c
===================================================================

mm/page_cgroup.c +2 -1
@@ -47,6 +47,8 @@ static int __init alloc_node_page_cgroup
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	unsigned long start_pfn, nr_pages, index;
+	struct page *page;
+	unsigned int order;
 
 	start_pfn = NODE_DATA(nid)->node_start_pfn;
 	nr_pages = NODE_DATA(nid)->node_spanned_pages;
@@ -55,11 +57,13 @@ static int __init alloc_node_page_cgroup
 		return 0;
 
 	table_size = sizeof(struct page_cgroup) * nr_pages;
-

mm/page_cgroup.c static int __init alloc_node_page_cgroup · line 66

Quoted 10 lines
mm/page_cgroup.c +6 -3
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
-	if (!base)
+	order = get_order(table_size);
+	page = alloc_pages_node(nid, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
+		page = alloc_pages_node(-1, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
 		return -ENOMEM;
+	base = page_address(page);

any good way to replace __alloc_bootmem_node that could take alignment?

YH

#6 lore raw

Re: [PATCH] slab: remove bootmem calling

Quoted 24 lines · Yinghai Lu
Quoted 23 lines · Yinghai Lu

mem_init/kmem_cache_init is moved up

---
 mm/page_cgroup.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Index: linux-2.6/mm/page_cgroup.c
===================================================================

mm/page_cgroup.c +2 -0
@@ -47,6 +47,8 @@ static int __init alloc_node_page_cgroup
 	struct page_cgroup *base, *pc;
 	unsigned long table_size;
 	unsigned long start_pfn, nr_pages, index;
+	struct page *page;
+	unsigned int order;
 
 	start_pfn = NODE_DATA(nid)->node_start_pfn;
 	nr_pages = NODE_DATA(nid)->node_spanned_pages;
@@ -55,11 +57,13 @@ static int __init alloc_node_page_cgroup
 		return 0;
 
Quoted 14 lines

mm/page_cgroup.c static int __init alloc_node_page_cgroup · line 66

Quoted 12 lines
mm/page_cgroup.c +6 -4
 	table_size = sizeof(struct page_cgroup) * nr_pages;
-
-	base = __alloc_bootmem_node_nopanic(NODE_DATA(nid),
-			table_size, PAGE_SIZE, __pa(MAX_DMA_ADDRESS));
-	if (!base)
+	order = get_order(table_size);
+	page = alloc_pages_node(nid, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
+		page = alloc_pages_node(-1, GFP_NOWAIT | __GFP_ZERO, order);
+	if (!page)
 		return -ENOMEM;
+	base = page_address(page);

any good way to replace __alloc_bootmem_node that could take alignment?

Not that I am aware of. Where do you need that? This one looks ok to me as page allocator obviously returns PAGE_SIZE aligned chunks.

Pekka

#7 lore raw

Re: [PATCH] slab: remove bootmem calling

Quoted 2 lines · Pekka Enberg

Not that I am aware of. Where do you need that? This one looks ok to me as page allocator obviously returns PAGE_SIZE aligned chunks.

The page allocator returns PAGE_SIZE << order aligned chunks. This should be ok.

#8 lore raw

Re: [PATCH] slab: remove bootmem calling

In reply to Yinghai Lu

Hi Yinghai,

Quoted 3 lines · Yinghai Lu

mem_init/kmem_cache_init is moved up

Thanks!

I cleaned up the changelogs a bit and applied in 'topic/slab/earlyboot' branch in my tree:

http://git.kernel.org/?p=linux/kernel/git/penberg/slab-2.6.git;a=shortlog;h=topic/slab/earlyboot

I expect Ingo to pick up these changes at some point and we can move the development of this patch series to -tip. But for now, please send patches against my tree.

Pekka

#9 lore raw
In reply to Pekka Enberg
Quoted 5 lines · Pekka Enberg

From: Pekka Enberg <[email protected]>

There's no need to call vfs_caches_init_early() before kmem_cache_init(). All we have to do is make sure we don't attempt to use the bootmem allocator after we've called mem_init().

Hmm, but you'd want to be able to allocate > MAX_ORDER areas in the linear KVA, which the page allocator cannot do. So this is just going to silently truncate hash table size. Nack on this one.

Quoted 62 lines
Cc Christoph Lameter <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Matt Mackall <[email protected]>
Cc Nick Piggin <[email protected]>
Cc Yinghai Lu <[email protected]>
---
 fs/dcache.c |    2 +-
 fs/inode.c  |    2 +-
 init/main.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
fs/dcache.c +1 -1
index ee60ce4..6c48ba1 100644
@@ -2255,7 +2255,7 @@ static void __init dcache_init_early(void)
 					sizeof(struct hlist_head),
 					dhash_entries,
 					13,
-					HASH_EARLY,
+					0,
 					&d_hash_shift,
 					&d_hash_mask,
 					0);
fs/inode.c +1 -1
index 0571983..92379c8 100644
@@ -1487,7 +1487,7 @@ void __init inode_init_early(void)
 					sizeof(struct hlist_head),
 					ihash_entries,
 					14,
-					HASH_EARLY,
+					0,
 					&i_hash_shift,
 					&i_hash_mask,
 					0);
init/main.c +1 -1
index 5a19578..f6bd51f 100644
@@ -588,7 +588,6 @@ asmlinkage void __init start_kernel(void)
 	 * kmem_cache_init()
 	 */
 	pidhash_init();
-	vfs_caches_init_early();
 	/*
 	 * Set up kernel memory allocators
 	 */
@@ -658,6 +657,7 @@ asmlinkage void __init start_kernel(void)
 		initrd_start = 0;
 	}
 #endif
+	vfs_caches_init_early();
 	cpuset_init_early();
 	page_cgroup_init();
 	enable_debug_pagealloc();
Signature · 1 line
1.6.0.4
#10 lore raw

Hi Nick,

[ I see I typo'd Linus' email address in the original patch submission... ]

Quoted 5 lines · Pekka Enberg
Quoted 5 lines

From: Pekka Enberg <[email protected]>

There's no need to call vfs_caches_init_early() before kmem_cache_init(). All we have to do is make sure we don't attempt to use the bootmem allocator after we've called mem_init().

Quoted 3 lines · Nick Piggin

Hmm, but you'd want to be able to allocate > MAX_ORDER areas in the linear KVA, which the page allocator cannot do. So this is just going to silently truncate hash table size. Nack on this one.

OK, makes sense. IIRC, Linus suggested doing this but I think I'll just revert the patch.

Pekka

#11 lore raw
Quoted 11 lines · Pekka Enberg

Hi Nick,

[ I see I typo'd Linus' email address in the original patch submission... ]

Quoted 5 lines · Pekka Enberg
Quoted 5 lines

From: Pekka Enberg <[email protected]>

There's no need to call vfs_caches_init_early() before kmem_cache_init(). All we have to do is make sure we don't attempt to use the bootmem allocator after we've called mem_init().

Quoted 7 lines
Quoted 3 lines · Nick Piggin

Hmm, but you'd want to be able to allocate > MAX_ORDER areas in the linear KVA, which the page allocator cannot do. So this is just going to silently truncate hash table size. Nack on this one.

OK, makes sense. IIRC, Linus suggested doing this but I think I'll just revert the patch.

What might be interesting to do is to be able to switch the bootmem allocator to be able to run after the page allocator comes up (it would have to have a few hooks to put pages on and off the buddy lists, but should be possible). Then you could do these kinds of large allocations later (or set up allocators earlier).

But that might not be worth the complexity and churn just for these couple of cases...