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, SMS can read-ahead memory of the process immediately
when the app switches to forground.
Calling process_madvise() with MADV_WILLNEED can meet this need.
Signed-off-by: zhangkui <zhangkui@xxxxxxxx>
---
mm/madvise.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/madvise.c b/mm/madvise.c
index 6d3d348b17f4..b9681fb3fbb5 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -1046,6 +1046,7 @@ process_madvise_behavior_valid(int behavior)
switch (behavior) {
case MADV_COLD:
case MADV_PAGEOUT:
+ case MADV_WILLNEED:
return true;
default:
return false;