The patch titled

     x86_64: fix numa node sizing in nr_free_zone_pages()

has been added to the -mm tree.  Its filename is

     x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

x86-compress-the-stack-layout-of-do_page_fault-fix.patch
x86-x86_64-deferred-handling-of-writes-to-proc-irq-xx-smp_affinitypatch-added-to-mm-tree.patch
x86-64-ptrace-ia32-bp-fix.patch
x86_64-print-processor-number-in-show_regs.patch
x86_64-prefetchw-can-fall-back-to-prefetch-if-3dnow.patch
x86_64-create-sysfs-entries-for-cpu-only-for-present-cpus.patch
x86_64dont-call-enforce_max_cpus-when-hotplug-is-enabled.patch
x86_64fix-cluster-mode-send_ipi_allbutself-to-use-get_cpu-put_cpu.patch
x86_64dont-do-broadcast-ipis-when-hotplug-is-enabled-in-flat-mode.patch
x86_64dont-use-lowest-priority-when-using-physical-mode.patch
x86_64use-common-functions-in-cluster-and-physflat-mode.patch
x86_64-choose-physflat-for-amd-systems-only-when-8-cpus.patch
x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak.patch
unify-x86-x86-64-semaphore-code.patch
isa-dma-suspend-for-x86_64-2.patch



From: Andi Kleen <[EMAIL PROTECTED]>

Cc: "Martin J. Bligh" <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 arch/x86_64/kernel/e820.c |   36 ++++++++++++++++++++++++++++++++++++
 arch/x86_64/mm/init.c     |   16 ++++++++++++----
 arch/x86_64/mm/numa.c     |    8 +++++++-
 include/asm-x86_64/e820.h |    2 ++
 4 files changed, 57 insertions(+), 5 deletions(-)

diff -puN 
arch/x86_64/kernel/e820.c~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak 
arch/x86_64/kernel/e820.c
--- 
devel/arch/x86_64/kernel/e820.c~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak
        2005-08-22 22:55:01.000000000 -0700
+++ devel-akpm/arch/x86_64/kernel/e820.c        2005-08-22 22:55:01.000000000 
-0700
@@ -185,6 +185,42 @@ unsigned long __init e820_end_of_ram(voi
 }
 
 /* 
+ * Compute how much memory is missing in a range.
+ * Unlike the other functions in this file the arguments and return
+ * value is in PFNs.
+ */
+unsigned long __init
+e820_hole_size(unsigned long start_pfn, unsigned long end_pfn)
+{
+       unsigned long ram = 0;
+       unsigned long start = start_pfn << PAGE_SHIFT;
+       unsigned long end = end_pfn << PAGE_SHIFT;
+       int i;
+       for (i = 0; i < e820.nr_map; i++) {
+               struct e820entry *ei = &e820.map[i];
+               unsigned long last, addr;
+
+               if (ei->type != E820_RAM ||
+                   ei->addr+ei->size <= start ||
+                   ei->addr >= end)
+                       continue;
+
+               addr = round_up(ei->addr, PAGE_SIZE);
+               if (addr < start)
+                       addr = start;
+
+               last = round_down(ei->addr + ei->size, PAGE_SIZE);
+               if (last >= end)
+                       last = end;
+
+               if (last > addr && last-addr >= PAGE_SIZE)
+                       ram += last - addr;
+       }
+       return ((end - start) - ram) >> PAGE_SHIFT;
+}
+
+
+/*
  * Mark e820 reserved areas as busy for the resource manager.
  */
 void __init e820_reserve_resources(void)
diff -puN 
arch/x86_64/mm/init.c~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak 
arch/x86_64/mm/init.c
--- 
devel/arch/x86_64/mm/init.c~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak
    2005-08-22 22:55:01.000000000 -0700
+++ devel-akpm/arch/x86_64/mm/init.c    2005-08-22 22:55:01.000000000 -0700
@@ -322,18 +322,26 @@ void zap_low_mappings(void)
 void __init paging_init(void)
 {
        {
-               unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0};
+               unsigned long zones_size[MAX_NR_ZONES];
+               unsigned long holes[MAX_NR_ZONES];
                unsigned int max_dma;
 
+               memset(zones_size, 0, sizeof(zones_size));
+               memset(holes, 0, sizeof(holes));
+
                max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
 
-               if (end_pfn < max_dma)
+               if (end_pfn < max_dma) {
                        zones_size[ZONE_DMA] = end_pfn;
-               else {
+                       holes[ZONE_DMA] = e820_hole_size(0, end_pfn);
+               } else {
                        zones_size[ZONE_DMA] = max_dma;
+                       holes[ZONE_DMA] = e820_hole_size(0, max_dma);
                        zones_size[ZONE_NORMAL] = end_pfn - max_dma;
+                       holes[ZONE_NORMAL] = e820_hole_size(max_dma, end_pfn);
                }
-               free_area_init(zones_size);
+               free_area_init_node(0, NODE_DATA(0), zones_size,
+                        __pa(PAGE_OFFSET) >> PAGE_SHIFT, holes);
        }
        return;
 }
diff -puN 
arch/x86_64/mm/numa.c~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak 
arch/x86_64/mm/numa.c
--- 
devel/arch/x86_64/mm/numa.c~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak
    2005-08-22 22:55:01.000000000 -0700
+++ devel-akpm/arch/x86_64/mm/numa.c    2005-08-22 22:55:01.000000000 -0700
@@ -126,9 +126,11 @@ void __init setup_node_zones(int nodeid)
 { 
        unsigned long start_pfn, end_pfn; 
        unsigned long zones[MAX_NR_ZONES];
+       unsigned long holes[MAX_NR_ZONES];
        unsigned long dma_end_pfn;
 
        memset(zones, 0, sizeof(unsigned long) * MAX_NR_ZONES); 
+       memset(nodes, 0, sizeof(unsigned long) * MAX_NR_ZONES);
 
        start_pfn = node_start_pfn(nodeid);
        end_pfn = node_end_pfn(nodeid);
@@ -139,13 +141,17 @@ void __init setup_node_zones(int nodeid)
        dma_end_pfn = __pa(MAX_DMA_ADDRESS) >> PAGE_SHIFT; 
        if (start_pfn < dma_end_pfn) { 
                zones[ZONE_DMA] = dma_end_pfn - start_pfn;
+               holes[ZONE_DMA] = e820_hole_size(start_pfn, dma_end_pfn);
                zones[ZONE_NORMAL] = end_pfn - dma_end_pfn; 
+               holes[ZONE_NORMAL] = e820_hole_size(dma_end_pfn, end_pfn);
+
        } else { 
                zones[ZONE_NORMAL] = end_pfn - start_pfn; 
+               holes[ZONE_NORMAL] = e820_hole_size(start_pfn, end_pfn);
        } 
     
        free_area_init_node(nodeid, NODE_DATA(nodeid), zones,
-                           start_pfn, NULL); 
+                           start_pfn, holes);
 } 
 
 void __init numa_init_array(void)
diff -puN 
include/asm-x86_64/e820.h~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak 
include/asm-x86_64/e820.h
--- 
devel/include/asm-x86_64/e820.h~x86_64-fix-numa-node-sizing-in-nr_free_zone_pages-ak
        2005-08-22 22:55:01.000000000 -0700
+++ devel-akpm/include/asm-x86_64/e820.h        2005-08-22 22:55:01.000000000 
-0700
@@ -51,6 +51,8 @@ extern int e820_mapped(unsigned long sta
 
 extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned 
long end);
 extern void e820_setup_gap(void);
+extern unsigned long e820_hole_size(unsigned long start_pfn,
+                                   unsigned long end_pfn);
 
 extern void __init parse_memopt(char *p, char **end);
 
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to