linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: zhangkui <zhangkui@oppo.com>,
	akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
Date: Wed, 4 Aug 2021 21:08:57 +0200	[thread overview]
Message-ID: <480fd747-d8d7-0830-0b97-bf2069dbef07@redhat.com> (raw)
In-Reply-To: <20210804082010.12482-1-zhangkui@oppo.com>

On 04.08.21 10:20, zhangkui wrote:
> 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;

I guess this should be fine. In contrast to other (e.g., destructive) 
madvise calls, an application could merely notice the difference that 
for example, in the pagemap something is suddenly no longer swapped, 
even thought the page wasn't touched by the process. But that can also 
happen e.g., during swapoff.

So I think this is fine, but let's hear if there are concerns.

-- 
Thanks,

David / dhildenb


  reply	other threads:[~2021-08-04 19:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04  8:20 [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() zhangkui
2021-08-04 19:08 ` David Hildenbrand [this message]
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=480fd747-d8d7-0830-0b97-bf2069dbef07@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=zhangkui@oppo.com \
    /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).