diff mbox series

[5/8] mm/vmscan: use helper folio_is_file_lru()

Message ID 20220329132619.18689-6-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series A few cleanup and fixup patches for migration | expand

Commit Message

Miaohe Lin March 29, 2022, 1:26 p.m. UTC
Use helper folio_is_file_lru() to check whether folio is file lru. Minor
readability improvement.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/vmscan.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Huang, Ying April 1, 2022, 3:20 a.m. UTC | #1
Miaohe Lin <linmiaohe@huawei.com> writes:

> Use helper folio_is_file_lru() to check whether folio is file lru. Minor
> readability improvement.
>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/vmscan.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index ebd8ffb63673..31e95d627448 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1411,14 +1411,14 @@ static enum page_references folio_check_references(struct folio *folio,
>  		/*
>  		 * Activate file-backed executable folios after first usage.
>  		 */
> -		if ((vm_flags & VM_EXEC) && !folio_test_swapbacked(folio))
> +		if ((vm_flags & VM_EXEC) && folio_is_file_lru(folio))

I think that this should be converted to

		if ((vm_flags & VM_EXEC)))

We should activate swap-backed executable folios (e.g. tmpfs) after
first usage too.

Best Regards,
Huang, Ying

>  			return PAGEREF_ACTIVATE;
>  
>  		return PAGEREF_KEEP;
>  	}
>  
>  	/* Reclaim if clean, defer dirty folios to writeback */
> -	if (referenced_folio && !folio_test_swapbacked(folio))
> +	if (referenced_folio && folio_is_file_lru(folio))
>  		return PAGEREF_RECLAIM_CLEAN;
>  
>  	return PAGEREF_RECLAIM;
Miaohe Lin April 1, 2022, 6:14 a.m. UTC | #2
On 2022/4/1 11:20, Huang, Ying wrote:
> Miaohe Lin <linmiaohe@huawei.com> writes:
> 
>> Use helper folio_is_file_lru() to check whether folio is file lru. Minor
>> readability improvement.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/vmscan.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index ebd8ffb63673..31e95d627448 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1411,14 +1411,14 @@ static enum page_references folio_check_references(struct folio *folio,
>>  		/*
>>  		 * Activate file-backed executable folios after first usage.
>>  		 */
>> -		if ((vm_flags & VM_EXEC) && !folio_test_swapbacked(folio))
>> +		if ((vm_flags & VM_EXEC) && folio_is_file_lru(folio))
> 
> I think that this should be converted to
> 
> 		if ((vm_flags & VM_EXEC)))
> 
> We should activate swap-backed executable folios (e.g. tmpfs) after
> first usage too.
> 

Dig into the git history, we can found that commit c909e99364c8 ("vmscan: activate executable pages after first usage")
activate swap-backed executable folios after first usage too. But later swap-backed executable folios is not activated
via commit b518154e59aa ("mm/vmscan: protect the workingset on anonymous LRU") to pretect the workingset from anonymous
LRU. So above change might not be wanted. Or am I miss something?

Many thanks.

> Best Regards,
> Huang, Ying
> 
>>  			return PAGEREF_ACTIVATE;
>>  
>>  		return PAGEREF_KEEP;
>>  	}
>>  
>>  	/* Reclaim if clean, defer dirty folios to writeback */
>> -	if (referenced_folio && !folio_test_swapbacked(folio))
>> +	if (referenced_folio && folio_is_file_lru(folio))
>>  		return PAGEREF_RECLAIM_CLEAN;
>>  
>>  	return PAGEREF_RECLAIM;
> .
>
Huang, Ying April 1, 2022, 6:40 a.m. UTC | #3
Miaohe Lin <linmiaohe@huawei.com> writes:

> On 2022/4/1 11:20, Huang, Ying wrote:
>> Miaohe Lin <linmiaohe@huawei.com> writes:
>> 
>>> Use helper folio_is_file_lru() to check whether folio is file lru. Minor
>>> readability improvement.
>>>
>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>> ---
>>>  mm/vmscan.c | 4 ++--
>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>>> index ebd8ffb63673..31e95d627448 100644
>>> --- a/mm/vmscan.c
>>> +++ b/mm/vmscan.c
>>> @@ -1411,14 +1411,14 @@ static enum page_references folio_check_references(struct folio *folio,
>>>  		/*
>>>  		 * Activate file-backed executable folios after first usage.
>>>  		 */
>>> -		if ((vm_flags & VM_EXEC) && !folio_test_swapbacked(folio))
>>> +		if ((vm_flags & VM_EXEC) && folio_is_file_lru(folio))
>> 
>> I think that this should be converted to
>> 
>> 		if ((vm_flags & VM_EXEC)))
>> 
>> We should activate swap-backed executable folios (e.g. tmpfs) after
>> first usage too.
>> 
>
> Dig into the git history, we can found that commit c909e99364c8 ("vmscan: activate executable pages after first usage")
> activate swap-backed executable folios after first usage too. But later swap-backed executable folios is not activated
> via commit b518154e59aa ("mm/vmscan: protect the workingset on anonymous LRU") to pretect the workingset from anonymous
> LRU. So above change might not be wanted. Or am I miss something?

I think we should restore the original behavior to protect swap backed
executable folios too.

Hi, Kim,

What do you think about this?

Best Regards,
Huang, Ying

> Many thanks.
>
>> Best Regards,
>> Huang, Ying
>> 
>>>  			return PAGEREF_ACTIVATE;
>>>  
>>>  		return PAGEREF_KEEP;
>>>  	}
>>>  
>>>  	/* Reclaim if clean, defer dirty folios to writeback */
>>> -	if (referenced_folio && !folio_test_swapbacked(folio))
>>> +	if (referenced_folio && folio_is_file_lru(folio))
>>>  		return PAGEREF_RECLAIM_CLEAN;
>>>  
>>>  	return PAGEREF_RECLAIM;
>> .
>>
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index ebd8ffb63673..31e95d627448 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1411,14 +1411,14 @@  static enum page_references folio_check_references(struct folio *folio,
 		/*
 		 * Activate file-backed executable folios after first usage.
 		 */
-		if ((vm_flags & VM_EXEC) && !folio_test_swapbacked(folio))
+		if ((vm_flags & VM_EXEC) && folio_is_file_lru(folio))
 			return PAGEREF_ACTIVATE;
 
 		return PAGEREF_KEEP;
 	}
 
 	/* Reclaim if clean, defer dirty folios to writeback */
-	if (referenced_folio && !folio_test_swapbacked(folio))
+	if (referenced_folio && folio_is_file_lru(folio))
 		return PAGEREF_RECLAIM_CLEAN;
 
 	return PAGEREF_RECLAIM;