android_kernel_motorola_sm6375/mm
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Minchan Kim a95f164e8e mm: support vector address ranges for process_madvise
This patch changes process_madvise interface:

  a) support vector address ranges in a system call
  b) support the vector address ranges to local process as well as
     external process
  c) remove pid but keep only pidfd in argument - [1][2]
  d) change type of flags with unsgined int

Android app has thousands of vmas due to zygote so it's totally waste of
CPU and power if we should call the syscall one by one for each vma.
(With testing 2000-vma syscall vs 1-vector syscall, it showed 15%
performance improvement.  I think it would be bigger in real practice
because the testing ran very cache friendly environment).

Another potential use case for the vector range is to amortize the cost of
TLB shootdowns for multiple ranges when using MADV_DONTNEED; this could
benefit users like TCP receive zerocopy and malloc implementations.  In
future, we could find more usecases for other advises so let's make it
happens as API since we introduce a new syscall at this moment.  With
that, existing madvise(2) user could replace it with process_madvise(2)
with their own pid if they want to have batch address ranges support
feature.

So finally, the API is as follows,

      ssize_t process_madvise(int pidfd, const struct iovec *iovec,
      		unsigned long vlen, int advice, unsigned int flags);

    DESCRIPTION
      The process_madvise() system call is used to give advice or directions
      to the kernel about the address ranges from external process as well as
      local process. It provides the advice to address ranges of process
      described by iovec and vlen. The goal of such advice is to improve system
      or application performance.

      The pidfd selects the process referred to by the PID file descriptor
      specified in pidfd. (See pidofd_open(2) for further information)

      The pointer iovec points to an array of iovec structures, defined in
      <sys/uio.h> as:

        struct iovec {
            void *iov_base;         /* starting address */
            size_t iov_len;         /* number of bytes to be advised */
        };

      The iovec describes address ranges beginning at address(iov_base)
      and with size length of bytes(iov_len).

      The vlen represents the number of elements in iovec.

      The advice is indicated in the advice argument, which is one of the
      following at this moment if the target process specified by pidfd is
      external.

        MADV_COLD
        MADV_PAGEOUT
        MADV_MERGEABLE
        MADV_UNMERGEABLE

      Permission to provide a hint to external process is governed by a
      ptrace access mode PTRACE_MODE_ATTACH_FSCREDS check; see ptrace(2).

      The process_madvise supports every advice madvise(2) has if target
      process is in same thread group with calling process so user could
      use process_madvise(2) to extend existing madvise(2) to support
      vector address ranges.

    RETURN VALUE
      On success, process_madvise() returns the number of bytes advised.
      This return value may be less than the total number of requested
      bytes, if an error occurred. The caller should check return value
      to determine whether a partial advice occurred.

[1] https://lore.kernel.org/linux-mm/20200509124817.xmrvsrq3mla6b76k@wittgenstein/
[2] https://lore.kernel.org/linux-mm/[email protected]/

Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Minchan Kim <[email protected]>
Reviewed-by: Suren Baghdasaryan <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Arjun Roy <[email protected]>
Cc: Tim Murray <[email protected]>
Cc: Daniel Colascione <[email protected]>
Cc: Sonny Rao <[email protected]>
Cc: Brian Geffon <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: John Dias <[email protected]>
Cc: Joel Fernandes <[email protected]>
Cc: SeongJae Park <[email protected]>
Cc: Oleksandr Natalenko <[email protected]>
Cc: Sandeep Patil <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Christian Brauner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
Git-Commit: cac63a8674fec9a9e288972475366896d706b53c
Git-Repo: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git

From: Randy Dunlap <[email protected]>
Subject: mm-support-vector-address-ranges-for-process_madvise-fix-fix

fix process_madvise prototype.
[[email protected]]: This is merged with cac63a8674fe ("mm:
support vector address ranges for process_madvise" to avoid the
compilation errors.

Cc: Minchan Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
Git-Commit: beadf725ea3f41cc23c77aefcb3139c081ff528d
Git-Repo: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
Change-Id: I8aa28294d56874f057779674337986dbbe7cf076
Signed-off-by: Charan Teja Reddy <[email protected]>
2020-06-18 18:51:10 +05:30
..
kasan kasan: Zero shadow memory on memory hotplug 2019-12-23 10:08:36 -08:00
backing-dev.c memcg: fix a crash in wb_workfn when a device disappears 2020-02-11 04:35:11 -08:00
balloon_compaction.c mm/balloon_compaction: suppress allocation warnings 2019-09-04 07:42:01 -04:00
cleancache.c
cma.c Merge "mm: cma: Print region name on failure" 2019-12-09 14:12:05 -08:00
cma.h
cma_debug.c Revert "mm: cma: make writeable CMA debugfs optional" 2020-01-16 13:16:30 -08:00
compaction.c mm, compaction: fix wrong pfn handling in __reset_isolation_pfn() 2019-10-14 15:04:01 -07:00
debug.c mm/debug.c: always print flags in dump_page() 2020-03-05 16:43:51 +01:00
debug_page_ref.c
dmapool.c
early_ioremap.c
fadvise.c fs: Export generic_fadvise() 2019-08-30 22:43:58 -07:00
failslab.c
filemap.c Merge android-5.4.9 (813bf83) into msm-5.4 2020-03-07 10:01:47 -08:00
frame_vector.c mm: untag user pointers in get_vaddr_frames 2019-09-25 17:51:41 -07:00
frontswap.c
gup.c mm/gup: allow FOLL_FORCE for get_user_pages_fast() 2020-03-05 16:43:51 +01:00
gup_benchmark.c mm/gup: fix memory leak in __gup_benchmark_ioctl 2020-01-09 10:20:00 +01:00
highmem.c
hmm.c pagewalk: separate function pointers from iterator data 2019-09-07 04:28:04 -03:00
huge_memory.c mm: Enhance per process reclaim to consider shared pages 2020-06-02 21:31:03 -07:00
hugetlb.c Merge android-5.4.24 (ce5de62) into msm-5.4 2020-04-14 08:25:29 -07:00
hugetlb_cgroup.c mm: hugetlb: switch to css_tryget() in hugetlb_cgroup_charge_cgroup() 2019-11-15 18:34:00 -08:00
hwpoison-inject.c
init-mm.c mm/init-mm.c: include <linux/mman.h> for vm_committed_as_batch 2019-10-19 06:32:32 -04:00
internal.h mm: drop mmap_sem before calling balance_dirty_pages() in write fault 2020-01-09 10:19:55 +01:00
interval_tree.c
Kconfig Merge "mm: introduce CONFIG_SPECULATIVE_PAGE_FAULT" 2020-06-17 02:00:28 -07:00
Kconfig.debug mm, page_owner: set page owner info for tail pages 2020-02-27 15:13:14 -08:00
khugepaged.c mm,thp: recheck each page before collapsing file THP 2019-11-15 18:34:00 -08:00
kmemleak-test.c
kmemleak.c kmemleak: Do not corrupt the object_list during clean-up 2019-10-14 08:56:16 -07:00
ksm.c mm: Enhance per process reclaim to consider shared pages 2020-06-02 21:31:03 -07:00
list_lru.c
maccess.c uaccess: Add non-pagefault user-space write function 2020-01-17 19:48:40 +01:00
madvise.c mm: support vector address ranges for process_madvise 2020-06-18 18:51:10 +05:30
Makefile Merge "mm: Add notifier framework for showing memory" 2019-10-11 23:42:08 -07:00
memblock.c arm64: mm/memblock: Update memory limit calculation 2020-01-03 15:44:34 -08:00
memcontrol.c mm: fork: fix kernel_stack memcg stats for various stack implementations 2020-04-01 11:02:03 +02:00
memfd.c mm: page cache: store only head pages in i_pages 2019-09-24 15:54:08 -07:00
memory-failure.c mm: Enhance per process reclaim to consider shared pages 2020-06-02 21:31:03 -07:00
memory.c Merge android-5.4.9 (813bf83) into msm-5.4 2020-03-07 10:01:47 -08:00
memory_hotplug.c Merge "mm/memory_hotplug: Rate limit page migration warnings" 2020-06-08 17:54:16 -07:00
mempolicy.c This is the 5.4.18 stable release 2020-02-05 22:19:48 +00:00
mempool.c
memremap.c mm/memory_hotplug: shrink zones when offlining memory 2020-01-09 10:19:56 +01:00
memtest.c
migrate.c mm: Enhance per process reclaim to consider shared pages 2020-06-02 21:31:03 -07:00
mincore.c mm: untag user pointers passed to memory syscalls 2019-09-25 17:51:41 -07:00
mlock.c Merge 5.4-rc1-prelrease into android-mainline 2019-10-02 17:58:47 +02:00
mm_init.c
mmap.c This is the 5.4.23 stable release 2020-03-01 10:17:44 +01:00
mmu_context.c
mmu_gather.c mm/mmu_gather: invalidate TLB correctly on batch allocation failure and flush 2020-02-11 04:35:42 -08:00
mmu_notifier.c mm/mmu_notifiers: use the right return code for WARN_ON 2019-11-06 08:47:50 -08:00
mmzone.c
mprotect.c This is the 5.4.25 stable release 2020-03-12 17:09:04 +01:00
mremap.c mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() 2020-02-28 17:22:21 +01:00
msync.c mm: untag user pointers passed to memory syscalls 2019-09-25 17:51:41 -07:00
nommu.c x86/mm: split vmalloc_sync_all() 2020-03-25 08:25:58 +01:00
oom_kill.c mm: oom_kill: Support further prioritization of OOM kills 2020-03-17 16:37:27 -07:00
page-writeback.c mm/page-writeback.c: avoid potential division by zero in wb_min_max_ratio() 2020-01-23 08:22:41 +01:00
page_alloc.c Merge android-5.4.26 (0d3cca0c) into msm-5.4 2020-05-19 12:58:11 -07:00
page_counter.c
page_ext.c mm, page_owner: fix off-by-one error in __set_page_owner_handle() 2019-10-14 15:04:00 -07:00
page_idle.c
page_io.c Merge android-5.4.24 (ce5de62) into msm-5.4 2020-04-14 08:25:29 -07:00
page_isolation.c
page_owner.c mm, page_owner: set page owner info for tail pages 2020-02-27 15:13:14 -08:00
page_poison.c Merge "mm: allow page poisoning to be enabled by default" 2019-10-12 01:44:53 -07:00
page_vma_mapped.c mm: introduce page_size() 2019-09-24 15:54:08 -07:00
pagewalk.c pagewalk: use lockdep_assert_held for locking validation 2019-09-07 04:28:04 -03:00
percpu-internal.h
percpu-km.c
percpu-stats.c
percpu-vm.c
percpu.c percpu: Use struct_size() helper 2019-09-04 13:40:49 -07:00
pgtable-generic.c
process_vm_access.c
readahead.c
rmap.c mm: Enhance per process reclaim to consider shared pages 2020-06-02 21:31:03 -07:00
rodata_test.c
shmem.c This is the 5.4.14 stable release 2020-01-23 08:37:43 +01:00
showmem.c mm: showmem: make the notifiers atomic 2019-10-10 12:39:04 -07:00
shuffle.c mm: fix -Wmissing-prototypes warnings 2019-10-07 15:47:19 -07:00
shuffle.h
slab.c mm, debug_pagealloc: don't rely on static keys too early 2020-01-23 08:22:40 +01:00
slab.h mm: slab: make page_cgroup_ino() to recognize non-compound slab pages properly 2019-11-06 08:47:50 -08:00
slab_common.c mm: memcg/slab: call flush_memcg_workqueue() only if memcg workqueue is valid 2020-01-23 08:22:39 +01:00
slob.c mm, sl[aou]b: guarantee natural alignment for kmalloc(power-of-two) 2019-10-07 15:47:20 -07:00
slub.c Merge android-5.4.30 (5cfdde5) into msm-5.4 2020-05-19 13:22:43 -07:00
sparse-vmemmap.c
sparse.c mm/sparse: fix kernel crash with pfn_section_valid check 2020-04-01 11:02:03 +02:00
swap.c mm: introduce MADV_COLD 2019-09-25 17:51:41 -07:00
swap_cgroup.c
swap_slots.c mm: swap: Add null pointer check 2020-01-10 11:23:22 -08:00
swap_state.c mm: page cache: store only head pages in i_pages 2019-09-24 15:54:08 -07:00
swapfile.c mm/swapfile.c: move inode_lock out of claim_swapfile 2020-04-01 11:02:02 +02:00
truncate.c mm/thp: allow dropping THP from page cache 2019-10-19 06:32:33 -04:00
usercopy.c mm: usercopy: skip stack page span check 2019-12-02 15:36:05 -08:00
userfaultfd.c Merge android-5.4.24 (ce5de62) into msm-5.4 2020-04-14 08:25:29 -07:00
util.c arm64, mm: make randomization selected by generic topdown mmap layout 2019-09-24 15:54:11 -07:00
vmacache.c
vmalloc.c x86/mm: split vmalloc_sync_all() 2020-03-25 08:25:58 +01:00
vmpressure.c mm/vmpressure.c: fix a signedness bug in vmpressure_register_event() 2019-10-07 15:47:19 -07:00
vmscan.c mm: Enhance per process reclaim to consider shared pages 2020-06-02 21:31:03 -07:00
vmstat.c mm: introduce NR_UNRECLAIMABLE_PAGES 2020-06-05 14:38:07 +05:30
workingset.c mm: workingset: fix vmstat counters for shadow nodes 2019-08-13 16:06:52 -07:00
z3fold.c mm/z3fold.c: claim page in the beginning of free 2019-10-07 15:47:19 -07:00
zbud.c
zpool.c zpool: add malloc_support_movable to zpool_driver 2019-09-24 15:54:12 -07:00
zsmalloc.c Merge android-5.4.9 (813bf83) into msm-5.4 2020-03-07 10:01:47 -08:00
zswap.c zswap: do not map same object twice 2019-09-24 15:54:12 -07:00