• David Hildenbrand's avatar
    mm/memory_hotplug: set node_start_pfn of hotadded pgdat to 0 · c68ab18c
    David Hildenbrand authored
    Patch series "mm/memory_hotplug: handle memblocks only with
    CONFIG_ARCH_KEEP_MEMBLOCK", v1.
    
    A hotadded node/pgdat will span no pages at all, until memory is moved to
    the zone/node via move_pfn_range_to_zone() -> resize_pgdat_range - e.g.,
    when onlining memory blocks.  We don't have to initialize the
    node_start_pfn to the memory we are adding.
    
    This patch (of 2):
    
    Especially, there is an inconsistency:
     - Hotplugging memory to a memory-less node with cpus: node_start_pf ==  0
     - Offlining and removing last memory from a node: node_start_pfn == 0
     - Hotplugging memory to a memory-less node without cpus: node_start_pfn != 0
    
    As soon as memory is onlined, node_start_pfn is overwritten with the
    actual start.  E.g., when adding two DIMMs but only onlining one of both,
    only that DIMM (with online memory blocks) is spanned by the node.
    
    Currently, the validity of node_start_pfn really is linked to
    node_spanned_pages != 0.  With node_spanned_pages == 0 (e.g., before
    onlining memory), it has no meaning.
    
    So let's stop setting node_start_pfn, just to be overwritten via
    move_pfn_range_to_zone().  This avoids confusion when looking at the code,
    wondering which magic will be performed with the node_start_pfn in this
    function, when hotadding a pgdat.
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Acked-by: default avatarPankaj Gupta <pankaj.gupta.linux@gmail.com>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Baoquan He <bhe@redhat.com>
    Cc: Oscar Salvador <osalvador@suse.de>
    Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
    Cc: Anshuman Khandual <anshuman.khandual@arm.com>
    Cc: Mike Rapoport <rppt@linux.ibm.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Link: http://lkml.kernel.org/r/20200422155353.25381-1-david@redhat.com
    Link: http://lkml.kernel.org/r/20200422155353.25381-2-david@redhat.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    c68ab18c
memory_hotplug.c 45.1 KB