[Question] How to represent SYSTEM_RAM in kerenel/resouce.c

Previous thread: [BUG] sky2 errors in 2.6.23-rc9-git1 by Ian Kumlien on Tuesday, October 2, 2007 - 8:42 pm. (15 messages)

Next thread: [PATCH] Document x86-64 iommu kernel parameters by Jeff Garzik on Tuesday, October 2, 2007 - 9:34 pm. (9 messages)
To: LKML <linux-kernel@...>
Cc: <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, Andrew Morton <akpm@...>, <pbadari@...>, linux-ia64@vger.kernel.org <linux-ia64@...>
Date: Tuesday, October 2, 2007 - 9:31 pm

Hi,

Now, SYSTEM_RAM is registerd to resouce list and a user can see memory map
from /proc/iomem, like following.
==
[kamezawa@drpq linux-2.6.23-rc8-mm2]$ grep RAM /proc/iomem
00000000-0009ffff : System RAM
00100000-03ffffff : System RAM
04000000-04f1bfff : System RAM
04f1c000-6b4b9fff : System RAM
6b4ba000-6b797fff : System RAM
6b798000-6b799fff : System RAM
6b79a000-6b79dfff : System RAM
6b79e000-6b79efff : System RAM
6b79f000-6b7fbfff : System RAM
6b7fc000-6c629fff : System RAM
6c62a000-6c800fff : System RAM
6c801000-6c843fff : System RAM
6c844000-6c847fff : System RAM
6c848000-6c849fff : System RAM
6c84a000-6c85dfff : System RAM
6c85e000-6c85efff : System RAM
6c85f000-6cbfbfff : System RAM
6cbfc000-6d349fff : System RAM
6d34a000-6d3fbfff : System RAM
6d3fc000-6d455fff : System RAM
6d4fc000-6d773fff : System RAM
100000000-7ffffffff : System RAM
4080000000-40ffffffff : System RAM
14004000000-147ffffffff : System RAM
==

But there is a confusion.

i386 and x86_64 registers System RAM as IORESOUCE_MEM | IORESOUCE_BUSY.
ia64 registers System RAM as IORESOURCE_MEM.

Which is better ?

I ask this because current memory hotplug treat memory as IORESOUCE_MEM.
When memory hot-add occurs on x86_64, new memory is added as IORESOUCE_MEM.
memory hot-remove (now) can remove only IORESOUCE_MEM.

If ia64 should treat System RAM as IORESOUCE_MEM | IORESOUCE_BUSY, I'll write
a fix.

Thanks,
-Kame

-

To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Cc: LKML <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, Andrew Morton <akpm@...>, <pbadari@...>, linux-ia64@vger.kernel.org <linux-ia64@...>
Date: Wednesday, October 3, 2007 - 12:37 pm

I think we should take system ram out of the iomem file, at least.

'struct resource' is a good, cross-platform structure to use for keeping
track of which memory we have where. So, we can share that structure to
keep track of iomem, or memory hotplug state. But, I'm not sure we
should be intermingling system RAM and iomem like we are now in the same
instance of the structure.

-- Dave

-

To: Dave Hansen <haveblue@...>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, LKML <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, Andrew Morton <akpm@...>, <pbadari@...>, linux-ia64@vger.kernel.org <linux-ia64@...>
Date: Wednesday, October 3, 2007 - 12:43 pm

Rubbish. iomem is a representation of the physical addresses in the
system as seen from the CPU's perspective. As I said in my previous
mail in this thread, if you attempt to map a device's BAR over the top
of physical RAM, things will go poorly for you.

--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
-

To: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>
Cc: LKML <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, Andrew Morton <akpm@...>, <pbadari@...>, linux-ia64@vger.kernel.org <linux-ia64@...>
Date: Tuesday, October 2, 2007 - 9:52 pm

Should probably be BUSY. Non-BUSY regions can have io resources
requested underneath them, but you wouldn't want a PCI device to be
assigned an address which overlaps with physical memory.

--
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
-

To: Matthew Wilcox <matthew@...>
Cc: LKML <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, Andrew Morton <akpm@...>, <pbadari@...>, linux-ia64@vger.kernel.org <linux-ia64@...>
Date: Wednesday, October 3, 2007 - 12:57 am

On Tue, 2 Oct 2007 19:52:42 -0600

Thank you.
It seems that I'll have to try modifing ia64 and memory hotplug in
the next -mm.

Regards,
-Kame

-

To: Andrew Morton <akpm@...>
Cc: Matthew Wilcox <matthew@...>, LKML <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, <pbadari@...>, linux-ia64@vger.kernel.org <linux-ia64@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, Dave Hansen <haveblue@...>
Date: Thursday, November 1, 2007 - 5:21 am

Hello.

I was asked from Kame-san to write this patch.

Please apply.

---------
i386 and x86-64 registers System RAM as IORESOURCE_MEM | IORESOURCE_BUSY.

But ia64 registers it as IORESOURCE_MEM only.
In addition, memory hotplug code registers new memory as IORESOURCE_MEM too.

This patch adds IORESOURCE_BUSY for them to avoid potential overlap mapping
by PCI device.

Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>

---
arch/ia64/kernel/efi.c | 6 ++----
mm/memory_hotplug.c | 2 +-
2 files changed, 3 insertions(+), 5 deletions(-)

Index: current/arch/ia64/kernel/efi.c
===================================================================
--- current.orig/arch/ia64/kernel/efi.c 2007-11-01 15:24:05.000000000 +0900
+++ current/arch/ia64/kernel/efi.c 2007-11-01 15:24:18.000000000 +0900
@@ -1111,7 +1111,7 @@ efi_initialize_iomem_resources(struct re
if (md->num_pages == 0) /* should not happen */
continue;

- flags = IORESOURCE_MEM;
+ flags = IORESOURCE_MEM | IORESOURCE_BUSY;
switch (md->type) {

case EFI_MEMORY_MAPPED_IO:
@@ -1133,12 +1133,11 @@ efi_initialize_iomem_resources(struct re

case EFI_ACPI_MEMORY_NVS:
name = "ACPI Non-volatile Storage";
- flags |= IORESOURCE_BUSY;
break;

case EFI_UNUSABLE_MEMORY:
name = "reserved";
- flags |= IORESOURCE_BUSY | IORESOURCE_DISABLED;
+ flags |= IORESOURCE_DISABLED;
break;

case EFI_RESERVED_TYPE:
@@ -1147,7 +1146,6 @@ efi_initialize_iomem_resources(struct re
case EFI_ACPI_RECLAIM_MEMORY:
default:
name = "reserved";
- flags |= IORESOURCE_BUSY;
break;
}

Index: current/mm/memory_hotplug.c
===================================================================
--- current.orig/mm/memory_hotplug.c 2007-11-01 15:24:16.000000000 +0900
+++ current/mm/memory_hotplug.c 2007-11-01 15:41:27.000000000 +0900
@@ -39,7 +39,7 @@ static struct resource *register_memory_
res->name = "System RAM";
res->start = start;...

To: Yasunori Goto <y-goto@...>
Cc: Andrew Morton <akpm@...>, Matthew Wilcox <matthew@...>, lkml <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, linux-ia64@vger.kernel.org <linux-ia64@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, Dave Hansen <haveblue@...>
Date: Thursday, November 1, 2007 - 12:28 pm

Not quite.. You need following patch on top of this to make
hotplug memory remove work on ia64/x86-64.

Thanks,
Badari

Once you mark memory resource BUSY, walk_memory_resource() won't be able
to find it.

Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
---
kernel/resource.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.24-rc1/kernel/resource.c
===================================================================
--- linux-2.6.24-rc1.orig/kernel/resource.c 2007-10-23 20:50:57.000000000 -0700
+++ linux-2.6.24-rc1/kernel/resource.c 2007-11-01 08:19:59.000000000 -0700
@@ -277,7 +277,7 @@ walk_memory_resource(unsigned long start
int ret = -1;
res.start = (u64) start_pfn << PAGE_SHIFT;
res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1;
- res.flags = IORESOURCE_MEM;
+ res.flags = IORESOURCE_MEM | IORESOURCE_BUSY;
orig_end = res.end;
while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) {
pfn = (unsigned long)(res.start >> PAGE_SHIFT);

-

To: Andrew Morton <akpm@...>
Cc: Matthew Wilcox <matthew@...>, lkml <linux-kernel@...>, <andi@...>, linux-mm@kvack.org <linux-mm@...>, tony.luck@intel.com <tony.luck@...>, linux-ia64@vger.kernel.org <linux-ia64@...>, KAMEZAWA Hiroyuki <kamezawa.hiroyu@...>, Dave Hansen <haveblue@...>, Badari Pulavarty <pbadari@...>
Date: Monday, November 5, 2007 - 10:23 pm

Hello.

I merged Baradi-san's patch and mine. This and Kame-san's
following patch is necessary for x86-64 memory unplug.

http://marc.info/?l=linux-mm&m=119399026017901&w=2

I heard Kame-san's patch is already included in -mm.
So, I'll repost merged patch now.

This patch is tested on 2.6.23-mm1.

Please apply.

---

i386 and x86-64 registers System RAM as IORESOURCE_MEM | IORESOURCE_BUSY.

But ia64 registers it as IORESOURCE_MEM only.
In addition, memory hotplug code registers new memory as IORESOURCE_MEM too.

This difference causes a failure of memory unplug of x86-64.
This patch fix it.

This patch adds IORESOURCE_BUSY to avoid potential overlap mapping
by PCI device.

Signed-off-by: Yasunori Goto <y-goto@jp.fujitsu.com>
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>

---
arch/ia64/kernel/efi.c | 6 ++----
kernel/resource.c | 2 +-
mm/memory_hotplug.c | 2 +-
3 files changed, 4 insertions(+), 6 deletions(-)

Index: current/arch/ia64/kernel/efi.c
===================================================================
--- current.orig/arch/ia64/kernel/efi.c 2007-11-02 17:17:30.000000000 +0900
+++ current/arch/ia64/kernel/efi.c 2007-11-02 17:19:10.000000000 +0900
@@ -1111,7 +1111,7 @@ efi_initialize_iomem_resources(struct re
if (md->num_pages == 0) /* should not happen */
continue;

- flags = IORESOURCE_MEM;
+ flags = IORESOURCE_MEM | IORESOURCE_BUSY;
switch (md->type) {

case EFI_MEMORY_MAPPED_IO:
@@ -1133,12 +1133,11 @@ efi_initialize_iomem_resources(struct re

case EFI_ACPI_MEMORY_NVS:
name = "ACPI Non-volatile Storage";
- flags |= IORESOURCE_BUSY;
break;

case EFI_UNUSABLE_MEMORY:
name = "reserved";
- flags |= IORESOURCE_BUSY | IORESOURCE_DISABLED;
+ flags |= IORESOURCE_DISABLED;
break;

case EFI_RESERVED_TYPE:
@@ -1147,7 +1146,6 @@ efi_initialize_iomem_resources(struct re
case EFI_ACPI_RECLAIM_MEMORY:
default:
name = "r...

Previous thread: [BUG] sky2 errors in 2.6.23-rc9-git1 by Ian Kumlien on Tuesday, October 2, 2007 - 8:42 pm. (15 messages)

Next thread: [PATCH] Document x86-64 iommu kernel parameters by Jeff Garzik on Tuesday, October 2, 2007 - 9:34 pm. (9 messages)