• Pavel Tatashin's avatar
    mm: calculate deferred pages after skipping mirrored memory · d3035be4
    Pavel Tatashin authored
    update_defer_init() should be called only when struct page is about to be
    initialized. Because it counts number of initialized struct pages, but
    there we may skip struct pages if there is some mirrored memory.
    
    So move, update_defer_init() after checking for mirrored memory.
    
    Also, rename update_defer_init() to defer_init() and reverse the return
    boolean to emphasize that this is a boolean function, that tells that the
    reset of memmap initialization should be deferred.
    
    Make this function self-contained: do not pass number of already
    initialized pages in this zone by using static counters.
    
    I found this bug by reading the code.  The effect is that fewer than
    expected struct pages are initialized early in boot, and it is possible
    that in some corner cases we may fail to boot when mirrored pages are
    used.  The deferred on demand code should somewhat mitigate this.  But
    this still brings some inconsistencies compared to when booting without
    mirrored pages, so it is better to fix.
    
    [pasha.tatashin@oracle.com: add comment about defer_init's lack of locking]
      Link: http://lkml.kernel.org/r/20180726193509.3326-3-pasha.tatashin@oracle.com
    [akpm@linux-foundation.org: make defer_init non-inline, __meminit]
    Link: http://lkml.kernel.org/r/20180724235520.10200-3-pasha.tatashin@oracle.comSigned-off-by: default avatarPavel Tatashin <pasha.tatashin@oracle.com>
    Reviewed-by: default avatarOscar Salvador <osalvador@suse.de>
    Cc: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
    Cc: Baoquan He <bhe@redhat.com>
    Cc: Daniel Jordan <daniel.m.jordan@oracle.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: Dave Hansen <dave.hansen@intel.com>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Jan Kara <jack@suse.cz>
    Cc: Jérôme Glisse <jglisse@redhat.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Souptick Joarder <jrdr.linux@gmail.com>
    Cc: Steven Sistare <steven.sistare@oracle.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Wei Yang <richard.weiyang@gmail.com>
    Cc: Pasha Tatashin <Pavel.Tatashin@microsoft.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    d3035be4
page_alloc.c 225 KB