From: Johannes Weiner <hannes@cmpxchg.org>
To: Alexandre Ghiti <alex@ghiti.fr>
Cc: Yosry Ahmed <yosry@kernel.org>, Nhat Pham <nphamcs@gmail.com>,
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:47:30 -0400 [thread overview]
Message-ID: <al9cUqWH-72HUAG_@cmpxchg.org> (raw)
In-Reply-To: <20260718093723.153324-2-alex@ghiti.fr>
On Sat, Jul 18, 2026 at 11:36:39AM +0200, Alexandre Ghiti 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))
> + goto out;
> +
> + /* Raced: the folio is now owned by the swapin; put it back on the LRU. */
> + folio_add_lru(folio);
> +out:
> + folio_unlock(folio);
> + folio_put(folio);
> +}
Is this actually zswap-specific or should it be just swap code?
Both this function and the dropbehind queue in the next patch seem
like they could be reused if we wanted to make the generic swapout
path do dropbehind as well.
It looks odd in the next patch to have a generic swapcache &&
dropbehind check and then call zswap code.
next prev parent reply other threads:[~2026-07-21 11:47 UTC|newest]
Thread overview: 15+ 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
2026-07-21 13:51 ` Alexandre Ghiti
2026-07-21 11:47 ` Johannes Weiner [this message]
2026-07-21 13:55 ` Alexandre Ghiti
2026-07-22 2:38 ` Barry Song
2026-07-22 6:31 ` Kairui Song
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=al9cUqWH-72HUAG_@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox