• D
    mm/memory_hotplug: set node_start_pfn of hotadded pgdat to 0 · 64f827bf
    David Hildenbrand 提交于
    task #29077503
    commit c68ab18c6aee0397574afb418f6775f23379198e upstream
    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: NDavid Hildenbrand <david@redhat.com>
    Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
    Acked-by: NPankaj 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: NLinus Torvalds <torvalds@linux-foundation.org>
    (cherry picked from ccommit c68ab18c6aee0397574afb418f6775f23379198e)
    Signed-off-by: NAlex Shi <alex.shi@linux.alibaba.com>
    Reviewed-by: NXunlei Pang <xlpang@linux.alibaba.com>
    64f827bf
memory_hotplug.c 52.3 KB