[PATCH 06/12] mm/swapfile.c: update the code comment above swap_count_continued()

Baoquan He posted 12 patches 10 months, 1 week ago
[PATCH 06/12] mm/swapfile.c: update the code comment above swap_count_continued()
Posted by Baoquan He 10 months, 1 week ago
Now, swap_count_continued() has two callers, __swap_duplicate() and
__swap_entry_free_locked(), the relevant code comment is stale.
Update it to reflect the current situation.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
 mm/swapfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index bf284ba16198..9ee2238042a5 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3789,8 +3789,8 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
  * into, carry if so, or else fail until a new continuation page is allocated;
  * when the original swap_map count is decremented from 0 with continuation,
  * borrow from the continuation and report whether it still holds more.
- * Called while __swap_duplicate() or swap_entry_free() holds swap or cluster
- * lock.
+ * Called while __swap_duplicate() or caller of __swap_entry_free_locked()
+ * holds swap or cluster lock.
  */
 static bool swap_count_continued(struct swap_info_struct *si,
 				 pgoff_t offset, unsigned char count)
-- 
2.41.0
Re: [PATCH 06/12] mm/swapfile.c: update the code comment above swap_count_continued()
Posted by Kairui Song 10 months, 1 week ago
On Wed, Feb 5, 2025 at 5:28 PM Baoquan He <bhe@redhat.com> wrote:
>
> Now, swap_count_continued() has two callers, __swap_duplicate() and
> __swap_entry_free_locked(), the relevant code comment is stale.
> Update it to reflect the current situation.
>
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  mm/swapfile.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index bf284ba16198..9ee2238042a5 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -3789,8 +3789,8 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
>   * into, carry if so, or else fail until a new continuation page is allocated;
>   * when the original swap_map count is decremented from 0 with continuation,
>   * borrow from the continuation and report whether it still holds more.
> - * Called while __swap_duplicate() or swap_entry_free() holds swap or cluster
> - * lock.
> + * Called while __swap_duplicate() or caller of __swap_entry_free_locked()
> + * holds swap or cluster lock.

It should be only "cluster lock" not "swap or cluster lock" now?

>   */
>  static bool swap_count_continued(struct swap_info_struct *si,
>                                  pgoff_t offset, unsigned char count)
> --
> 2.41.0
>
Re: [PATCH 06/12] mm/swapfile.c: update the code comment above swap_count_continued()
Posted by Baoquan He 10 months, 1 week ago
On 02/06/25 at 03:50pm, Kairui Song wrote:
> On Wed, Feb 5, 2025 at 5:28 PM Baoquan He <bhe@redhat.com> wrote:
> >
> > Now, swap_count_continued() has two callers, __swap_duplicate() and
> > __swap_entry_free_locked(), the relevant code comment is stale.
> > Update it to reflect the current situation.
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > ---
> >  mm/swapfile.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > index bf284ba16198..9ee2238042a5 100644
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -3789,8 +3789,8 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
> >   * into, carry if so, or else fail until a new continuation page is allocated;
> >   * when the original swap_map count is decremented from 0 with continuation,
> >   * borrow from the continuation and report whether it still holds more.
> > - * Called while __swap_duplicate() or swap_entry_free() holds swap or cluster
> > - * lock.
> > + * Called while __swap_duplicate() or caller of __swap_entry_free_locked()
> > + * holds swap or cluster lock.
> 
> It should be only "cluster lock" not "swap or cluster lock" now?

You are right, I will update.

> 
> >   */
> >  static bool swap_count_continued(struct swap_info_struct *si,
> >                                  pgoff_t offset, unsigned char count)
> > --
> > 2.41.0
> >
> 

[PATCH v2 06/12] mm/swapfile.c: update the code comment above swap_count_continued()
Posted by Baoquan He 10 months, 1 week ago
Now, swap_count_continued() has two callers, __swap_duplicate() and
__swap_entry_free_locked(), the relevant code comment is stale.
Update it to reflect the current situation.

Signed-off-by: Baoquan He <bhe@redhat.com>
---
v1->v2:
- Update the code comment according to Kairui's comment.

 mm/swapfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/swapfile.c b/mm/swapfile.c
index bf284ba16198..f6cc169f59d9 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3789,8 +3789,8 @@ int add_swap_count_continuation(swp_entry_t entry, gfp_t gfp_mask)
  * into, carry if so, or else fail until a new continuation page is allocated;
  * when the original swap_map count is decremented from 0 with continuation,
  * borrow from the continuation and report whether it still holds more.
- * Called while __swap_duplicate() or swap_entry_free() holds swap or cluster
- * lock.
+ * Called while __swap_duplicate() or caller of __swap_entry_free_locked()
+ * holds cluster lock.
  */
 static bool swap_count_continued(struct swap_info_struct *si,
 				 pgoff_t offset, unsigned char count)
-- 
2.41.0