linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chris Li <chrisl@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Kemeng Shi <shikemeng@huaweicloud.com>,
	Kairui Song <kasong@tencent.com>,  Nhat Pham <nphamcs@gmail.com>,
	Baoquan He <bhe@redhat.com>, Barry Song <baohua@kernel.org>,
	 "Huang, Ying" <ying.huang@linux.alibaba.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/swapfile.c: introduce function alloc_swap_scan_list()
Date: Wed, 6 Aug 2025 16:25:03 -0700	[thread overview]
Message-ID: <CANeU7QkxNfe5Ut8AnyJYV4eQOS4=aL6ni3EAcdfdgTTZ2vG41g@mail.gmail.com> (raw)
In-Reply-To: <20250806153146.ee1ee22dc8f6381ff5a6d882@linux-foundation.org>

Hi Andrew,

Thanks for the feedback.

On Wed, Aug 6, 2025 at 3:31 PM Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Wed, 06 Aug 2025 10:34:45 -0700 Chris Li <chrisl@kernel.org> wrote:
>
> > This the alloc_swap_scan_list() will scan the whole list or the first
> > cluster.
> >
> > This reduces the repeat patterns of isolating a cluster then scanning
> > that cluster. As a result, cluster_alloc_swap_entry() is shorter and shallower.
> >
> > No functional change.
> > ...
> >
> > ---
> >  mm/swapfile.c | 86 ++++++++++++++++++++++++++++++++---------------------------
> >  1 file changed, 47 insertions(+), 39 deletions(-)
>
> A nice little patch.
>
> > diff --git a/mm/swapfile.c b/mm/swapfile.c
> > index 4a0cf4fb348d..fcb1e57d8108 100644
> > --- a/mm/swapfile.c
> > +++ b/mm/swapfile.c
> > @@ -820,6 +820,29 @@ static unsigned int alloc_swap_scan_cluster(struct swap_info_struct *si,
> >       return found;
> >  }
> >
> > +static unsigned int alloc_swap_scan_list(struct swap_info_struct *si,
> > +                                      struct list_head *list,
> > +                                      unsigned int order,
> > +                                      unsigned char usage,
> > +                                      bool scan_all)
> > +{
> > +     int found = SWAP_ENTRY_INVALID;
>
> but this function returns an unsigned int

Will fix it in the next version.

>
> > +
> > +     do {
> > +             struct swap_cluster_info *ci = isolate_lock_cluster(si, list);
> > +             unsigned long offset;
> > +
> > +             if (!ci)
> > +                     break;
> > +             offset = cluster_offset(si, ci);
> > +             found = alloc_swap_scan_cluster(si, ci, offset, order, usage);
>
> so does that one
>
> > +             if (found)
> > +                     return found;
>
> `break' here.  To avoid multiple return points and for consistency.

Will do.

Chris


      reply	other threads:[~2025-08-06 23:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 17:34 Chris Li
2025-08-06 22:31 ` Andrew Morton
2025-08-06 23:25   ` Chris Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANeU7QkxNfe5Ut8AnyJYV4eQOS4=aL6ni3EAcdfdgTTZ2vG41g@mail.gmail.com' \
    --to=chrisl@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=bhe@redhat.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=ying.huang@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox