Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Longlong Xia <xialonglong2025@163.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: hannes@cmpxchg.org, yosry@kernel.org, nphamcs@gmail.com,
	chengming.zhou@linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Longlong Xia <xialonglong@kylinos.cn>
Subject: Re: [PATCH 1/1] mm/zswap: enable static key after runtime pool recovery
Date: Sun, 6 Sep 2026 08:31:32 +0800	[thread overview]
Message-ID: <b2a66985-ede1-433b-aff0-4d2acc5c027b@163.com> (raw)
In-Reply-To: <20260905160926.9836f2ca0dc977b89f2f146e@linux-foundation.org>

Thanks for taking a look.

在 2026/9/6 7:09, Andrew Morton 写道:
> On Sat,  5 Sep 2026 20:50:28 +0800 Longlong Xia <xialonglong2025@163.com> wrote:
>
>> From: Longlong Xia <xialonglong@kylinos.cn>
>>
>> When CONFIG_ZSWAP_DEFAULT_ON is disabled, zswap_setup() can complete
>> without a pool after a failed initial pool creation. A later compressor
>> parameter update can create and publish a pool, but does not enable
>> zswap_ever_enabled.
>>
>> If users then enable zswap, zswap_store() intercepts swapout while
>> zswap_load() still returns -ENOENT without consulting the xarray. The
>> swapin path therefore reads a stale backing swap slot because the store
>> skipped writing it.
> That sounds bad.  I'll leave it to reviewers to suggest whether this is
> a sufficient description of the runtime effects, and to decide whether
> a backport is appropriate.  Please.
>
>> Enable the static key after a successful compressor and pool update. Do
>> this outside zswap_pools_lock because static key updates may sleep.
>>
>> Verified with fault injection on a stock kernel (compressor builtin,
>> CONFIG_ZSWAP_DEFAULT_ON=n):
>>
>>    1. Boot with zswap.enabled=1; pool creation fails, init completes
>>       pool-less (static key off).
>>    2. Echo an available compressor name to zswap.compressor; a pool is
>>       recovered but the key stays off.
>>    3. Enable zswap.
>>    4. madvise(MADV_PAGEOUT) a pattern-verified 512 MiB region, then
>>       fault it back in and verify.
>>
>> Step 4 reads back 131072/131072 zeroed pages (zswpin=0, zswpout=131072)
>> without this patch; all pages intact (zswpin=131072) with it.
> And thanks.  Sashiko might have found another issue in this zswap code:
> 	https://sashiko.dev/#/patchset/20260905125101.2970456-1-xialonglong2025@163.com

I'll send a separate fix patch.


Thanks,

Longlong




  reply	other threads:[~2026-09-06  0:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05 12:50 [PATCH 1/1] mm/zswap: enable static key after runtime pool recovery Longlong Xia
2026-09-05 23:09 ` Andrew Morton
2026-09-06  0:31   ` Longlong Xia [this message]
2026-09-06  9:19   ` Yosry Ahmed
2026-09-07 11:00     ` Usama Arif
2026-09-07 11:34       ` Yosry Ahmed
2026-09-07 16:22         ` Usama Arif
2026-09-06  9:09 ` Yosry Ahmed
2026-09-06 13:36   ` [PATCH v2 1/1] mm/zswap: enable zswap_ever_enabled in zswap_pool_create() Longlong Xia
2026-09-06 13:43     ` Yosry Ahmed
2026-09-06 13:59       ` [PATCH v3 " Longlong Xia

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=b2a66985-ede1-433b-aff0-4d2acc5c027b@163.com \
    --to=xialonglong2025@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=xialonglong@kylinos.cn \
    --cc=yosry@kernel.org \
    /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