[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMgjq7C+2snKqZm1BKK8jNjkeot9dO1tPx=f7Jt1gBvDvWggAg@mail.gmail.com>
Date: Thu, 8 Jan 2026 00:05:21 +0800
From: Kairui Song <ryncsn@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-mm@...ck.org, Baoquan He <bhe@...hat.com>, Barry Song <baohua@...nel.org>,
Chris Li <chrisl@...nel.org>, Nhat Pham <nphamcs@...il.com>,
Yosry Ahmed <yosry.ahmed@...ux.dev>, David Hildenbrand <david@...nel.org>,
Johannes Weiner <hannes@...xchg.org>, Youngjun Park <youngjun.park@....com>,
Hugh Dickins <hughd@...gle.com>, Baolin Wang <baolin.wang@...ux.alibaba.com>,
Ying Huang <ying.huang@...ux.alibaba.com>, Kemeng Shi <shikemeng@...weicloud.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>, linux-kernel@...r.kernel.org,
linux-pm@...r.kernel.org, "Rafael J. Wysocki (Intel)" <rafael@...nel.org>
Subject: Re: [PATCH v5 14/19] mm, swap: cleanup swap entry management workflow
On Mon, Dec 22, 2025 at 10:43 AM Kairui Song <ryncsn@...il.com> wrote:
>
> On Sat, Dec 20, 2025 at 12:02 PM Baoquan He <bhe@...hat.com> wrote:
> >
> > On 12/20/25 at 03:43am, Kairui Song wrote:
> > > From: Kairui Song <kasong@...cent.com>
> > >
> > > The current swap entry allocation/freeing workflow has never had a clear
> > > definition. This makes it hard to debug or add new optimizations.
> > >
> > > This commit introduces a proper definition of how swap entries would be
> > > allocated and freed. Now, most operations are folio based, so they will
> > > never exceed one swap cluster, and we now have a cleaner border between
> > > swap and the rest of mm, making it much easier to follow and debug,
> > > especially with new added sanity checks. Also making more optimization
> > > possible.
> > >
> > > Swap entry will be mostly allocated and free with a folio bound.
> > ~~~~
> > freed, typo
>
> Ack, nice catch.
>
> > > The folio lock will be useful for resolving many swap ralated races.
> > >
> > > Now swap allocation (except hibernation) always starts with a folio in
> > > the swap cache, and gets duped/freed protected by the folio lock:
> > >
> > > - folio_alloc_swap() - The only allocation entry point now.
> > > Context: The folio must be locked.
> > > This allocates one or a set of continuous swap slots for a folio and
> > > binds them to the folio by adding the folio to the swap cache. The
> > > swap slots' swap count start with zero value.
> > >
> > > - folio_dup_swap() - Increase the swap count of one or more entries.
> > > Context: The folio must be locked and in the swap cache. For now, the
> > > caller still has to lock the new swap entry owner (e.g., PTL).
> > > This increases the ref count of swap entries allocated to a folio.
> > > Newly allocated swap slots' count has to be increased by this helper
> > > as the folio got unmapped (and swap entries got installed).
> > >
> > > - folio_put_swap() - Decrease the swap count of one or more entries.
> > > Context: The folio must be locked and in the swap cache. For now, the
> > > caller still has to lock the new swap entry owner (e.g., PTL).
> > > This decreases the ref count of swap entries allocated to a folio.
> > > Typically, swapin will decrease the swap count as the folio got
> > > installed back and the swap entry got uninstalled
> > >
> > > This won't remove the folio from the swap cache and free the
> > > slot. Lazy freeing of swap cache is helpful for reducing IO.
> > > There is already a folio_free_swap() for immediate cache reclaim.
> > > This part could be further optimized later.
> > >
> > > The above locking constraints could be further relaxed when the swap
> > > table if fully implemented. Currently dup still needs the caller
> > ~~ s/if/is/ typo
>
> Ack, Thanks!
Hi Andrew,
There are no other problems reported with the series so far, for the
two typos here, could you help update the commit message?
Powered by blists - more mailing lists