1. Sep 28, 2019
    • Linus Torvalds's avatar
      Merge branch 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux · d0e00bc5
      Linus Torvalds authored
      Pull thermal management updates from Zhang Rui:
      
       - Add Amit Kucheria as thermal subsystem Reviewer (Amit Kucheria)
      
       - Fix a use after free bug when unregistering thermal zone devices (Ido
         Schimmel)
      
       - Fix thermal core framework to use put_device() when device_register()
         fails (Yue Hu)
      
       - Enable intel_pch_thermal and MMIO RAPL support for Intel Icelake
         platform (Srinivas Pandruvada)
      
       - Add clock operations in qorip thermal driver, for some platforms with
         clock control like i.MX8MQ (Anson Huang)
      
       - A couple of trivial fixes and cleanups for thermal core and different
         soc thermal drivers (Amit Kucheria, Christophe JAILLET, Chuhong Yuan,
         Fuqian Huang, Kelsey Skunberg, Nathan Huckleberry, Rishi Gupta,
         Srinivas Kandagatla)
      
      * 'for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
        MAINTAINERS: Add Amit Kucheria as reviewer for thermal
        thermal: Add some error messages
        thermal: Fix use-after-free when unregistering thermal zone device
        thermal/drivers/core: Use put_device() if device_register() fails
        thermal_hwmon: Sanitize thermal_zone type
        thermal: intel: Use dev_get_drvdata
        thermal: intel: int3403: replace printk(KERN_WARN...) with pr_warn(...)
        thermal: intel: int340x_thermal: Remove unnecessary acpi_has_method() uses
        thermal: int340x: processor_thermal: Add Ice Lake support
        drivers: thermal: qcom: tsens: Fix memory leak from qfprom read
        thermal: tegra: Fix a typo
        thermal: rcar_gen3_thermal: Replace devm_add_action() followed by failure action with devm_add_action_or_reset()
        thermal: armada: Fix -Wshift-negative-value
        dt-bindings: thermal: qoriq: Add optional clocks property
        thermal: qoriq: Use __maybe_unused instead of #if CONFIG_PM_SLEEP
        thermal: qoriq: Use devm_platform_ioremap_resource() instead of of_iomap()
        thermal: qoriq: Fix error path of calling qoriq_tmu_register_tmu_zone fail
        thermal: qoriq: Add clock operations
        drivers: thermal: processor_thermal_device: Export sysfs interface for TCC offset
      d0e00bc5
    • Linus Torvalds's avatar
      Merge tag 'linux-watchdog-5.4-rc1' of git://www.linux-watchdog.org/linux-watchdog · 7bccb9f1
      Linus Torvalds authored
      Pull watchdog updates from Wim Van Sebroeck:
      
       - addition of AST2600, i.MX7ULP and F81803 watchdog support
      
       - removal of the w90x900 and ks8695 drivers
      
       - ziirave_wdt improvements
      
       - small fixes and improvements
      
      * tag 'linux-watchdog-5.4-rc1' of git://www.linux-watchdog.org/linux-watchdog: (51 commits)
        watchdog: f71808e_wdt: Add F81803 support
        watchdog: qcom: remove unnecessary variable from private storage
        watchdog: qcom: support pre-timeout when the bark irq is available
        watchdog: imx_sc: this patch just fixes whitespaces
        watchdog: apseed: Add access_cs0 option for alt-boot
        watchdog: aspeed: add support for dual boot
        watchdog: orion_wdt: use timer1 as a pretimeout
        watchdog: Add i.MX7ULP watchdog support
        dt-bindings: watchdog: Add i.MX7ULP bindings
        dt-bindings: watchdog: sun4i: Add the watchdog clock
        dt-bindings: watchdog: sun4i: Add the watchdog interrupts
        dt-bindings: watchdog: Convert Allwinner watchdog to a schema
        dt-bindings: watchdog: Add YAML schemas for the generic watchdog bindings
        watchdog: aspeed: Add support for AST2600
        dt-bindings: watchdog: Add ast2600 compatible
        watchdog: ziirave_wdt: Update checked I2C functionality mask
        watchdog: ziirave_wdt: Drop ziirave_firm_write_block_data()
        watchdog: ziirave_wdt: Fix DOWNLOAD_START payload
        watchdog: ziirave_wdt: Drop status polling code
        watchdog: ziirave_wdt: Fix RESET_PROCESSOR payload
        ...
      7bccb9f1
    • Linus Torvalds's avatar
      Merge tag 'drm-next-2019-09-27' of git://anongit.freedesktop.org/drm/drm · 289991ce
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Fixes built up over the past 1.5 weeks or so, it's two weeks of
        amdgpu, some core cleanups and some panfrost fixes. I also finally
        figured out why my desktop was slow to do a bunch of stuff (someone
        gave it an IPv6 address which can't reach anything!).
      
        core:
         - Some cleanups and fixes in the self-refresh helpers
         - Some cleanups and fixes in the atomic helpers
      
        amdgpu:
         - Fix a 64 bit divide
         - Prevent a memory leak in a failure case in dc
         - Load proper gfx firmware on navi14 variants
         - Add more navi12 and navi14 PCI ids
         - Misc fixes for renoir
         - Fix bandwidth issues with multiple displays on vega20
         - Support for Dali
         - Fix a possible oops with KFD on hawaii
         - Fix for backlight level after resume on some APUs
         - Other misc fixes
      
        panfrost:
         - Multiple panfrost fixes for regulator support and page fault
           handling"
      
      * tag 'drm-next-2019-09-27' of git://anongit.freedesktop.org/drm/drm: (34 commits)
        drm/amd/display: prevent memory leak
        drm/amdgpu/gfx10: add support for wks firmware loading
        drm/amdgpu/display: include slab.h in dcn21_resource.c
        drm/amdgpu/display: fix 64 bit divide
        drm/panfrost: Prevent race when handling page fault
        drm/panfrost: Remove NULL checks for regulator
        drm/panfrost: Fix regulator_get_optional() misuse
        drm: Measure Self Refresh Entry/Exit times to avoid thrashing
        drm: Fix kerneldoc and remove unused struct member in self_refresh helper
        drm/atomic: Rename crtc_state->pageflip_flags to async_flip
        drm/atomic: Reject FLIP_ASYNC unconditionally
        drm/atomic: Take the atomic toys away from X
        drm/amdgpu: flag navi12 and 14 as experimental for 5.4
        drm/kms: Duct-tape for mode object lifetime checks
        drm/amdgpu: add navi12 pci id
        drm/amdgpu: add navi14 PCI ID for work station SKU
        drm/amdkfd: Swap trap temporary registers in gfx10 trap handler
        drm/amd/powerplay: implement sysfs for getting dpm clock
        drm/amd/display: Restore backlight brightness after system resume
        drm/amd/display: Implement voltage limitation for dali
        ...
      289991ce
    • Linus Torvalds's avatar
      Merge tag 'ntb-5.4' of git://github.com/jonmason/ntb · 0cd81d77
      Linus Torvalds authored
      Pull NTB updates from Jon Mason:
       "A few bugfixes and support for new AMD NTB hardware"
      
      * tag 'ntb-5.4' of git://github.com/jonmason/ntb:
        NTB: fix IDT Kconfig typos/spellos
        ntb_hw_amd: Add memory window support for new AMD hardware
        ntb_hw_amd: Add a new NTB PCI device ID
        NTB: ntb_transport: remove redundant assignment to rc
        ntb_hw_switchtec: make ntb_mw_set_trans() work when addr == 0
        ntb: point to right memory window index
      0cd81d77
    • Jarkko Sakkinen's avatar
      keys: Add Jarkko Sakkinen as co-maintainer · ea1e2bbe
      Jarkko Sakkinen authored
      
      
      To address a major procedural concern on Linus's part the keyrings needs
      a co-maintainer.
      
      Suggested-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ea1e2bbe
  2. Sep 27, 2019
  3. Sep 26, 2019
    • David Howells's avatar
      jffs2: Fix mounting under new mount API · a3bc18a4
      David Howells authored
      The mounting of jffs2 is broken due to the changes from the new mount API
      because it specifies a "source" operation, but then doesn't actually
      process it.  But because it specified it, it doesn't return -ENOPARAM and
      the caller doesn't process it either and the source gets lost.
      
      Fix this by simply removing the source parameter from jffs2 and letting the
      VFS deal with it in the default manner.
      
      To test it, enable CONFIG_MTD_MTDRAM and allow the default size and erase
      block size parameters, then try and mount the /dev/mtdblock<N> file that
      that creates as jffs2.  No need to initialise it.
      
      Fixes: ec10a24f
      
       ("vfs: Convert jffs2 to use the new mount API")
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      cc: David Woodhouse <dwmw2@infradead.org>
      cc: Richard Weinberger <richard@nod.at>
      cc: linux-mtd@lists.infradead.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      a3bc18a4
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-5.5-20190925' of... · b11f7244
      Ingo Molnar authored
      Merge tag 'perf-core-for-mingo-5.5-20190925' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
       into perf/urgent
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      perf record:
      
        Stephane Eranian:
      
        - Fix priv level with branch sampling for paranoid=2, i.e. the kernel checks
          if perf_event_attr_attr.exclude_hv is set in addition to .exclude_kernel,
          so reset both to zero.
      
        Arnaldo Carvalho de Melo:
      
        - Don't warn about not being able to read kernel maps (kallsyms, etc) when
          kernel samples aren't being collected.
      
      perf list:
      
        Kim Phillips:
      
        - Allow plurals for metric, metricgroup., i.e.:
      
          $ perf list metrics
      
          was showing nothing, which is very confusing, make it work like:
      
          $ perf stat metric
      
      perf stat:
      
        Andi Kleen:
      
        - Free memory access/leaks detected via valgrind, related to metrics.
      
      Libraries:
      
      libperf:
      
        Jiri Olsa:
      
        - Move more stuff from tools/perf, this time a first stab at moving perf_mmap
          methods.
      
      libtracevent:
      
        Steven Rostedt (VMware):
      
        - Round up in tep_print_event() time precision.
      
        Tzvetomir Stoyanov (VMware):
      
        - Man pages for event print and related and plugins APIs.
      
        - Move traceevent plugins in its own subdirectory.
      
      Feature detection:
      
        Thomas Richter:
      
        - Add detection of java-11-openjdk-devel package, in addition to the older
          versions supported.
      
      Architecture specific:
      
      S/390:
      
        Thomas Richter (2):
      
        - Include JVMTI support for s390
      
      Vendor events:
      
      AMD:
      
        Kim Phillips:
      
        - Add L3 cache events for Family 17h.
      
        - Remove redundant '['.
      
      PowerPC:
      
        Mamatha Inamdar:
      
        - Remove P8 HW events which are not supported.
      
      Cleanups:
      
        Arnaldo Carvalho de Melo:
      
        - Remove needless headers, add needed ones, move things around to reduce the
          headers dependency tree, speeding up builds by not doing needless compiles
          when unrelated stuff gets changed.
      
        - Ditch unused code that was dragging headers.
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      b11f7244
    • Dave Airlie's avatar
      Merge tag 'drm-fixes-5.4-2019-09-25' of git://people.freedesktop.org/~agd5f/linux into drm-next · 3e2cb6d8
      Dave Airlie authored
      
      
      drm-fixes-5.4-2019-09-25:
      
      amdgpu:
      - Fix a 64 bit divide
      - Prevent a memory leak in a failure case in dc
      - Load proper gfx firmware on navi14 variants
      
      drm-fixes-5.4-2019-09-19:
      
      amdgpu:
      - Add more navi12 and navi14 PCI ids
      - Misc fixes for renoir
      - Fix bandwidth issues with multiple displays on vega20
      - Support for Dali
      - Fix a possible oops with KFD on hawaii
      - Fix for backlight level after resume on some APUs
      - Other misc fixes
      
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      From: Alex Deucher <alexdeucher@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190925213500.3490-1-alexander.deucher@amd.com
      3e2cb6d8
    • Denis Efremov's avatar
      checkpatch: check for nested (un)?likely() calls · de3f186f
      Denis Efremov authored
      IS_ERR(), IS_ERR_OR_NULL(), IS_ERR_VALUE() and WARN*() already contain
      unlikely() optimization internally.  Thus, there is no point in calling
      these functions and defines under likely()/unlikely().
      
      This check is based on the coccinelle rule developed by Enrico Weigelt
      https://lore.kernel.org/lkml/1559767582-11081-1-git-send-email-info@metux.net/
      
      Link: http://lkml.kernel.org/r/20190829165025.15750-1-efremov@linux.com
      
      
      Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Anton Altaparmakov <anton@tuxera.com>
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Cc: Boris Pismenny <borisp@mellanox.com>
      Cc: Darrick J. Wong <darrick.wong@oracle.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Denis Efremov <efremov@linux.com>
      Cc: Dennis Dalessandro <dennis.dalessandro@intel.com>
      Cc: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Cc: Juergen Gross <jgross@suse.com>
      Cc: Leon Romanovsky <leon@kernel.org>
      Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Saeed Mahameed <saeedm@mellanox.com>
      Cc: Sean Paul <sean@poorly.run>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      de3f186f
    • Mike Rapoport's avatar
      hexagon: drop empty and unused free_initrd_mem · c7cc8d77
      Mike Rapoport authored
      hexagon never reserves or initializes initrd and the only mention of it is
      the empty free_initrd_mem() function.
      
      As we have a generic implementation of free_initrd_mem(), there is no need
      to define an empty stub for the hexagon implementation and it can be
      dropped.
      
      Link: http://lkml.kernel.org/r/1565858133-25852-1-git-send-email-rppt@linux.ibm.com
      
      
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Richard Kuo <rkuo@codeaurora.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      c7cc8d77
    • Minchan Kim's avatar
      mm: factor out common parts between MADV_COLD and MADV_PAGEOUT · d616d512
      Minchan Kim authored
      There are many common parts between MADV_COLD and MADV_PAGEOUT.
      This patch factor them out to save code duplication.
      
      Link: http://lkml.kernel.org/r/20190726023435.214162-6-minchan@kernel.org
      
      
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Suggested-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Daniel Colascione <dancol@google.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
      Cc: kbuild test robot <lkp@intel.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Oleksandr Natalenko <oleksandr@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Sonny Rao <sonnyrao@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tim Murray <timmurray@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d616d512
    • Minchan Kim's avatar
      mm: introduce MADV_PAGEOUT · 1a4e58cc
      Minchan Kim authored
      When a process expects no accesses to a certain memory range for a long
      time, it could hint kernel that the pages can be reclaimed instantly but
      data should be preserved for future use.  This could reduce workingset
      eviction so it ends up increasing performance.
      
      This patch introduces the new MADV_PAGEOUT hint to madvise(2) syscall.
      MADV_PAGEOUT can be used by a process to mark a memory range as not
      expected to be used for a long time so that kernel reclaims *any LRU*
      pages instantly.  The hint can help kernel in deciding which pages to
      evict proactively.
      
      A note: It doesn't apply SWAP_CLUSTER_MAX LRU page isolation limit
      intentionally because it's automatically bounded by PMD size.  If PMD
      size(e.g., 256) makes some trouble, we could fix it later by limit it to
      SWAP_CLUSTER_MAX[1].
      
      - man-page material
      
      MADV_PAGEOUT (since Linux x.x)
      
      Do not expect access in the near future so pages in the specified
      regions could be reclaimed instantly regardless of memory pressure.
      Thus, access in the range after successful operation could cause
      major page fault but never lose the up-to-date contents unlike
      MADV_DONTNEED. Pages belonging to a shared mapping are only processed
      if a write access is allowed for the calling process.
      
      MADV_PAGEOUT cannot be applied to locked pages, Huge TLB pages, or
      VM_PFNMAP pages.
      
      [1] https://lore.kernel.org/lkml/20190710194719.GS29695@dhcp22.suse.cz/
      
      [minchan@kernel.org: clear PG_active on MADV_PAGEOUT]
        Link: http://lkml.kernel.org/r/20190802200643.GA181880@google.com
      [akpm@linux-foundation.org: resolve conflicts with hmm.git]
      Link: http://lkml.kernel.org/r/20190726023435.214162-5-minchan@kernel.org
      
      
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Daniel Colascione <dancol@google.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Oleksandr Natalenko <oleksandr@redhat.com>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Sonny Rao <sonnyrao@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tim Murray <timmurray@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1a4e58cc
    • Minchan Kim's avatar
      mm: change PAGEREF_RECLAIM_CLEAN with PAGE_REFRECLAIM · 8940b34a
      Minchan Kim authored
      The local variable references in shrink_page_list is PAGEREF_RECLAIM_CLEAN
      as default.  It is for preventing to reclaim dirty pages when CMA try to
      migrate pages.  Strictly speaking, we don't need it because CMA didn't
      allow to write out by .may_writepage = 0 in reclaim_clean_pages_from_list.
      
      Moreover, it has a problem to prevent anonymous pages's swap out even
      though force_reclaim = true in shrink_page_list on upcoming patch.  So
      this patch makes references's default value to PAGEREF_RECLAIM and rename
      force_reclaim with ignore_references to make it more clear.
      
      This is a preparatory work for next patch.
      
      Link: http://lkml.kernel.org/r/20190726023435.214162-3-minchan@kernel.org
      
      
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Daniel Colascione <dancol@google.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
      Cc: kbuild test robot <lkp@intel.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Oleksandr Natalenko <oleksandr@redhat.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Sonny Rao <sonnyrao@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tim Murray <timmurray@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8940b34a
    • Minchan Kim's avatar
      mm: introduce MADV_COLD · 9c276cc6
      Minchan Kim authored
      Patch series "Introduce MADV_COLD and MADV_PAGEOUT", v7.
      
      - Background
      
      The Android terminology used for forking a new process and starting an app
      from scratch is a cold start, while resuming an existing app is a hot
      start.  While we continually try to improve the performance of cold
      starts, hot starts will always be significantly less power hungry as well
      as faster so we are trying to make hot start more likely than cold start.
      
      To increase hot start, Android userspace manages the order that apps
      should be killed in a process called ActivityManagerService.
      ActivityManagerService tracks every Android app or service that the user
      could be interacting with at any time and translates that into a ranked
      list for lmkd(low memory killer daemon).  They are likely to be killed by
      lmkd if the system has to reclaim memory.  In that sense they are similar
      to entries in any other cache.  Those apps are kept alive for
      opportunistic performance improvements but those performance improvements
      will vary based on the memory requirements of individual workloads.
      
      - Problem
      
      Naturally, cached apps were dominant consumers of memory on the system.
      However, they were not significant consumers of swap even though they are
      good candidate for swap.  Under investigation, swapping out only begins
      once the low zone watermark is hit and kswapd wakes up, but the overall
      allocation rate in the system might trip lmkd thresholds and cause a
      cached process to be killed(we measured performance swapping out vs.
      zapping the memory by killing a process.  Unsurprisingly, zapping is 10x
      times faster even though we use zram which is much faster than real
      storage) so kill from lmkd will often satisfy the high zone watermark,
      resulting in very few pages actually being moved to swap.
      
      - Approach
      
      The approach we chose was to use a new interface to allow userspace to
      proactively reclaim entire processes by leveraging platform information.
      This allowed us to bypass the inaccuracy of the kernel’s LRUs for pages
      that are known to be cold from userspace and to avoid races with lmkd by
      reclaiming apps as soon as they entered the cached state.  Additionally,
      it could provide many chances for platform to use much information to
      optimize memory efficiency.
      
      To achieve the goal, the patchset introduce two new options for madvise.
      One is MADV_COLD which will deactivate activated pages and the other is
      MADV_PAGEOUT which will reclaim private pages instantly.  These new
      options complement MADV_DONTNEED and MADV_FREE by adding non-destructive
      ways to gain some free memory space.  MADV_PAGEOUT is similar to
      MADV_DONTNEED in a way that it hints the kernel that memory region is not
      currently needed and should be reclaimed immediately; MADV_COLD is similar
      to MADV_FREE in a way that it hints the kernel that memory region is not
      currently needed and should be reclaimed when memory pressure rises.
      
      This patch (of 5):
      
      When a process expects no accesses to a certain memory range, it could
      give a hint to kernel that the pages can be reclaimed when memory pressure
      happens but data should be preserved for future use.  This could reduce
      workingset eviction so it ends up increasing performance.
      
      This patch introduces the new MADV_COLD hint to madvise(2) syscall.
      MADV_COLD can be used by a process to mark a memory range as not expected
      to be used in the near future.  The hint can help kernel in deciding which
      pages to evict early during memory pressure.
      
      It works for every LRU pages like MADV_[DONTNEED|FREE]. IOW, It moves
      
      	active file page -> inactive file LRU
      	active anon page -> inacdtive anon LRU
      
      Unlike MADV_FREE, it doesn't move active anonymous pages to inactive file
      LRU's head because MADV_COLD is a little bit different symantic.
      MADV_FREE means it's okay to discard when the memory pressure because the
      content of the page is *garbage* so freeing such pages is almost zero
      overhead since we don't need to swap out and access afterward causes just
      minor fault.  Thus, it would make sense to put those freeable pages in
      inactive file LRU to compete other used-once pages.  It makes sense for
      implmentaion point of view, too because it's not swapbacked memory any
      longer until it would be re-dirtied.  Even, it could give a bonus to make
      them be reclaimed on swapless system.  However, MADV_COLD doesn't mean
      garbage so reclaiming them requires swap-out/in in the end so it's bigger
      cost.  Since we have designed VM LRU aging based on cost-model, anonymous
      cold pages would be better to position inactive anon's LRU list, not file
      LRU.  Furthermore, it would help to avoid unnecessary scanning if system
      doesn't have a swap device.  Let's start simpler way without adding
      complexity at this moment.  However, keep in mind, too that it's a caveat
      that workloads with a lot of pages cache are likely to ignore MADV_COLD on
      anonymous memory because we rarely age anonymous LRU lists.
      
      * man-page material
      
      MADV_COLD (since Linux x.x)
      
      Pages in the specified regions will be treated as less-recently-accessed
      compared to pages in the system with similar access frequencies.  In
      contrast to MADV_FREE, the contents of the region are preserved regardless
      of subsequent writes to pages.
      
      MADV_COLD cannot be applied to locked pages, Huge TLB pages, or VM_PFNMAP
      pages.
      
      [akpm@linux-foundation.org: resolve conflicts with hmm.git]
      Link: http://lkml.kernel.org/r/20190726023435.214162-2-minchan@kernel.org
      
      
      Signed-off-by: default avatarMinchan Kim <minchan@kernel.org>
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Cc: James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Daniel Colascione <dancol@google.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Hillf Danton <hdanton@sina.com>
      Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Oleksandr Natalenko <oleksandr@redhat.com>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Sonny Rao <sonnyrao@google.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Tim Murray <timmurray@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9c276cc6
    • Catalin Marinas's avatar
      mm: untag user pointers in mmap/munmap/mremap/brk · ce18d171
      Catalin Marinas authored
      There isn't a good reason to differentiate between the user address space
      layout modification syscalls and the other memory permission/attributes
      ones (e.g.  mprotect, madvise) w.r.t.  the tagged address ABI.  Untag the
      user addresses on entry to these functions.
      
      Link: http://lkml.kernel.org/r/20190821164730.47450-2-catalin.marinas@arm.com
      
      
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Acked-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
      Cc: Kevin Brodsky <kevin.brodsky@arm.com>
      Cc: Dave P Martin <Dave.Martin@arm.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ce18d171
    • Andrey Konovalov's avatar
      vfio/type1: untag user pointers in vaddr_get_pfn · 6cf5354c
      Andrey Konovalov authored
      This patch is a part of a series that extends kernel ABI to allow to pass
      tagged user pointers (with the top byte set to something else other than
      0x00) as syscall arguments.
      
      vaddr_get_pfn() uses provided user pointers for vma lookups, which can
      only by done with untagged pointers.
      
      Untag user pointers in this function.
      
      Link: http://lkml.kernel.org/r/87422b4d72116a975896f2b19b00f38acbd28f33.1563904656.git.andreyknvl@google.com
      
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: default avatarEric Auger <eric.auger@redhat.com>
      Reviewed-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Felix Kuehling <Felix.Kuehling@amd.com>
      Cc: Jens Wiklander <jens.wiklander@linaro.org>
      Cc: Khalid Aziz <khalid.aziz@oracle.com>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6cf5354c
    • Andrey Konovalov's avatar
      tee/shm: untag user pointers in tee_shm_register · 78063a9d
      Andrey Konovalov authored
      This patch is a part of a series that extends kernel ABI to allow to pass
      tagged user pointers (with the top byte set to something else other than
      0x00) as syscall arguments.
      
      tee_shm_register()->optee_shm_unregister()->check_mem_type() uses provided
      user pointers for vma lookups (via __check_mem_type()), which can only by
      done with untagged pointers.
      
      Untag user pointers in this function.
      
      Link: http://lkml.kernel.org/r/4b993f33196b3566ac81285ff8453219e2079b45.1563904656.git.andreyknvl@google.com
      
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Eric Auger <eric.auger@redhat.com>
      Cc: Felix Kuehling <Felix.Kuehling@amd.com>
      Cc: Khalid Aziz <khalid.aziz@oracle.com>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      78063a9d
    • Andrey Konovalov's avatar
      media/v4l2-core: untag user pointers in videobuf_dma_contig_user_get · e275faf3
      Andrey Konovalov authored
      This patch is a part of a series that extends kernel ABI to allow to pass
      tagged user pointers (with the top byte set to something else other than
      0x00) as syscall arguments.
      
      videobuf_dma_contig_user_get() uses provided user pointers for vma
      lookups, which can only by done with untagged pointers.
      
      Untag the pointers in this function.
      
      Link: http://lkml.kernel.org/r/100436d5f8e4349a78f27b0bbb27e4801fcb946b.1563904656.git.andreyknvl@google.com
      
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Eric Auger <eric.auger@redhat.com>
      Cc: Felix Kuehling <Felix.Kuehling@amd.com>
      Cc: Jens Wiklander <jens.wiklander@linaro.org>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      e275faf3
    • Andrey Konovalov's avatar
      drm/radeon: untag user pointers in radeon_gem_userptr_ioctl · 4fdfae8d
      Andrey Konovalov authored
      This patch is a part of a series that extends kernel ABI to allow to pass
      tagged user pointers (with the top byte set to something else other than
      0x00) as syscall arguments.
      
      In radeon_gem_userptr_ioctl() an MMU notifier is set up with a (tagged)
      userspace pointer.  The untagged address should be used so that MMU
      notifiers for the untagged address get correctly matched up with the right
      BO.  This funcation also calls radeon_ttm_tt_pin_userptr(), which uses
      provided user pointers for vma lookups, which can only by done with
      untagged pointers.
      
      This patch untags user pointers in radeon_gem_userptr_ioctl().
      
      Link: http://lkml.kernel.org/r/c856babeb67195b35603b8d5ba386a2819cec5ff.1563904656.git.andreyknvl@google.com
      
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: default avatarKhalid Aziz <khalid.aziz@oracle.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Suggested-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Acked-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Eric Auger <eric.auger@redhat.com>
      Cc: Jens Wiklander <jens.wiklander@linaro.org>
      Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Cc: Mike Rapoport <rppt@linux.ibm.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      4fdfae8d