mm: swap: remove duplicate nr_swap_pages decrement in get_swap_page_of_type()
Subsystems (2)
Youngjun Park
reviewerPATCH 1/1 mm: swap: remove duplicate nr_swap_pages decrement in get_swap_page_of_type()
After commit 4f78252da887, nr_swap_pages is decremented in swap_range_alloc(). Since cluster_alloc_swap_entry() calls swap_range_alloc() internally, the decrement in get_swap_page_of_type() causes double-decrementing.
Remove the duplicate decrement.
mm/swapfile.c +1 -3
@@ -2020,10 +2020,8 @@ swp_entry_t get_swap_page_of_type(int type)local_lock (&percpu_swap_cluster.lock); offset =cluster_alloc_swap_entry (si,0 ,1 );local_unlock (&percpu_swap_cluster.lock); -if (offset) { +if (offset) entry =swp_entry (si->type, offset); -atomic_long_dec (&nr_swap_pages); - } }put_swap_device (si); }
Signature · 1 line
2.34.1
Quoted 7 lines · Youngjun Park
After commit
4f78252da887,nr_swap_pagesis decremented inswap_range_alloc(). Sincecluster_alloc_swap_entry()callsswap_range_alloc()internally, the decrement inget_swap_page_of_type()causes double-decrementing.Remove the duplicate decrement.
Thanks for the good catch. Indeed there is duplication, but only affects the hibernation usage of swap as far as I can tell. This bug is in v6.17-rc1 upwards including v6.17 as well. You might want to add the stable tag:
Hi Andrew,
Please apply. Can you add the above line or Youngjun needs to send out a new version to include the stable line?
Chris
Quoted 23 lines
Fixes 4f78252da887 ("mm: swap: move nr_swap_pages counter decrement from folio_alloc_swap() to swap_range_alloc()")Signed-off-by Youngjun Park <[email protected]>mm/swapfile.c +1
-4@@ -2020,10 +2020,8 @@ swp_entry_t get_swap_page_of_type(int type)local_lock (&percpu_swap_cluster.lock); offset =cluster_alloc_swap_entry (si,0 ,1 );local_unlock (&percpu_swap_cluster.lock); -if (offset) { +if (offset) entry =swp_entry (si->type, offset); -atomic_long_dec (&nr_swap_pages); - } }put_swap_device (si); } --2.34.1
YoungJun Park
reviewerQuoted 9 lines · Chris Li
Quoted 7 lines · Youngjun Park
After commit
4f78252da887,nr_swap_pagesis decremented inswap_range_alloc(). Sincecluster_alloc_swap_entry()callsswap_range_alloc()internally, the decrement inget_swap_page_of_type()causes double-decrementing.Remove the duplicate decrement.
Quoted 8 lines
Acked-by Chris Li <[email protected]>Thanks for the good catch. Indeed there is duplication, but only affects the hibernation usage of swap as far as I can tell. This bug is in v6.17-rc1 upwards including v6.17 as well. You might want to add the stable tag:
Cc [email protected] # v6.17-rc1
I add the Cc tag on v2 patch
Thank you for review
Best Regards,
Youngjun Park
Quoted 10 lines · Youngjun Park
After commit
4f78252da887,nr_swap_pagesis decremented inswap_range_alloc(). Sincecluster_alloc_swap_entry()callsswap_range_alloc()internally, the decrement inget_swap_page_of_type()causes double-decrementing.Remove the duplicate decrement.
Fixes 4f78252da887 ("mm: swap: move nr_swap_pages counter decrement from folio_alloc_swap() to swap_range_alloc()")Signed-off-by Youngjun Park <[email protected]>
As Chris mentioned, we need to add Cc: [email protected].
Otherwise,
YoungJun Park
reviewerQuoted 7 lines · Barry Song
Quoted 6 lines · Youngjun Park
After commit
4f78252da887,nr_swap_pagesis decremented inswap_range_alloc(). Sincecluster_alloc_swap_entry()callsswap_range_alloc()internally, the decrement inget_swap_page_of_type()causes double-decrementing.
Quoted 6 lines
Quoted 4 lines
Remove the duplicate decrement.
Fixes 4f78252da887 ("mm: swap: move nr_swap_pages counter decrement from folio_alloc_swap() to swap_range_alloc()")Signed-off-by Youngjun Park <[email protected]>As Chris mentioned, we need to add Cc: [email protected].
Okay I add on my v2 patch as Chris mentioned.
Quoted 3 lines
Otherwise,
Reviewed-by Barry Song <[email protected]>
Thank you for the review.
Best regards,
Youngjun Park