Re: [PATCH] Fix sparsemem on Cell (take 3)

Previous thread: [2.6 patch] SCSI seagate.c: remove SEAGATE_USE_ASM by Adrian Bunk on Friday, January 5, 2007 - 9:06 pm. (1 message)

Next thread: [2.6 patch] cleanup include/linux/reiserfs_xattr.h by Adrian Bunk on Friday, January 5, 2007 - 9:09 pm. (1 message)
To: Andrew Morton <akpm@...>
Cc: <linuxppc-dev@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, Andrew Morton <akpm@...>, <kmannth@...>, <linux-kernel@...>, <hch@...>, <linux-mm@...>, <paulus@...>, <mkravetz@...>, <gone@...>, <cbe-oss-dev@...>, John Rose <johnrose@...>, Arnd Bergmann <arnd@...>
Date: Friday, January 5, 2007 - 9:10 pm

I dropped this on the floor over Christmas. This has had a few smoke
tests on ppc64 and i386 and is ready for -mm. Against 2.6.20-rc2-mm1.

The following patch fixes an oops experienced on the Cell architecture
when init-time functions, early_*(), are called at runtime. It alters
the call paths to make sure that the callers explicitly say whether the
call is being made on behalf of a hotplug even, or happening at
boot-time.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>

---

lxc-dave/arch/s390/mm/vmem.c | 3 ++-
lxc-dave/include/linux/mm.h | 7 ++++++-
lxc-dave/include/linux/mmzone.h | 3 ++-
lxc-dave/mm/memory_hotplug.c | 6 ++++--
lxc-dave/mm/page_alloc.c | 25 +++++++++++++++++--------
5 files changed, 31 insertions(+), 13 deletions(-)

diff -puN mm/page_alloc.c~sparsemem-enum1 mm/page_alloc.c
--- lxc/mm/page_alloc.c~sparsemem-enum1 2006-12-19 09:38:34.000000000 -0800
+++ lxc-dave/mm/page_alloc.c 2006-12-19 11:18:24.000000000 -0800
@@ -2062,17 +2062,24 @@ static inline unsigned long wait_table_b
* done. Non-atomic initialization, single-pass.
*/
void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
- unsigned long start_pfn)
+ unsigned long start_pfn, enum memmap_context context)
{
struct page *page;
unsigned long end_pfn = start_pfn + size;
unsigned long pfn;

for (pfn = start_pfn; pfn < end_pfn; pfn++) {
- if (!early_pfn_valid(pfn))
- continue;
- if (!early_pfn_in_nid(pfn, nid))
- continue;
+ /*
+ * There can be holes in boot-time mem_map[]s
+ * handed to this function. They do not
+ * exist on hotplugged memory.
+ */
+ if (context == MEMMAP_EARLY) {
+ if (!early_pfn_valid(pfn))
+ continue;
+ if (!early_pfn_in_nid(pfn, nid))
+ continue;
+ }
page = pfn_to_page(pfn);
set_page_links(page, zone, nid, pfn);
init_page_count(page);
@@ -2102,7 +2109,7 @@ void zone_init_free_lists(struct pglist_

#ifndef __HAVE_ARCH_MEMMAP_INIT
#de...

To: Dave Hansen <haveblue@...>
Cc: Andrew Morton <akpm@...>, External List <linuxppc-dev@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, <kmannth@...>, lkml <linux-kernel@...>, <hch@...>, <linux-mm@...>, Paul Mackerras <paulus@...>, <mkravetz@...>, <gone@...>, <cbe-oss-dev@...>, Arnd Bergmann <arnd@...>
Date: Saturday, January 6, 2007 - 12:52 am

Could this break ia64, given that it uses memmap_init_zone()?

-

To: John Rose <johnrose@...>
Cc: Andrew Morton <akpm@...>, External List <linuxppc-dev@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, <kmannth@...>, lkml <linux-kernel@...>, <hch@...>, <linux-mm@...>, Paul Mackerras <paulus@...>, <mkravetz@...>, <gone@...>, Arnd Bergmann <arnd@...>
Date: Sunday, January 7, 2007 - 4:58 am

You are right, I think it does.

Here's an updated patch to replace the earlier one. I had to move the
enum definition over to a different header because ia64 evidently has a
different include order.

---

The following patch fixes an oops experienced on the Cell architecture
when init-time functions, early_*(), are called at runtime. It alters
the call paths to make sure that the callers explicitly say whether the
call is being made on behalf of a hotplug even, or happening at
boot-time.

It has been compile tested on ia64, s390, i386 and x86_64.

Signed-off-by: Dave Hansen <haveblue@us.ibm.com>

---

lxc-dave/arch/ia64/mm/init.c | 5 +++--
lxc-dave/arch/s390/mm/vmem.c | 3 ++-
lxc-dave/include/linux/mm.h | 3 ++-
lxc-dave/include/linux/mmzone.h | 8 ++++++--
lxc-dave/mm/memory_hotplug.c | 6 ++++--
lxc-dave/mm/page_alloc.c | 25 +++++++++++++++++--------
6 files changed, 34 insertions(+), 16 deletions(-)

diff -puN arch/s390/mm/vmem.c~Re-_PATCH_Fix_sparsemem_on_Cell arch/s390/mm/vmem.c
--- lxc/arch/s390/mm/vmem.c~Re-_PATCH_Fix_sparsemem_on_Cell 2007-01-05 15:38:23.000000000 -0800
+++ lxc-dave/arch/s390/mm/vmem.c 2007-01-07 00:47:02.000000000 -0800
@@ -61,7 +61,8 @@ void memmap_init(unsigned long size, int

if (map_start < map_end)
memmap_init_zone((unsigned long)(map_end - map_start),
- nid, zone, page_to_pfn(map_start));
+ nid, zone, page_to_pfn(map_start),
+ MEMMAP_EARLY);
}
}

diff -puN include/linux/mm.h~Re-_PATCH_Fix_sparsemem_on_Cell include/linux/mm.h
--- lxc/include/linux/mm.h~Re-_PATCH_Fix_sparsemem_on_Cell 2007-01-05 15:38:23.000000000 -0800
+++ lxc-dave/include/linux/mm.h 2007-01-06 23:57:59.000000000 -0800
@@ -979,7 +979,8 @@ extern int early_pfn_to_nid(unsigned lon
#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
extern void set_dma_reserve(unsigned long new_dma_reserve);
-extern void memmap_init_zone(unsigned long, int, unsigned...

To: Dave Hansen <haveblue@...>
Cc: John Rose <johnrose@...>, Andrew Morton <akpm@...>, External List <linuxppc-dev@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, <kmannth@...>, lkml <linux-kernel@...>, <hch@...>, <linux-mm@...>, Paul Mackerras <paulus@...>, <mkravetz@...>, <gone@...>, Arnd Bergmann <arnd@...>
Date: Monday, January 8, 2007 - 2:47 am

Boot tested OK on ia64 with this latest version of the patch.

(forgot to click plain text on gmail the first time..sorry if you got
html mail or repeat)

Tim
-

To: Dave Hansen <haveblue@...>
Cc: John Rose <johnrose@...>, Andrew Morton <akpm@...>, External List <linuxppc-dev@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, <kmannth@...>, lkml <linux-kernel@...>, <hch@...>, <linux-mm@...>, Paul Mackerras <paulus@...>, <mkravetz@...>, <gone@...>
Date: Sunday, January 7, 2007 - 8:07 am

I can't test it here, since I'm travelling at the moment, but

Acked-by: Arnd Bergmann <arndb@de.ibm.com>
-

Previous thread: [2.6 patch] SCSI seagate.c: remove SEAGATE_USE_ASM by Adrian Bunk on Friday, January 5, 2007 - 9:06 pm. (1 message)

Next thread: [2.6 patch] cleanup include/linux/reiserfs_xattr.h by Adrian Bunk on Friday, January 5, 2007 - 9:09 pm. (1 message)