[PATCH] mm: update outdated comments for removed scan_swap_map_slots()

Kexin Sun posted 1 patch 1 week, 6 days ago
mm/page_io.c | 4 ++--
mm/vmscan.c  | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
[PATCH] mm: update outdated comments for removed scan_swap_map_slots()
Posted by Kexin Sun 1 week, 6 days ago
The function scan_swap_map_slots() was removed in commit
0ff67f990bd4 ("mm, swap: remove swap slot cache").

The three comments referencing it simply noted that ->flags can be
updated non-atomically by scan_swap_map_slots() to justify a
data_race() annotation.  Since the function no longer exists, drop
the parenthetical reference while keeping the data_race()
justification intact: ->flags can still be updated non-atomically
by other paths (e.g., swapoff clearing SWP_WRITEOK).

Assisted-by: unnamed:deepseek-v3.2 coccinelle
Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
---
 mm/page_io.c | 4 ++--
 mm/vmscan.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index a2c034660c80..330abc5ab7b4 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -450,14 +450,14 @@ void __swap_writepage(struct folio *folio, struct swap_iocb **swap_plug)
 
 	VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio);
 	/*
-	 * ->flags can be updated non-atomically (scan_swap_map_slots),
+	 * ->flags can be updated non-atomically,
 	 * but that will never affect SWP_FS_OPS, so the data_race
 	 * is safe.
 	 */
 	if (data_race(sis->flags & SWP_FS_OPS))
 		swap_writepage_fs(folio, swap_plug);
 	/*
-	 * ->flags can be updated non-atomically (scan_swap_map_slots),
+	 * ->flags can be updated non-atomically,
 	 * but that will never affect SWP_SYNCHRONOUS_IO, so the data_race
 	 * is safe.
 	 */
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 0fc9373e8251..0758ef3b100b 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1070,7 +1070,7 @@ static bool may_enter_fs(struct folio *folio, gfp_t gfp_mask)
 	/*
 	 * We can "enter_fs" for swap-cache with only __GFP_IO
 	 * providing this isn't SWP_FS_OPS.
-	 * ->flags can be updated non-atomically (scan_swap_map_slots),
+	 * ->flags can be updated non-atomically,
 	 * but that will never affect SWP_FS_OPS, so the data_race
 	 * is safe.
 	 */
-- 
2.25.1
Re: [PATCH] mm: update outdated comments for removed scan_swap_map_slots()
Posted by Lorenzo Stoakes (Oracle) 1 week, 4 days ago
-cc old email address +cc new

(Gentle hint to send new mail to ljs@kernel.org :)

On Sat, Mar 21, 2026 at 06:58:14PM +0800, Kexin Sun wrote:
> The function scan_swap_map_slots() was removed in commit
> 0ff67f990bd4 ("mm, swap: remove swap slot cache").
>
> The three comments referencing it simply noted that ->flags can be
> updated non-atomically by scan_swap_map_slots() to justify a
> data_race() annotation.  Since the function no longer exists, drop
> the parenthetical reference while keeping the data_race()
> justification intact: ->flags can still be updated non-atomically
> by other paths (e.g., swapoff clearing SWP_WRITEOK).
>
> Assisted-by: unnamed:deepseek-v3.2 coccinelle
> Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>

LGTM, so:

Reviewed-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>

> ---
>  mm/page_io.c | 4 ++--
>  mm/vmscan.c  | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/mm/page_io.c b/mm/page_io.c
> index a2c034660c80..330abc5ab7b4 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -450,14 +450,14 @@ void __swap_writepage(struct folio *folio, struct swap_iocb **swap_plug)
>
>  	VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio);
>  	/*
> -	 * ->flags can be updated non-atomically (scan_swap_map_slots),
> +	 * ->flags can be updated non-atomically,
>  	 * but that will never affect SWP_FS_OPS, so the data_race
>  	 * is safe.
>  	 */
>  	if (data_race(sis->flags & SWP_FS_OPS))
>  		swap_writepage_fs(folio, swap_plug);
>  	/*
> -	 * ->flags can be updated non-atomically (scan_swap_map_slots),
> +	 * ->flags can be updated non-atomically,
>  	 * but that will never affect SWP_SYNCHRONOUS_IO, so the data_race
>  	 * is safe.
>  	 */
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 0fc9373e8251..0758ef3b100b 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1070,7 +1070,7 @@ static bool may_enter_fs(struct folio *folio, gfp_t gfp_mask)
>  	/*
>  	 * We can "enter_fs" for swap-cache with only __GFP_IO
>  	 * providing this isn't SWP_FS_OPS.
> -	 * ->flags can be updated non-atomically (scan_swap_map_slots),
> +	 * ->flags can be updated non-atomically,
>  	 * but that will never affect SWP_FS_OPS, so the data_race
>  	 * is safe.
>  	 */
> --
> 2.25.1
>
Re: [PATCH] mm: update outdated comments for removed scan_swap_map_slots()
Posted by David Hildenbrand (Arm) 1 week, 4 days ago
On 3/21/26 11:58, Kexin Sun wrote:
> The function scan_swap_map_slots() was removed in commit
> 0ff67f990bd4 ("mm, swap: remove swap slot cache").
> 
> The three comments referencing it simply noted that ->flags can be
> updated non-atomically by scan_swap_map_slots() to justify a
> data_race() annotation.  Since the function no longer exists, drop
> the parenthetical reference while keeping the data_race()
> justification intact: ->flags can still be updated non-atomically
> by other paths (e.g., swapoff clearing SWP_WRITEOK).
> 
> Assisted-by: unnamed:deepseek-v3.2 coccinelle
> Signed-off-by: Kexin Sun <kexinsun@smail.nju.edu.cn>
> ---

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David