1. 05 Jun, 2020 28 commits
  2. 04 Jun, 2020 12 commits
    • Linus Torvalds's avatar
      atomisp: avoid warning about unused function · 6929f71e
      Linus Torvalds authored
      The atomisp_mrfld_power() function isn't actually ever called, because
      the two call-sites have commented out the use because it breaks on some
      platforms.  That results in:
      
        drivers/staging/media/atomisp/pci/atomisp_v4l2.c:764:12: warning: ‘atomisp_mrfld_power’ defined but not used [-Wunused-function]
          764 | static int atomisp_mrfld_power(struct atomisp_device *isp, bool enable)
              |            ^~~~~~~~~~~~~~~~~~~
      
      during the build.
      
      Rather than commenting out the use entirely, just disable it
      semantically instead (using a "0 &&" construct), leaving the call in
      place from a syntax standpoint, and avoiding the warning.
      
      I really don't want my builds to have any warnings that can then hide
      real issues.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6929f71e
    • Linus Torvalds's avatar
      Merge tag 'media/v5.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media · a98f670e
      Linus Torvalds authored
      Pull media updates from Mauro Carvalho Chehab:
      
       - Media documentation is now split into admin-guide, driver-api and
         userspace-api books (a longstanding request from Jon);
      
       - The media Kconfig was reorganized, in order to make easier to select
         drivers and their dependencies;
      
       - The testing drivers now has a separate directory;
      
       - added a new driver for Rockchip Video Decoder IP;
      
       - The atomisp staging driver was resurrected. It is meant to work with
         4 generations of cameras on Atom-based laptops, tablets and cell
         phones. So, it seems worth investing time to cleanup this driver and
         making it in good shape.
      
       - Added some V4L2 core ancillary routines to help with h264 codecs;
      
       - Added an ov2740 image sensor driver;
      
       - The si2157 gained support for Analog TV, which, in turn, added
         support for some cx231xx and cx23885 boards to also support analog
         standards;
      
       - Added some V4L2 controls (V4L2_CID_CAMERA_ORIENTATION and
         V4L2_CID_CAMERA_SENSOR_ROTATION) to help identifying where the camera
         is located at the device;
      
       - VIDIOC_ENUM_FMT was extended to support MC-centric devices;
      
       - Lots of drivers improvements and cleanups.
      
      * tag 'media/v5.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (503 commits)
        media: Documentation: media: Refer to mbus format documentation from CSI-2 docs
        media: s5k5baf: Replace zero-length array with flexible-array
        media: i2c: imx219: Drop <linux/clk-provider.h> and <linux/clkdev.h>
        media: i2c: Add ov2740 image sensor driver
        media: ov8856: Implement sensor module revision identification
        media: ov8856: Add devicetree support
        media: dt-bindings: ov8856: Document YAML bindings
        media: dvb-usb: Add Cinergy S2 PCIe Dual Port support
        media: dvbdev: Fix tuner->demod media controller link
        media: dt-bindings: phy: phy-rockchip-dphy-rx0: move rockchip dphy rx0 bindings out of staging
        media: staging: dt-bindings: phy-rockchip-dphy-rx0: remove non-used reg property
        media: atomisp: unify the version for isp2401 a0 and b0 versions
        media: atomisp: update TODO with the current data
        media: atomisp: adjust some code at sh_css that could be broken
        media: atomisp: don't produce errs for ignored IRQs
        media: atomisp: print IRQ when debugging
        media: atomisp: isp_mmu: don't use kmem_cache
        media: atomisp: add a notice about possible leak resources
        media: atomisp: disable the dynamic and reserved pools
        media: atomisp: turn on camera before setting it
        ...
      a98f670e
    • Linus Torvalds's avatar
      Merge branch 'akpm' (patches from Andrew) · ee01c4d7
      Linus Torvalds authored
      Merge more updates from Andrew Morton:
       "More mm/ work, plenty more to come
      
        Subsystems affected by this patch series: slub, memcg, gup, kasan,
        pagealloc, hugetlb, vmscan, tools, mempolicy, memblock, hugetlbfs,
        thp, mmap, kconfig"
      
      * akpm: (131 commits)
        arm64: mm: use ARCH_HAS_DEBUG_WX instead of arch defined
        x86: mm: use ARCH_HAS_DEBUG_WX instead of arch defined
        riscv: support DEBUG_WX
        mm: add DEBUG_WX support
        drivers/base/memory.c: cache memory blocks in xarray to accelerate lookup
        mm/thp: rename pmd_mknotpresent() as pmd_mkinvalid()
        powerpc/mm: drop platform defined pmd_mknotpresent()
        mm: thp: don't need to drain lru cache when splitting and mlocking THP
        hugetlbfs: get unmapped area below TASK_UNMAPPED_BASE for hugetlbfs
        sparc32: register memory occupied by kernel as memblock.memory
        include/linux/memblock.h: fix minor typo and unclear comment
        mm, mempolicy: fix up gup usage in lookup_node
        tools/vm/page_owner_sort.c: filter out unneeded line
        mm: swap: memcg: fix memcg stats for huge pages
        mm: swap: fix vmstats for huge pages
        mm: vmscan: limit the range of LRU type balancing
        mm: vmscan: reclaim writepage is IO cost
        mm: vmscan: determine anon/file pressure balance at the reclaim root
        mm: balance LRU lists based on relative thrashing
        mm: only count actual rotations as LRU reclaim cost
        ...
      ee01c4d7
    • Zong Li's avatar
      arm64: mm: use ARCH_HAS_DEBUG_WX instead of arch defined · 09587a09
      Zong Li authored
      Extract DEBUG_WX to mm/Kconfig.debug for shared use.  Change to use
      ARCH_HAS_DEBUG_WX instead of DEBUG_WX defined by arch port.
      Signed-off-by: default avatarZong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lkml.kernel.org/r/e19709e7576f65e303245fe520cad5f7bae72763.1587455584.git.zong.li@sifive.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      09587a09
    • Zong Li's avatar
      x86: mm: use ARCH_HAS_DEBUG_WX instead of arch defined · 7e01ccb4
      Zong Li authored
      Extract DEBUG_WX to mm/Kconfig.debug for shared use.  Change to use
      ARCH_HAS_DEBUG_WX instead of DEBUG_WX defined by arch port.
      Signed-off-by: default avatarZong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lkml.kernel.org/r/430736828d149df3f5b462d291e845ec690e0141.1587455584.git.zong.li@sifive.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      7e01ccb4
    • Zong Li's avatar
      riscv: support DEBUG_WX · b422d28b
      Zong Li authored
      Support DEBUG_WX to check whether there are mapping with write and execute
      permission at the same time.
      
      [akpm@linux-foundation.org: replace macros with C]
      Signed-off-by: default avatarZong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Palmer Dabbelt <palmer@dabbelt.com>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lkml.kernel.org/r/282e266311bced080bc6f7c255b92f87c1eb65d6.1587455584.git.zong.li@sifive.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b422d28b
    • Zong Li's avatar
      mm: add DEBUG_WX support · 375d315c
      Zong Li authored
      Patch series "Extract DEBUG_WX to shared use".
      
      Some architectures support DEBUG_WX function, it's verbatim from each
      others, so extract to mm/Kconfig.debug for shared use.
      
      PPC and ARM ports don't support generic page dumper yet, so we only
      refine x86 and arm64 port in this patch series.
      
      For RISC-V port, the DEBUG_WX support depends on other patches which
      be merged already:
        - RISC-V page table dumper
        - Support strict kernel memory permissions for security
      
      This patch (of 4):
      
      Some architectures support DEBUG_WX function, it's verbatim from each
      others.  Extract to mm/Kconfig.debug for shared use.
      
      [akpm@linux-foundation.org: reword text, per Will Deacon & Zong Li]
        Link: http://lkml.kernel.org/r/20200427194245.oxRJKj3fn%25akpm@linux-foundation.org
      [zong.li@sifive.com: remove the specific name of arm64]
        Link: http://lkml.kernel.org/r/3a6a92ecedc54e1d0fc941398e63d504c2cd5611.1589178399.git.zong.li@sifive.com
      [zong.li@sifive.com: add MMU dependency for DEBUG_WX]
        Link: http://lkml.kernel.org/r/4a674ac7863ff39ca91847b10e51209771f99416.1589178399.git.zong.li@sifive.comSuggested-by: default avatarPalmer Dabbelt <palmer@dabbelt.com>
      Signed-off-by: default avatarZong Li <zong.li@sifive.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Paul Walmsley <paul.walmsley@sifive.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Link: http://lkml.kernel.org/r/cover.1587455584.git.zong.li@sifive.com
      Link: http://lkml.kernel.org/r/23980cd0f0e5d79e24a92169116407c75bcc650d.1587455584.git.zong.li@sifive.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      375d315c
    • Scott Cheloha's avatar
      drivers/base/memory.c: cache memory blocks in xarray to accelerate lookup · 4fb6eabf
      Scott Cheloha authored
      Searching for a particular memory block by id is an O(n) operation because
      each memory block's underlying device is kept in an unsorted linked list
      on the subsystem bus.
      
      We can cut the lookup cost to O(log n) if we cache each memory block
      in an xarray.  This time complexity improvement is significant on
      systems with many memory blocks.  For example:
      
      1. A 128GB POWER9 VM with 256MB memblocks has 512 blocks.  With this
         change  memory_dev_init() completes ~12ms faster and walk_memory_blocks()
         completes ~12ms faster.
      
      Before:
      [    0.005042] memory_dev_init: adding memory blocks
      [    0.021591] memory_dev_init: added memory blocks
      [    0.022699] walk_memory_blocks: walking memory blocks
      [    0.038730] walk_memory_blocks: walked memory blocks 0-511
      
      After:
      [    0.005057] memory_dev_init: adding memory blocks
      [    0.009415] memory_dev_init: added memory blocks
      [    0.010519] walk_memory_blocks: walking memory blocks
      [    0.014135] walk_memory_blocks: walked memory blocks 0-511
      
      2. A 256GB POWER9 LPAR with 256MB memblocks has 1024 blocks.  With
         this change memory_dev_init() completes ~88ms faster and
         walk_memory_blocks() completes ~87ms faster.
      
      Before:
      [    0.252246] memory_dev_init: adding memory blocks
      [    0.395469] memory_dev_init: added memory blocks
      [    0.409413] walk_memory_blocks: walking memory blocks
      [    0.433028] walk_memory_blocks: walked memory blocks 0-511
      [    0.433094] walk_memory_blocks: walking memory blocks
      [    0.500244] walk_memory_blocks: walked memory blocks 131072-131583
      
      After:
      [    0.245063] memory_dev_init: adding memory blocks
      [    0.299539] memory_dev_init: added memory blocks
      [    0.313609] walk_memory_blocks: walking memory blocks
      [    0.315287] walk_memory_blocks: walked memory blocks 0-511
      [    0.315349] walk_memory_blocks: walking memory blocks
      [    0.316988] walk_memory_blocks: walked memory blocks 131072-131583
      
      3. A 32TB POWER9 LPAR with 256MB memblocks has 131072 blocks.  With
         this change we complete memory_dev_init() ~37 minutes faster and
         walk_memory_blocks() at least ~30 minutes faster.  The exact timing
         for walk_memory_blocks() is  missing, though I observed that the
         soft lockups in walk_memory_blocks() disappeared with the change,
         suggesting that lower bound.
      
      Before:
      [   13.703907] memory_dev_init: adding blocks
      [ 2287.406099] memory_dev_init: added all blocks
      [ 2347.494986] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 2527.625378] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 2707.761977] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 2887.899975] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 3068.028318] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 3248.158764] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 3428.287296] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 3608.425357] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 3788.554572] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 3968.695071] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      [ 4148.823970] [c000000014c5bb60] [c000000000869af4] walk_memory_blocks+0x94/0x160
      
      After:
      [   13.696898] memory_dev_init: adding blocks
      [   15.660035] memory_dev_init: added all blocks
      (the walk_memory_blocks traces disappear)
      
      There should be no significant negative impact for machines with few
      memory blocks.  A sparse xarray has a small footprint and an O(log n)
      lookup is negligibly slower than an O(n) lookup for only the smallest
      number of memory blocks.
      
      1. A 16GB x86 machine with 128MB memblocks has 132 blocks.  With this
         change memory_dev_init() completes ~300us faster and walk_memory_blocks()
         completes no faster or slower.  The improvement is pretty close to noise.
      
      Before:
      [    0.224752] memory_dev_init: adding memory blocks
      [    0.227116] memory_dev_init: added memory blocks
      [    0.227183] walk_memory_blocks: walking memory blocks
      [    0.227183] walk_memory_blocks: walked memory blocks 0-131
      
      After:
      [    0.224911] memory_dev_init: adding memory blocks
      [    0.226935] memory_dev_init: added memory blocks
      [    0.227089] walk_memory_blocks: walking memory blocks
      [    0.227089] walk_memory_blocks: walked memory blocks 0-131
      
      [david@redhat.com: document the locking]
        Link: http://lkml.kernel.org/r/bc21eec6-7251-4c91-2f57-9a0671f8d414@redhat.comSigned-off-by: default avatarScott Cheloha <cheloha@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
      Acked-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Rafael J. Wysocki <rafael@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Rick Lindsley <ricklind@linux.vnet.ibm.com>
      Cc: Scott Cheloha <cheloha@linux.ibm.com>
      Link: http://lkml.kernel.org/r/20200121231028.13699-1-cheloha@linux.ibm.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4fb6eabf
    • Anshuman Khandual's avatar
      mm/thp: rename pmd_mknotpresent() as pmd_mkinvalid() · 86ec2da0
      Anshuman Khandual authored
      pmd_present() is expected to test positive after pmdp_mknotpresent() as
      the PMD entry still points to a valid huge page in memory.
      pmdp_mknotpresent() implies that given PMD entry is just invalidated from
      MMU perspective while still holding on to pmd_page() referred valid huge
      page thus also clearing pmd_present() test.  This creates the following
      situation which is counter intuitive.
      
      [pmd_present(pmd_mknotpresent(pmd)) = true]
      
      This renames pmd_mknotpresent() as pmd_mkinvalid() reflecting the helper's
      functionality more accurately while changing the above mentioned situation
      as follows.  This does not create any functional change.
      
      [pmd_present(pmd_mkinvalid(pmd)) = true]
      
      This is not applicable for platforms that define own pmdp_invalidate() via
      __HAVE_ARCH_PMDP_INVALIDATE.  Suggestion for renaming came during a
      previous discussion here.
      
      https://patchwork.kernel.org/patch/11019637/
      
      [anshuman.khandual@arm.com: change pmd_mknotvalid() to pmd_mkinvalid() per Will]
        Link: http://lkml.kernel.org/r/1587520326-10099-3-git-send-email-anshuman.khandual@arm.comSuggested-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Link: http://lkml.kernel.org/r/1584680057-13753-3-git-send-email-anshuman.khandual@arm.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      86ec2da0
    • Anshuman Khandual's avatar
      powerpc/mm: drop platform defined pmd_mknotpresent() · 124cb3a6
      Anshuman Khandual authored
      Patch series "mm/thp: Rename pmd_mknotpresent() as pmd_mknotvalid()", v2.
      
      This series renames pmd_mknotpresent() as pmd_mknotvalid().  Before that
      it drops an existing pmd_mknotpresent() definition from powerpc platform
      which was never required as it defines it's pmdp_invalidate() through
      subscribing __HAVE_ARCH_PMDP_INVALIDATE.  This does not create any
      functional change.
      
      This rename was suggested by Catalin during a previous discussion while we
      were trying to change the THP helpers on arm64 platform for migration.
      
      https://patchwork.kernel.org/patch/11019637/
      
      This patch (of 2):
      
      Platform needs to define pmd_mknotpresent() for generic pmdp_invalidate()
      only when __HAVE_ARCH_PMDP_INVALIDATE is not subscribed.  Otherwise
      platform specific pmd_mknotpresent() is not required.  Hence just drop it.
      Signed-off-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1587520326-10099-1-git-send-email-anshuman.khandual@arm.com
      Link: http://lkml.kernel.org/r/1584680057-13753-1-git-send-email-anshuman.khandual@arm.com
      Link: http://lkml.kernel.org/r/1584680057-13753-2-git-send-email-anshuman.khandual@arm.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      124cb3a6
    • Yang Shi's avatar
      mm: thp: don't need to drain lru cache when splitting and mlocking THP · 67e4eb07
      Yang Shi authored
      Since commit 8f182270 ("mm/swap.c: flush lru pvecs on compound page
      arrival") THP would not stay in pagevec anymore.  So the optimization made
      by commit d9654322 ("thp: increase split_huge_page() success rate")
      doesn't make sense anymore, which tries to unpin munlocked THPs from
      pagevec by draining pagevec.
      
      Draining lru cache before isolating THP in mlock path is also unnecessary.
      b676b293 ("mm, thp: fix mapped pages avoiding unevictable list on
      mlock") added it and 9a73f61b ("thp, mlock: do not mlock PTE-mapped
      file huge pages") accidentally carried it over after the above
      optimization went in.
      Signed-off-by: default avatarYang Shi <yang.shi@linux.alibaba.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarDaniel Jordan <daniel.m.jordan@oracle.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Link: http://lkml.kernel.org/r/1585946493-7531-1-git-send-email-yang.shi@linux.alibaba.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      67e4eb07
    • Shijie Hu's avatar
      hugetlbfs: get unmapped area below TASK_UNMAPPED_BASE for hugetlbfs · 88590253
      Shijie Hu authored
      In a 32-bit program, running on arm64 architecture.  When the address
      space below mmap base is completely exhausted, shmat() for huge pages will
      return ENOMEM, but shmat() for normal pages can still success on no-legacy
      mode.  This seems not fair.
      
      For normal pages, the calling trace of get_unmapped_area() is:
      
      	=> mm->get_unmapped_area()
      	if on legacy mode,
      		=> arch_get_unmapped_area()
      			=> vm_unmapped_area()
      	if on no-legacy mode,
      		=> arch_get_unmapped_area_topdown()
      			=> vm_unmapped_area()
      
      For huge pages, the calling trace of get_unmapped_area() is:
      
      	=> file->f_op->get_unmapped_area()
      		=> hugetlb_get_unmapped_area()
      			=> vm_unmapped_area()
      
      To solve this issue, we only need to make hugetlb_get_unmapped_area() take
      the same way as mm->get_unmapped_area().  Add *bottomup() and *topdown()
      for hugetlbfs, and check current mm->get_unmapped_area() to decide which
      one to use.  If mm->get_unmapped_area is equal to
      arch_get_unmapped_area_topdown(), hugetlb_get_unmapped_area() calls
      topdown routine, otherwise calls bottomup routine.
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarShijie Hu <hushijie3@huawei.com>
      Signed-off-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Xiaoming Ni <nixiaoming@huawei.com>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: yangerkun <yangerkun@huawei.com>
      Cc: ChenGang <cg.chen@huawei.com>
      Cc: Chen Jie <chenjie6@huawei.com>
      Link: http://lkml.kernel.org/r/20200518065338.113664-1-hushijie3@huawei.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      88590253