linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
@ 2021-08-04  8:20 zhangkui
  2021-08-04 19:08 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: zhangkui @ 2021-08-04  8:20 UTC (permalink / raw)
  To: akpm, linux-mm, linux-kernel; +Cc: zhangkui

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!

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
  2021-08-04  8:20 [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() zhangkui
@ 2021-08-04 19:08 ` David Hildenbrand
  2021-08-05  2:00 ` Andrew Morton
  2021-08-05  2:04 ` Andrew Morton
  2 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2021-08-04 19:08 UTC (permalink / raw)
  To: zhangkui, akpm, linux-mm, linux-kernel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
  2021-08-04  8:20 [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() zhangkui
  2021-08-04 19:08 ` David Hildenbrand
@ 2021-08-05  2:00 ` Andrew Morton
  2021-08-05  2:58   ` 张魁(Kyler)
  2021-08-05  2:04 ` Andrew Morton
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2021-08-05  2:00 UTC (permalink / raw)
  To: zhangkui; +Cc: linux-mm, linux-kernel

On Wed,  4 Aug 2021 16:20:10 +0800 zhangkui <zhangkui@oppo.com> 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.
> 

What is SMS?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
  2021-08-04  8:20 [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() zhangkui
  2021-08-04 19:08 ` David Hildenbrand
  2021-08-05  2:00 ` Andrew Morton
@ 2021-08-05  2:04 ` Andrew Morton
  2021-08-05  4:50   ` 张魁(Kyler)
  2 siblings, 1 reply; 6+ messages in thread
From: Andrew Morton @ 2021-08-05  2:04 UTC (permalink / raw)
  To: zhangkui; +Cc: linux-mm, linux-kernel, linux-man

On Wed,  4 Aug 2021 16:20:10 +0800 zhangkui <zhangkui@oppo.com> 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.

This will require a small update to the process_madvise(2) manpage. 
Can you please send a patch?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
  2021-08-05  2:00 ` Andrew Morton
@ 2021-08-05  2:58   ` 张魁(Kyler)
  0 siblings, 0 replies; 6+ messages in thread
From: 张魁(Kyler) @ 2021-08-05  2:58 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel

在 8/5/2021 10:00, Andrew Morton 写道:
> On Wed,  4 Aug 2021 16:20:10 +0800 zhangkui <zhangkui@oppo.com> 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.
>>
>
> What is SMS?
>
SMS is the abbreviation of System Management Software.
For more information, please refer to the commit
ecb8ac8b1f146915aa6b96449b66dd48984caacc.
________________________________
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!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise()
  2021-08-05  2:04 ` Andrew Morton
@ 2021-08-05  4:50   ` 张魁(Kyler)
  0 siblings, 0 replies; 6+ messages in thread
From: 张魁(Kyler) @ 2021-08-05  4:50 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, linux-man

On 8/5/2021 10:04, Andrew Morton wrote:
> On Wed,  4 Aug 2021 16:20:10 +0800 zhangkui <zhangkui@oppo.com> 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.
>
> This will require a small update to the process_madvise(2) manpage.
> Can you please send a patch?
>

I pushed a patch, please help to review it.
https://lore.kernel.org/patchwork/patch/1472380/
________________________________
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!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-05  4:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04  8:20 [PATCH] mm/madvise: add MADV_WILLNEED to process_madvise() zhangkui
2021-08-04 19:08 ` 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)

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).