linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zhangkui <zhangkui@oppo.com>
To: akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: zhangkui <zhangkui@oppo.com>
Subject: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
Date: Wed,  4 Aug 2021 16:20:10 +0800	[thread overview]
Message-ID: <20210804082010.12482-1-zhangkui@oppo.com> (raw)

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@oppo.com>
---
 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;
--
2.25.1

________________________________
OPPO

本电子邮件及其附件含有OPPO公司的保密信息,仅限于邮件指明的收件人使用(包含个人及群组)。禁止任何人在未经授权的情况下以任何形式使用。如果您错收了本邮件,请立即以电子邮件通知发件人并删除本邮件及其附件。

This e-mail and its attachments contain confidential information from OPPO, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!

             reply	other threads:[~2021-08-04  8:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04  8:20 zhangkui [this message]
2021-08-04 19:08 ` [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() David Hildenbrand
2021-08-05  2:00 ` Andrew Morton
2021-08-05  2:58   ` 张魁(Kyler)
2021-08-05  2:04 ` Andrew Morton
2021-08-05  4:50   ` 张魁(Kyler)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210804082010.12482-1-zhangkui@oppo.com \
    --to=zhangkui@oppo.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).