android_kernel_motorola_sm6375/include
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
..
acpi
asm-generic
clocksource
crypto Merge android-5.4.24 (ce5de62) into msm-5.4 2020-04-14 08:25:29 -07:00
drm
dt-bindings dt-bindings: clock: Update the SMD-RPM clock ID 2020-06-07 16:36:45 +05:30
keys
kvm
linux mm: support vector address ranges for process_madvise 2020-06-18 18:51:10 +05:30
math-emu
media Merge android-5.4.30 (5cfdde5) into msm-5.4 2020-05-19 13:22:43 -07:00
misc
net Merge android-5.4.30 (5cfdde5) into msm-5.4 2020-05-19 13:22:43 -07:00
pcmcia
ras
rdma
scsi
soc Merge "drivers: soc: qcom: handle system sleep activities" 2020-06-05 00:39:02 -07:00
sound Merge "Revert "ALSA: jack: Add support to report second microphone"" 2020-05-22 16:30:14 -07:00
target
trace Merge "PM / devfreq: bw_hwmon: remove unused variable" 2020-06-14 11:32:33 -07:00
uapi mm/madvise: introduce process_madvise() syscall: an external memory hinting API 2020-06-18 17:55:54 +05:30
vdso
video
xen