2022-04-25 12:24:17

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH v3 3/6] mm/vmscan: activate swap-backed executable folios after first usage

We should activate swap-backed executable folios (e.g. tmpfs) after first
usage so that executable code gets yet better chance to stay in memory.

Suggested-by: Huang, Ying <[email protected]>
Signed-off-by: Miaohe Lin <[email protected]>
Reviewed-by: Huang, Ying <[email protected]>
Cc: Joonsoo Kim <[email protected]>
---
mm/vmscan.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 7dcc8cf4526f..82e6fa83c472 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1415,9 +1415,9 @@ static enum page_references folio_check_references(struct folio *folio,
return PAGEREF_ACTIVATE;

/*
- * Activate file-backed executable folios after first usage.
+ * Activate executable folios after first usage.
*/
- if ((vm_flags & VM_EXEC) && !folio_test_swapbacked(folio))
+ if (vm_flags & VM_EXEC)
return PAGEREF_ACTIVATE;

return PAGEREF_KEEP;
--
2.23.0


2022-04-26 03:48:08

by Huang, Ying

[permalink] [raw]
Subject: Re: [PATCH v3 3/6] mm/vmscan: activate swap-backed executable folios after first usage

On Mon, 2022-04-25 at 14:07 -0700, Andrew Morton wrote:
> On Mon, 25 Apr 2022 19:12:29 +0800 Miaohe Lin <[email protected]> wrote:
>
> > We should activate swap-backed executable folios (e.g. tmpfs) after first
> > usage so that executable code gets yet better chance to stay in memory.
>
> Does this not erase the intended effect of Joonsoo's b518154e59a
> ("mm/vmscan: protect the workingset on anonymous LRU")?

I don't think so. This is only for executable folios (vm_flags &
VM_EXEC). The behavior for all other anonymous pages are not affected.

Best Regards,
Huang, Ying

2022-04-26 08:49:28

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v3 3/6] mm/vmscan: activate swap-backed executable folios after first usage

On Mon, 25 Apr 2022 19:12:29 +0800 Miaohe Lin <[email protected]> wrote:

> We should activate swap-backed executable folios (e.g. tmpfs) after first
> usage so that executable code gets yet better chance to stay in memory.

Does this not erase the intended effect of Joonsoo's b518154e59a
("mm/vmscan: protect the workingset on anonymous LRU")?

2022-04-27 07:01:16

by Miaohe Lin

[permalink] [raw]
Subject: Re: [PATCH v3 3/6] mm/vmscan: activate swap-backed executable folios after first usage

On 2022/4/26 10:02, [email protected] wrote:
> On Mon, 2022-04-25 at 14:07 -0700, Andrew Morton wrote:
>> On Mon, 25 Apr 2022 19:12:29 +0800 Miaohe Lin <[email protected]> wrote:
>>
>>> We should activate swap-backed executable folios (e.g. tmpfs) after first
>>> usage so that executable code gets yet better chance to stay in memory.
>>
>> Does this not erase the intended effect of Joonsoo's b518154e59a
>> ("mm/vmscan: protect the workingset on anonymous LRU")?
>
> I don't think so. This is only for executable folios (vm_flags &
> VM_EXEC). The behavior for all other anonymous pages are not affected.
>

Agree. Only executable folios are changed! Thanks both!

> Best Regards,
> Huang, Ying
>
> .
>

2022-04-27 10:02:42

by Huang, Ying

[permalink] [raw]
Subject: Re: [PATCH v3 3/6] mm/vmscan: activate swap-backed executable folios after first usage

On Wed, 2022-04-27 at 13:08 +0900, Joonsoo Kim wrote:
> Hello,
>
> 2022년 4월 26일 (화) 오후 3:58, Miaohe Lin <[email protected]>님이 작성:
> >
> > On 2022/4/26 10:02, [email protected] wrote:
> > > On Mon, 2022-04-25 at 14:07 -0700, Andrew Morton wrote:
> > > > On Mon, 25 Apr 2022 19:12:29 +0800 Miaohe Lin <[email protected]> wrote:
> > > >
> > > > > We should activate swap-backed executable folios (e.g. tmpfs) after first
> > > > > usage so that executable code gets yet better chance to stay in memory.
>
> Missing activation for swap-backed executable page is the intended operation.
> So, I disagree with this patch until some numbers are provided.
> See following discussion.
>
> https://lore.kernel.org/all/[email protected]/T/#u

Thanks for your pointer. Now I understood more about this. I agree to
keep the original behavior unless we can prove the change with numbers.

Best Regards,
Huang, Ying


2022-04-27 10:45:49

by Joonsoo Kim

[permalink] [raw]
Subject: Re: [PATCH v3 3/6] mm/vmscan: activate swap-backed executable folios after first usage

Hello,

2022년 4월 26일 (화) 오후 3:58, Miaohe Lin <[email protected]>님이 작성:
>
> On 2022/4/26 10:02, [email protected] wrote:
> > On Mon, 2022-04-25 at 14:07 -0700, Andrew Morton wrote:
> >> On Mon, 25 Apr 2022 19:12:29 +0800 Miaohe Lin <[email protected]> wrote:
> >>
> >>> We should activate swap-backed executable folios (e.g. tmpfs) after first
> >>> usage so that executable code gets yet better chance to stay in memory.

Missing activation for swap-backed executable page is the intended operation.
So, I disagree with this patch until some numbers are provided.
See following discussion.

https://lore.kernel.org/all/[email protected]/T/#u

Thanks.