lkml.org 
[lkml]   [2006]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 10/10] hot-add-mem x86_64: valid add range check
    From: Keith Mannthey <kmannth@us.ibm.com>

    Introduce and implement valid_add_memory_range to MEMORY_HOTPLUG. The
    RESERVE path needs to be careful about check to make sure it only onlines
    correct memory. The SPASRMEM path is using resource code to do this so
    it gets a no-op check. This frame work makes it was to add specific checks
    for valid add memory ranges as the need arises.

    Signed-off-by: Keith Mannthey<kmannth@us.ibm.com>
    ---
    arch/x86_64/mm/srat.c | 6 ++++++
    include/linux/memory_hotplug.h | 2 +-
    mm/memory_hotplug.c | 8 ++++++++
    3 files changed, 15 insertions(+), 1 deletion(-)

    diff -urN orig/arch/x86_64/mm/srat.c current/arch/x86_64/mm/srat.c
    --- orig/arch/x86_64/mm/srat.c 2006-08-04 06:56:24.000000000 -0400
    +++ current/arch/x86_64/mm/srat.c 2006-08-04 03:39:29.000000000 -0400
    @@ -203,6 +203,12 @@
    {
    return hotadd_percent > 0;
    }
    +
    +inline int valid_add_memory_range(int nid, u64 start, u64 size) {
    + if (nodes_add[nid].start <= start && nodes_add[nid].end >= (start+size))
    + return 1;
    + return 0;
    +}
    #else
    int update_end_of_memory(unsigned long end) {return 0;}
    static int hotadd_enough_memory(struct bootnode *nd) {return 1;}
    diff -urN orig/include/linux/memory_hotplug.h current/include/linux/memory_hotplug.h
    --- orig/include/linux/memory_hotplug.h 2006-08-04 06:56:24.000000000 -0400
    +++ current/include/linux/memory_hotplug.h 2006-08-04 02:08:45.000000000 -0400
    @@ -159,7 +159,7 @@
    dump_stack();
    return -ENOSYS;
    }
    -
    +extern int valid_add_memory_range(int nid, u64 start, u64 size);
    #endif /* ! CONFIG_MEMORY_HOTPLUG */
    static inline int __remove_pages(struct zone *zone, unsigned long start_pfn,
    unsigned long nr_pages)
    diff -urN orig/mm/memory_hotplug.c current/mm/memory_hotplug.c
    --- orig/mm/memory_hotplug.c 2006-08-04 06:59:05.000000000 -0400
    +++ current/mm/memory_hotplug.c 2006-08-04 03:08:23.000000000 -0400
    @@ -220,6 +220,11 @@
    vm_total_pages = nr_free_pagecache_pages();
    return 0;
    }
    +
    +inline int valid_add_memory_range(int nid, u64 start, u64 size) {
    + return 1;
    +}
    +
    #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */

    static pg_data_t *hotadd_new_pgdat(int nid, u64 start)
    @@ -257,6 +262,9 @@
    int new_pgdat = 0;
    struct resource *res;
    int ret;
    +
    + if (!valid_add_memory_range(nid,start,size))
    + return -EINVAL;

    res = register_memory_resource(start, size);
    if (!res)
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2006-08-04 15:19    [W:0.024 / U:62.528 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site