Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • mm
  • Kconfig
Find file BlameHistoryPermalink
  • Pavel Tatashin's avatar
    mm: don't allow deferred pages with NEED_PER_CPU_KM · 02cec717
    Pavel Tatashin authored May 18, 2018
    BugLink: https://bugs.launchpad.net/bugs/1775477
    
    commit ab1e8d89 upstream.
    
    It is unsafe to do virtual to physical translations before mm_init() is
    called if struct page is needed in order to determine the memory section
    number (see SECTION_IN_PAGE_FLAGS).  This is because only in mm_init()
    we initialize struct pages for all the allocated memory when deferred
    struct pages are used.
    
    My recent fix in commit c9e97a19 ("mm: initialize pages on demand
    during boot") exposed this problem, because it greatly reduced number of
    pages that are initialized before mm_init(), but the problem existed
    even before my fix, as Fengguang Wu found.
    
    Below is a more detailed explanation of the problem.
    
    We initialize struct pages in four places:
    
    1. Early in boot a small set of struct pages is initialized to fill the
       first section, and lower zones.
    
    2. During mm_init() we initialize "struct pages" for all the memory that
       is allocated, i.e reserved in memblock.
    
    3. Using on-demand logic when pages are allocated after mm_init call
       (when memblock is finished)
    
    4. After smp_init() when the rest free deferred pages are initialized.
    
    The problem occurs if we try to do va to phys translation of a memory
    between steps 1 and 2.  Because we have not yet initialized struct pages
    for all the reserved pages, it is inherently unsafe to do va to phys if
    the translation itself requires access of "struct page" as in case of
    this combination: CONFIG_SPARSE && !CONFIG_SPARSE_VMEMMAP
    
    The following path exposes the problem:
    
      start_kernel()
       trap_init()
        setup_cpu_entry_areas()
         setup_cpu_entry_area(cpu)
          get_cpu_gdt_paddr(cpu)
           per_cpu_ptr_to_phys(addr)
            pcpu_addr_to_page(addr)
             virt_to_page(addr)
              pfn_to_page(__pa(addr) >> PAGE_SHIFT)
    
    We disable this path by not allowing NEED_PER_CPU_KM with deferred
    struct pages feature.
    
    The problems are discussed in these threads:
      http://lkml.kernel.org/r/20180418135300.inazvpxjxowogyge@wfg-t540p.sh.intel.com
      http://lkml.kernel.org/r/20180419013128.iurzouiqxvcnpbvz@wfg-t540p.sh.intel.com
      http://lkml.kernel.org/r/20180426202619.2768-1-pasha.tatashin@oracle.com
    
    Link: http://lkml.kernel.org/r/20180515175124.1770-1-pasha.tatashin@oracle.com
    Fixes: 3a80a7fa
    
     ("mm: meminit: initialise a subset of struct pages if CONFIG_DEFERRED_STRUCT_PAGE_INIT is set")
    Signed-off-by: default avatarPavel Tatashin <pasha.tatashin@oracle.com>
    Acked-by: default avatarMichal Hocko <mhocko@suse.com>
    Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Cc: Steven Sistare <steven.sistare@oracle.com>
    Cc: Daniel Jordan <daniel.m.jordan@oracle.com>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Cc: Fengguang Wu <fengguang.wu@intel.com>
    Cc: Dennis Zhou <dennisszhou@gmail.com>
    Cc: <stable@vger.kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
    Acked-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
    Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
    02cec717
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7