]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
acpi, memory-hotplug: support getting hotplug info from SRAT
authorTang Chen <tangchen@cn.fujitsu.com>
Thu, 7 Feb 2013 01:26:40 +0000 (12:26 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 18 Feb 2013 05:46:34 +0000 (16:46 +1100)
We now provide an option for users who don't want to specify physical
memory address in kernel commandline.

        /*
         * For movablemem_map=acpi:
         *
         * SRAT:                |_____| |_____| |_________| |_________| ......
         * node id:                0       1         1           2
         * hotpluggable:           n       y         y           n
         * movablemem_map:              |_____| |_________|
         *
         * Using movablemem_map, we can prevent memblock from allocating memory
         * on ZONE_MOVABLE at boot time.
         */

So user just specify movablemem_map=acpi, and the kernel will use
hotpluggable info in SRAT to determine which memory ranges should be set
as ZONE_MOVABLE.

NOTE: Using this way will cause NUMA performance down because the whole node
      will be set as ZONE_MOVABLE, and kernel cannot use memory on it.
      If users don't want to lose NUMA performance, just don't use it.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Jiang Liu <jiang.liu@huawei.com>
Cc: Jianguo Wu <wujianguo@huawei.com>
Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Wu Jianguo <wujianguo@huawei.com>
Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Len Brown <lenb@kernel.org>
Cc: "Brown, Len" <len.brown@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/kernel-parameters.txt
arch/x86/mm/srat.c
include/linux/mm.h
mm/page_alloc.c

index 2c13750031cf8ab460d5b7066060b683e7e8c58f..0b94b986a180393bdfff9964183fa5760a1ca510 100644 (file)
@@ -1644,15 +1644,28 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        that the amount of memory usable for all allocations
                        is not too small.
 
+       movablemem_map=acpi
+                       [KNL,X86,IA-64,PPC] This parameter is similar to
+                       memmap except it specifies the memory map of
+                       ZONE_MOVABLE.
+                       This option inform the kernel to use Hot Pluggable bit
+                       in flags from SRAT from ACPI BIOS to determine which
+                       memory devices could be hotplugged. The corresponding
+                       memory ranges will be set as ZONE_MOVABLE.
+
        movablemem_map=nn[KMG]@ss[KMG]
                        [KNL,X86,IA-64,PPC] This parameter is similar to
                        memmap except it specifies the memory map of
                        ZONE_MOVABLE.
-                       If more areas are all within one node, then from
-                       lowest ss to the end of the node will be ZONE_MOVABLE.
-                       If an area covers two or more nodes, the area from
-                       ss to the end of the 1st node will be ZONE_MOVABLE,
-                       and all the rest nodes will only have ZONE_MOVABLE.
+                       If user specifies memory ranges, the info in SRAT will
+                       be ingored. And it works like the following:
+                       - If more ranges are all within one node, then from
+                         lowest ss to the end of the node will be ZONE_MOVABLE.
+                       - If a range is within a node, then from ss to the end
+                         of the node will be ZONE_MOVABLE.
+                       - If a range covers two or more nodes, then from ss to
+                         the end of the 1st node will be ZONE_MOVABLE, and all
+                         the rest nodes will only have ZONE_MOVABLE.
                        If memmap is specified at the same time, the
                        movablemem_map will be limited within the memmap
                        areas. If kernelcore or movablecore is also specified,
index 3e90039e52e075f9f6bc117a1f493ea0de697209..b20b5b7ac7e18d86450efe644c123079f071c40a 100644 (file)
@@ -142,7 +142,8 @@ static inline int save_add_info(void) {return 0;}
 #endif
 
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
-static void __init handle_movablemem(int node, u64 start, u64 end)
+static void __init
+handle_movablemem(int node, u64 start, u64 end, u32 hotpluggable)
 {
        int overlap;
        unsigned long start_pfn, end_pfn;
@@ -151,7 +152,23 @@ static void __init handle_movablemem(int node, u64 start, u64 end)
        end_pfn = PFN_UP(end);
 
        /*
-        * For movablecore_map=nn[KMG]@ss[KMG]:
+        * For movablemem_map=acpi:
+        *
+        * SRAT:                |_____| |_____| |_________| |_________| ......
+        * node id:                0       1         1           2
+        * hotpluggable:           n       y         y           n
+        * movablemem_map:              |_____| |_________|
+        *
+        * Using movablemem_map, we can prevent memblock from allocating memory
+        * on ZONE_MOVABLE at boot time.
+        */
+       if (hotpluggable && movablemem_map.acpi) {
+               insert_movablemem_map(start_pfn, end_pfn);
+               goto out;
+       }
+
+       /*
+        * For movablemem_map=nn[KMG]@ss[KMG]:
         *
         * SRAT:                |_____| |_____| |_________| |_________| ......
         * node id:                0       1         1           2
@@ -160,6 +177,8 @@ static void __init handle_movablemem(int node, u64 start, u64 end)
         *
         * Using movablemem_map, we can prevent memblock from allocating memory
         * on ZONE_MOVABLE at boot time.
+        *
+        * NOTE: In this case, SRAT info will be ingored.
         */
        overlap = movablemem_map_overlap(start_pfn, end_pfn);
        if (overlap >= 0) {
@@ -187,9 +206,12 @@ static void __init handle_movablemem(int node, u64 start, u64 end)
                         */
                        insert_movablemem_map(start_pfn, end_pfn);
        }
+out:
+       return;
 }
 #else          /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
-static inline void handle_movablemem(int node, u64 start, u64 end)
+static inline void
+handle_movablemem(int node, u64 start, u64 end, u32 hotpluggable)
 {
 }
 #endif         /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
@@ -234,7 +256,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
               (unsigned long long) start, (unsigned long long) end - 1,
               hotpluggable ? "Hot Pluggable": "");
 
-       handle_movablemem(node, start, end);
+       handle_movablemem(node, start, end, hotpluggable);
 
        return 0;
 out_err_bad_srat:
index ac03db67396f114ea171911f5c5e72652da25281..a7bd9fda5a63b5115bf47994aa53c6340b6c7c9e 100644 (file)
@@ -1368,6 +1368,7 @@ struct movablemem_entry {
 };
 
 struct movablemem_map {
+       bool acpi;      /* true if using SRAT info */
        int nr_map;
        struct movablemem_entry map[MOVABLEMEM_MAP_MAX];
        nodemask_t numa_nodes_hotplug;  /* on which nodes we specify memory */
index 7511bbff45bb6f18d98246419bdc5730341733f0..ada77963e44b532960198f29a496f4401f4bfff3 100644 (file)
@@ -203,7 +203,10 @@ static unsigned long __meminitdata dma_reserve;
 
 #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
 /* Movable memory ranges, will also be used by memblock subsystem. */
-struct movablemem_map movablemem_map;
+struct movablemem_map movablemem_map = {
+       .acpi = false,
+       .nr_map = 0,
+};
 
 static unsigned long __meminitdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
 static unsigned long __meminitdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
@@ -5311,6 +5314,23 @@ static int __init cmdline_parse_movablemem_map(char *p)
        if (!p)
                goto err;
 
+       if (!strncmp(p, "acpi", max(4, strlen(p))))
+               movablemem_map.acpi = true;
+
+       /*
+        * If user decide to use info from BIOS, all the other user specified
+        * ranges will be ingored.
+        */
+       if (movablemem_map.acpi) {
+               if (movablemem_map.nr_map) {
+                       memset(movablemem_map.map, 0,
+                               sizeof(struct movablemem_entry)
+                               * movablemem_map.nr_map);
+                       movablemem_map.nr_map = 0;
+               }
+               return 0;
+       }
+
        oldp = p;
        mem_size = memparse(p, &p);
        if (p == oldp)