diff mbox series

[v2,1/9] mm/vmscan: add a comment about MADV_FREE pages check in folio_check_dirty_writeback

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

Commit Message

Miaohe Lin April 9, 2022, 9:34 a.m. UTC
The MADV_FREE pages check in folio_check_dirty_writeback is a bit hard to
follow. Add a comment to make the code clear.

Suggested-by: Huang, Ying <ying.huang@intel.com>
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/vmscan.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Huang, Ying April 11, 2022, 11:50 a.m. UTC | #1
On Sat, 2022-04-09 at 17:34 +0800, Miaohe Lin wrote:
> The MADV_FREE pages check in folio_check_dirty_writeback is a bit hard to
> follow. Add a comment to make the code clear.
> 
> Suggested-by: Huang, Ying <ying.huang@intel.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/vmscan.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index c77d5052f230..4a76be47bed1 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1436,6 +1436,9 @@ static void folio_check_dirty_writeback(struct folio
> *folio,
>         /*
>          * Anonymous pages are not handled by flushers and must be written
>          * from reclaim context. Do not stall reclaim based on them
> +        * MADV_FREE anonymous pages are put into inactive file list too.
> +        * They could be mistakenly treated as file lru. So further anon
> +        * test is needed.
>          */

How about something as follows,

	/*
         * Anonymous pages (including MADV_FREE ones) are not handled
by	 * flushers and must be written from reclaim context. Do not stall
	 * reclaim based on them
	 */.

Best Regards,
Huang, Ying

>         if (!folio_is_file_lru(folio) ||
>             (folio_test_anon(folio) && !folio_test_swapbacked(folio))) {
Christoph Hellwig April 11, 2022, 2:16 p.m. UTC | #2
On Sat, Apr 09, 2022 at 05:34:52PM +0800, Miaohe Lin wrote:
> The MADV_FREE pages check in folio_check_dirty_writeback is a bit hard to
> follow. Add a comment to make the code clear.
> 
> Suggested-by: Huang, Ying <ying.huang@intel.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---
>  mm/vmscan.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index c77d5052f230..4a76be47bed1 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1436,6 +1436,9 @@ static void folio_check_dirty_writeback(struct folio *folio,
>  	/*
>  	 * Anonymous pages are not handled by flushers and must be written
>  	 * from reclaim context. Do not stall reclaim based on them

While you touch this please add a period at the end of the above
sentence.

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Miaohe Lin April 12, 2022, 3:07 a.m. UTC | #3
On 2022/4/11 19:50, ying.huang@intel.com wrote:
> On Sat, 2022-04-09 at 17:34 +0800, Miaohe Lin wrote:
>> The MADV_FREE pages check in folio_check_dirty_writeback is a bit hard to
>> follow. Add a comment to make the code clear.
>>
>> Suggested-by: Huang, Ying <ying.huang@intel.com>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/vmscan.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index c77d5052f230..4a76be47bed1 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1436,6 +1436,9 @@ static void folio_check_dirty_writeback(struct folio
>> *folio,
>>         /*
>>          * Anonymous pages are not handled by flushers and must be written
>>          * from reclaim context. Do not stall reclaim based on them
>> +        * MADV_FREE anonymous pages are put into inactive file list too.
>> +        * They could be mistakenly treated as file lru. So further anon
>> +        * test is needed.
>>          */
> 
> How about something as follows,
> 
> 	/*
>          * Anonymous pages (including MADV_FREE ones) are not handled
> by	 * flushers and must be written from reclaim context. Do not stall
> 	 * reclaim based on them
> 	 */.
> 

This comment looks good but it seems it doesn't explain the MADV_FREE check logic.
Is this already enough? If so, will change to use this. Thanks!

> Best Regards,
> Huang, Ying
> 
>>         if (!folio_is_file_lru(folio) ||
>>             (folio_test_anon(folio) && !folio_test_swapbacked(folio))) {
> 
> 
> .
>
Miaohe Lin April 12, 2022, 3:15 a.m. UTC | #4
On 2022/4/11 22:16, Christoph Hellwig wrote:
> On Sat, Apr 09, 2022 at 05:34:52PM +0800, Miaohe Lin wrote:
>> The MADV_FREE pages check in folio_check_dirty_writeback is a bit hard to
>> follow. Add a comment to make the code clear.
>>
>> Suggested-by: Huang, Ying <ying.huang@intel.com>
>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>> ---
>>  mm/vmscan.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/mm/vmscan.c b/mm/vmscan.c
>> index c77d5052f230..4a76be47bed1 100644
>> --- a/mm/vmscan.c
>> +++ b/mm/vmscan.c
>> @@ -1436,6 +1436,9 @@ static void folio_check_dirty_writeback(struct folio *folio,
>>  	/*
>>  	 * Anonymous pages are not handled by flushers and must be written
>>  	 * from reclaim context. Do not stall reclaim based on them
> 
> While you touch this please add a period at the end of the above
> sentence.

Will do.

> 
> Otherwise looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Many thanks for review!

> .
>
Oscar Salvador April 12, 2022, 8:44 a.m. UTC | #5
On Sat, Apr 09, 2022 at 05:34:52PM +0800, Miaohe Lin wrote:
> The MADV_FREE pages check in folio_check_dirty_writeback is a bit hard to
> follow. Add a comment to make the code clear.
> 
> Suggested-by: Huang, Ying <ying.huang@intel.com>
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Reviewed-by: Oscar Salvador <osalvador@suse.de>
diff mbox series

Patch

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c77d5052f230..4a76be47bed1 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1436,6 +1436,9 @@  static void folio_check_dirty_writeback(struct folio *folio,
 	/*
 	 * Anonymous pages are not handled by flushers and must be written
 	 * from reclaim context. Do not stall reclaim based on them
+	 * MADV_FREE anonymous pages are put into inactive file list too.
+	 * They could be mistakenly treated as file lru. So further anon
+	 * test is needed.
 	 */
 	if (!folio_is_file_lru(folio) ||
 	    (folio_test_anon(folio) && !folio_test_swapbacked(folio))) {