• Steve Capper's avatar
    arm64: hugetlb: refactor find_num_contig() · bb9dd3df
    Steve Capper authored
    Patch series "Support for contiguous pte hugepages", v4.
    
    This patchset updates the hugetlb code to fix issues arising from
    contiguous pte hugepages (such as on arm64).  Compared to v3, This
    version addresses a build failure on arm64 by including two cleanup
    patches.  Other than the arm64 cleanups, the rest are generic code
    changes.  The remaining arm64 support based on these patches will be
    posted separately.  The patches are based on v4.12-rc2.  Previous
    related postings can be found at [0], [1], [2], and [3].
    
    The patches fall into three categories -
    
    * Patch 1-2 - arm64 cleanups required to greatly simplify changing
      huge_pte_offset() prototype in Patch 5.
    
      Catalin, Will - are you happy for these patches to go via mm?
    
    * Patches 3-4 address issues with gup
    
    * Patches 5-8 relate to passing a size argument to hugepage helpers to
      disambiguate the size of the referred page. These changes are
      required to enable arch code to properly handle swap entries for
      contiguous pte hugepages.
    
      The changes to huge_pte_offset() (patch 5) touch multiple
      architectures but I've managed to minimise these changes for the
      other affected functions - huge_pte_clear() and set_huge_pte_at().
    
    These patches gate the enabling of contiguous hugepages support on arm64
    which has been requested for systems using !4k page granule.
    
    The ARM64 architecture supports two flavours of hugepages -
    
    * Block mappings at the pud/pmd level
    
      These are regular hugepages where a pmd or a pud page table entry
      points to a block of memory. Depending on the PAGE_SIZE in use the
      following size of block mappings are supported -
    
              PMD	PUD
              ---	---
      4K:      2M	 1G
      16K:    32M
      64K:   512M
    
      For certain applications/usecases such as HPC and large enterprise
      workloads, folks are using 64k page size but the minimum hugepage size
      of 512MB isn't very practical.
    
    To overcome this ...
    
    * Using the Contiguous bit
    
      The architecture provides a contiguous bit in the translation table
      entry which acts as a hint to the mmu to indicate that it is one of a
      contiguous set of entries that can be cached in a single TLB entry.
    
      We use the contiguous bit in Linux to increase the mapping size at the
      pmd and pte (last) level.
    
      The number of supported contiguous entries varies by page size and
      level of the page table.
    
      Using the contiguous bit allows additional hugepage sizes -
    
               CONT PTE    PMD    CONT PMD    PUD
               --------    ---    --------    ---
        4K:         64K     2M         32M     1G
        16K:         2M    32M          1G
        64K:         2M   512M         16G
    
      Of these, 64K with 4K and 2M with 64K pages have been explicitly
      requested by a few different users.
    
    Entries with the contiguous bit set are required to be modified all
    together - which makes things like memory poisoning and migration
    impossible to do correctly without knowing the size of hugepage being
    dealt with - the reason for adding size parameter to a few of the
    hugepage helpers in this series.
    
    This patch (of 8):
    
    As we regularly check for contiguous pte's in the huge accessors, remove
    this extra check from find_num_contig.
    
    [punit.agrawal@arm.com: resolve rebase conflicts due to patch re-ordering]
    Link: http://lkml.kernel.org/r/20170524115409.31309-2-punit.agrawal@arm.comSigned-off-by: default avatarSteve Capper <steve.capper@arm.com>
    Signed-off-by: default avatarPunit Agrawal <punit.agrawal@arm.com>
    Cc: David Woods <dwoods@mellanox.com>
    Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
    Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Mike Kravetz <mike.kravetz@oracle.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    bb9dd3df
hugetlbpage.c 7 KB