From: Johannes Weiner <hannes@cmpxchg.org>
To: Nhat Pham <nphamcs@gmail.com>
Cc: Alexandre Ghiti <alex@ghiti.fr>, Yosry Ahmed <yosry@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Chengming Zhou <chengming.zhou@linux.dev>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Jan Kara <jack@suse.cz>, Kemeng Shi <shikemeng@huaweicloud.com>,
Baoquan He <baoquan.he@linux.dev>, Barry Song <baohua@kernel.org>,
Youngjun Park <youngjun.park@lge.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: zswap: free synchronous-IO writeback folios directly
Date: Tue, 21 Jul 2026 07:33:18 -0400 [thread overview]
Message-ID: <al9Y_tZH5AzDkK5K@cmpxchg.org> (raw)
In-Reply-To: <CAKEwX=Nn0dMc1K9drXFVMwt7wMZ2P6KToeh7T3rE1+Xq5yrCFw@mail.gmail.com>
On Mon, Jul 20, 2026 at 08:56:32AM -0700, Nhat Pham wrote:
> > @@ -972,6 +972,30 @@ static bool zswap_decompress(struct zswap_entry *entry, struct folio *folio)
> > /*********************************
> > * writeback code
> > **********************************/
> > +static void zswap_writeback_free_folio(struct folio *folio)
> > +{
> > + folio_lock(folio);
> > +
> > + /* The folio was allocated off the LRU and nothing re-adds it here. */
> > + VM_WARN_ON_ONCE_FOLIO(folio_test_lru(folio), folio);
> > +
> > + /*
> > + * Gate remove_mapping() on folio_test_swapcache(): a racing swapin may
> > + * have freed the swap slot (folio_free_swap()) and dropped the folio from
> > + * the cache, and remove_mapping() must not run on a non-swapcache folio
> > + * (it would trip __remove_mapping()'s mapping == folio_mapping() check).
> > + */
> > + if (folio_test_swapcache(folio) &&
> > + remove_mapping(swap_address_space(folio->swap), folio))
>
> Hmm I think you also have to test for writeback and dirty here right?
>
> After a racing swapin freed the swap slot, the folio might be dirtied
> and swapped out again. We probably shouldn't try to remove_mapping()
> such a folio?
remove_mapping() itself handles dirty state. It fails in that case.
next prev parent reply other threads:[~2026-07-21 11:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 9:36 [PATCH 0/2] mm: zswap: free cold writeback folios promptly Alexandre Ghiti
2026-07-18 9:36 ` [PATCH 1/2] mm: zswap: free synchronous-IO writeback folios directly Alexandre Ghiti
2026-07-18 11:10 ` Kairui Song
2026-07-20 15:56 ` Nhat Pham
2026-07-21 11:33 ` Johannes Weiner [this message]
2026-07-21 13:51 ` Alexandre Ghiti
2026-07-21 11:47 ` Johannes Weiner
2026-07-21 13:55 ` Alexandre Ghiti
2026-07-22 2:38 ` Barry Song
2026-07-22 6:31 ` Kairui Song
2026-07-23 13:39 ` Johannes Weiner
2026-07-23 15:38 ` Nhat Pham
2026-07-23 15:49 ` Nhat Pham
2026-07-18 9:36 ` [PATCH 2/2] mm: zswap: deferred dropbehind free of writeback folios Alexandre Ghiti
2026-07-20 15:57 ` Nhat Pham
2026-07-21 13:54 ` Alexandre Ghiti
2026-07-20 18:25 ` [PATCH 0/2] mm: zswap: free cold writeback folios promptly Yosry Ahmed
2026-07-21 13:54 ` Alexandre Ghiti
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=al9Y_tZH5AzDkK5K@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=baohua@kernel.org \
--cc=baoquan.he@linux.dev \
--cc=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=jack@suse.cz \
--cc=kasong@tencent.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=shikemeng@huaweicloud.com \
--cc=willy@infradead.org \
--cc=yosry@kernel.org \
--cc=youngjun.park@lge.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.