Skip to content

Commit

Permalink
mm/madvise: add MADV_WILLNEED to process_madvise()
Browse files Browse the repository at this point in the history
There is a usecase in Android that an app process's memory is swapped out
by process_madvise() with MADV_PAGEOUT, such as the memory is swapped to
zram or a backing device.  When the process is scheduled to running, like
switch to foreground, multiple page faults may cause the app dropped
frames.

To reduce the problem, System Management Software can read-ahead memory
of the process immediately when the app switches to forground.  Calling
process_madvise() with MADV_WILLNEED can meet this need.

Link: https://lkml.kernel.org/r/20210804082010.12482-1-zhangkui@oppo.com
Signed-off-by: zhangkui <zhangkui@oppo.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
zhangkui authored and Linus Torvalds committed Sep 3, 2021
1 parent 33090af commit d5fffc5
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ process_madvise_behavior_valid(int behavior)
switch (behavior) {
case MADV_COLD:
case MADV_PAGEOUT:
case MADV_WILLNEED:
return true;
default:
return false;
Expand Down

0 comments on commit d5fffc5

Please sign in to comment.