lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANeU7QkxNfe5Ut8AnyJYV4eQOS4=aL6ni3EAcdfdgTTZ2vG41g@mail.gmail.com>
Date: Wed, 6 Aug 2025 16:25:03 -0700
From: Chris Li <chrisl@...nel.org>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Kemeng Shi <shikemeng@...weicloud.com>, Kairui Song <kasong@...cent.com>, 
	Nhat Pham <nphamcs@...il.com>, Baoquan He <bhe@...hat.com>, Barry Song <baohua@...nel.org>, 
	"Huang, Ying" <ying.huang@...ux.alibaba.com>, linux-mm@...ck.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm/swapfile.c: introduce function alloc_swap_scan_list()

Hi Andrew,

Thanks for the feedback.

On Wed, Aug 6, 2025 at 3:31 PM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Wed, 06 Aug 2025 10:34:45 -0700 Chris Li <chrisl@...nel.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ