diff mbox series

[10/16] mm/migration: remove PG_writeback handle in folio_migrate_flags

Message ID 20220304093409.25829-11-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 4, 2022, 9:34 a.m. UTC
When newfolio reaches here, it's guaranteed that PG_writeback is not set
because caller ensures writeback must have been completed. Remove this
unneeded check and cleanup the relevant comment.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 mm/migrate.c | 12 ------------
 1 file changed, 12 deletions(-)

Comments

Andrew Morton March 7, 2022, 1:21 a.m. UTC | #1
On Fri, 4 Mar 2022 17:34:03 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:

> When newfolio reaches here, it's guaranteed that PG_writeback is not set
> because caller ensures writeback must have been completed. Remove this
> unneeded check and cleanup the relevant comment.

What guarantees that writeback cannot start after the caller has checked?

I see no such check in iomap_migrate_page()?

> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -549,18 +549,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
>  	if (!folio_test_hugetlb(folio))
>  		folio->private = NULL;
>  
> -	/*
> -	 * If any waiters have accumulated on the new page then
> -	 * wake them up.
> -	 */
> -	if (folio_test_writeback(newfolio))
> -		folio_end_writeback(newfolio);
> -
> -	/*
> -	 * PG_readahead shares the same bit with PG_reclaim.  The above
> -	 * end_page_writeback() may clear PG_readahead mistakenly, so set the
> -	 * bit after that.
> -	 */
>  	if (folio_test_readahead(folio))
>  		folio_set_readahead(newfolio);
>  

folio_migrate_flags() and folio_migrate_copy() are global,
export-to-modules functions but have no interface documentation.  That
was bad of us.  

I wonder why those two functions are exported to modules anyway.
Miaohe Lin March 7, 2022, 12:44 p.m. UTC | #2
On 2022/3/7 9:21, Andrew Morton wrote:
> On Fri, 4 Mar 2022 17:34:03 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:
> 
>> When newfolio reaches here, it's guaranteed that PG_writeback is not set
>> because caller ensures writeback must have been completed. Remove this
>> unneeded check and cleanup the relevant comment.
> 
> What guarantees that writeback cannot start after the caller has checked?

Drivers should set writeback flag under page lock. But I'am not sure this is always obeyed.

> 
> I see no such check in iomap_migrate_page()?

iomap_migrate_page acts as a migratepage callback. The check is actually done in __unmap_and_move.

> 
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -549,18 +549,6 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
>>  	if (!folio_test_hugetlb(folio))
>>  		folio->private = NULL;
>>  
>> -	/*
>> -	 * If any waiters have accumulated on the new page then
>> -	 * wake them up.
>> -	 */
>> -	if (folio_test_writeback(newfolio))
>> -		folio_end_writeback(newfolio);

IIUC, this should also be broken too. If a page can be flagged writeback under page lock,
we can't simply do folio_end_writeback here as page might still be under the use of drivers.
More works should be done to handle the case correctly.

>> -
>> -	/*
>> -	 * PG_readahead shares the same bit with PG_reclaim.  The above
>> -	 * end_page_writeback() may clear PG_readahead mistakenly, so set the
>> -	 * bit after that.
>> -	 */
>>  	if (folio_test_readahead(folio))
>>  		folio_set_readahead(newfolio);
>>  
> 
> folio_migrate_flags() and folio_migrate_copy() are global,
> export-to-modules functions but have no interface documentation.  That
> was bad of us.  
> 
> I wonder why those two functions are exported to modules anyway.

That's really a pity.

> .
> 

Many thanks for your comment and reply!
diff mbox series

Patch

diff --git a/mm/migrate.c b/mm/migrate.c
index cb970d201147..1de5289a4af0 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -549,18 +549,6 @@  void folio_migrate_flags(struct folio *newfolio, struct folio *folio)
 	if (!folio_test_hugetlb(folio))
 		folio->private = NULL;
 
-	/*
-	 * If any waiters have accumulated on the new page then
-	 * wake them up.
-	 */
-	if (folio_test_writeback(newfolio))
-		folio_end_writeback(newfolio);
-
-	/*
-	 * PG_readahead shares the same bit with PG_reclaim.  The above
-	 * end_page_writeback() may clear PG_readahead mistakenly, so set the
-	 * bit after that.
-	 */
 	if (folio_test_readahead(folio))
 		folio_set_readahead(newfolio);