2006-02-09 07:07:57

by Yasunori Goto

[permalink] [raw]
Subject: [RFC:PATCH(003/003)] Memory add to onlined node. (ver. 2) (For x86_64)

This is for x86_64 to add memory which belongs onlined node.

Signed-off-by: Yasunori Goto <[email protected]>

Index: node_simple3/arch/x86_64/mm/init.c
===================================================================
--- node_simple3.orig/arch/x86_64/mm/init.c 2006-02-09 12:01:47.000000000 +0900
+++ node_simple3/arch/x86_64/mm/init.c 2006-02-09 14:09:11.000000000 +0900
@@ -26,6 +26,7 @@
#include <linux/dma-mapping.h>
#include <linux/module.h>
#include <linux/memory_hotplug.h>
+#include <linux/acpi.h>

#include <asm/processor.h>
#include <asm/system.h>
@@ -494,11 +495,20 @@ void online_page(struct page *page)

int add_memory(u64 start, u64 size)
{
- struct pglist_data *pgdat = NODE_DATA(0);
- struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2;
+ struct pglist_data *pgdat;
+ struct zone *zone;
unsigned long start_pfn = start >> PAGE_SHIFT;
unsigned long nr_pages = size >> PAGE_SHIFT;
- int ret;
+ int ret, node;
+
+ node = acpi_paddr_to_node(start, size);
+ if (node >= 0 && node_online(node))
+ pgdat = NODE_DATA(node);
+ else
+ /* New node's memory will be added to Node 0 temporally. */
+ pgdat = NODE_DATA(0);
+
+ zone = pgdat->node_zones + MAX_NR_ZONES - 2;

ret = __add_pages(zone, start_pfn, nr_pages);
if (ret)

--
Yasunori Goto



2006-02-09 09:52:07

by Yasunori Goto

[permalink] [raw]
Subject: Re: [RFC:PATCH(003/003)] Memory add to onlined node. (ver. 2) (For x86_64)


BTW, I have 2 question about x86_64's memory hot-add.

Q1)
> int add_memory(u64 start, u64 size)
> {
> - struct pglist_data *pgdat = NODE_DATA(0);
> - struct zone *zone = pgdat->node_zones + MAX_NR_ZONES-2;

Current code adds memory to ZONE_NORMAL like this.
But, ZONE_DMA32 is available on 2.6.15. So, I'm afraid there are
2 types trouble.

a) When new memory is added to < 4GB, this should be added to
Zone_DMA32.
Are there any real machine which allow to add memory under
4GB?
b) If machine boots up with under 4GB memory, and new memory
is added to over 4GB, then kernel might panic due to Zone Normal's
initialization is imcomplete.

Q2)
Are there any real machine which can add memory with NUMA feature?
Or will be there?
In my patch, I assume that DSDT is defined well for NUMA by firmware.
(Container device, Memory device...).
But, if firmware doesn't define it, my patch is nonsense..
(Oh, I'm silly.....)


--
Yasunori Goto


2006-02-09 10:42:13

by Andi Kleen

[permalink] [raw]
Subject: Re: [discuss] Re: [RFC:PATCH(003/003)] Memory add to onlined node. (ver. 2) (For x86_64)

On Thursday 09 February 2006 10:50, Yasunori Goto wrote:

> Current code adds memory to ZONE_NORMAL like this.
> But, ZONE_DMA32 is available on 2.6.15. So, I'm afraid there are
> 2 types trouble.
>
> a) When new memory is added to < 4GB, this should be added to
> Zone_DMA32.
> Are there any real machine which allow to add memory under
> 4GB?

x86-64 machines usually use a continuous memory map
because Windows gets unhappy with too big memory holes (and even
Linux is not completely troublefree for UP install kernels) And for a small
system this implies memory < 4GB.

> b) If machine boots up with under 4GB memory, and new memory
> is added to over 4GB, then kernel might panic due to Zone Normal's
> initialization is imcomplete.
>
> Q2)
> Are there any real machine which can add memory with NUMA feature?

There are and will be.

-Andi

2006-02-09 10:57:42

by Yasunori Goto

[permalink] [raw]
Subject: Re: [discuss] Re: [RFC:PATCH(003/003)] Memory add to onlined node. (ver. 2) (For x86_64)

> On Thursday 09 February 2006 10:50, Yasunori Goto wrote:
>
> > Current code adds memory to ZONE_NORMAL like this.
> > But, ZONE_DMA32 is available on 2.6.15. So, I'm afraid there are
> > 2 types trouble.
> >
> > a) When new memory is added to < 4GB, this should be added to
> > Zone_DMA32.
> > Are there any real machine which allow to add memory under
> > 4GB?
>
> x86-64 machines usually use a continuous memory map
> because Windows gets unhappy with too big memory holes (and even
> Linux is not completely troublefree for UP install kernels) And for a small
> system this implies memory < 4GB.

Ah, Ok. Then, it is bug. :-P

>
> > b) If machine boots up with under 4GB memory, and new memory
> > is added to over 4GB, then kernel might panic due to Zone Normal's
> > initialization is imcomplete.
> >
> > Q2)
> > Are there any real machine which can add memory with NUMA feature?
>
> There are and will be.

I see. I'll continue my job with x86_64 too. :-)

Thanks.

--
Yasunori Goto