From: Chengming Zhou <zhouchengming@bytedance.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Yosry Ahmed <yosryahmed@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 5/6] mm/zswap: only support zswap_exclusive_loads_enabled
Date: Fri, 2 Feb 2024 20:57:38 +0800 [thread overview]
Message-ID: <d5455b43-aa22-4931-a6b3-062128f4d30f@bytedance.com> (raw)
In-Reply-To: <20240201181240.GE321148@cmpxchg.org>
On 2024/2/2 02:12, Johannes Weiner wrote:
> On Thu, Feb 01, 2024 at 03:49:05PM +0000, Chengming Zhou wrote:
>> The !zswap_exclusive_loads_enabled mode will leave compressed copy in
>> the zswap tree and lru list after the folio swapin.
>>
>> There are some disadvantages in this mode:
>> 1. It's a waste of memory since there are two copies of data, one is
>> folio, the other one is compressed data in zswap. And it's unlikely
>> the compressed data is useful in the near future.
>>
>> 2. If that folio is dirtied, the compressed data must be not useful,
>> but we don't know and don't invalidate the trashy memory in zswap.
>>
>> 3. It's not reclaimable from zswap shrinker since zswap_writeback_entry()
>> will always return -EEXIST and terminate the shrinking process.
>>
>> On the other hand, the only downside of zswap_exclusive_loads_enabled
>> is a little more cpu usage/latency when compression, and the same if
>> the folio is removed from swapcache or dirtied.
>>
>> Not sure if we should accept the above disadvantages in the case of
>> !zswap_exclusive_loads_enabled, so send this out for disscusion.
>>
>> Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
>
> This is interesting.
>
> First, I will say that I never liked this config option, because it's
> nearly impossible for a user to answer this question. Much better to
> just pick a reasonable default.
Agree.
>
> What should the default be?
>
> Caching "swapout work" is helpful when the system is thrashing. Then
> recently swapped in pages might get swapped out again very soon. It
> certainly makes sense with conventional swap, because keeping a clean
> copy on the disk saves IO work and doesn't cost any additional memory.
>
> But with zswap, it's different. It saves some compression work on a
> thrashing page. But the act of keeping compressed memory contributes
> to a higher rate of thrashing. And that can cause IO in other places
> like zswap writeback and file memory.
>
> It would be useful to have an A/B test to confirm that not caching is
> better. Can you run your test with and without keeping the cache, and
> in addition to the timings also compare the deltas for pgscan_anon,
> pgscan_file, workingset_refault_anon, workingset_refault_file?
I just A/B test kernel building in tmpfs directory, memory.max=2GB.
(zswap writeback enabled and shrinker_enabled, one 50GB swapfile)
From the below results, exclusive mode has fewer scan and refault.
zswap-invalidate-entry zswap-invalidate-entry-exclusive
real 63.80 63.01
user 1063.83 1061.32
sys 290.31 266.15
zswap-invalidate-entry zswap-invalidate-entry-exclusive
workingset_refault_anon 2383084.40 1976397.40
workingset_refault_file 44134.00 45689.40
workingset_activate_anon 837878.00 728441.20
workingset_activate_file 4710.00 4085.20
workingset_restore_anon 732622.60 639428.40
workingset_restore_file 1007.00 926.80
workingset_nodereclaim 0.00 0.00
pgscan 14343003.40 12409570.20
pgscan_kswapd 0.00 0.00
pgscan_direct 14343003.40 12409570.20
pgscan_khugepaged 0.00 0.00
next prev parent reply other threads:[~2024-02-02 12:57 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 15:49 [PATCH 0/6] mm/zswap: optimize zswap lru list Chengming Zhou
2024-02-01 15:49 ` [PATCH 1/6] mm/zswap: add more comments in shrink_memcg_cb() Chengming Zhou
2024-02-01 17:45 ` Johannes Weiner
2024-02-01 23:55 ` Yosry Ahmed
2024-02-02 22:25 ` Nhat Pham
2024-02-01 15:49 ` [PATCH 2/6] mm/zswap: invalidate zswap entry when swap entry free Chengming Zhou
2024-02-01 17:49 ` Johannes Weiner
2024-02-01 20:56 ` Nhat Pham
2024-02-02 0:11 ` Yosry Ahmed
2024-02-02 8:10 ` Chengming Zhou
2024-02-01 15:49 ` [PATCH 3/6] mm/zswap: stop lru list shrinking when encounter warm region Chengming Zhou
2024-02-01 17:51 ` Johannes Weiner
2024-02-01 18:10 ` Nhat Pham
2024-02-02 0:15 ` Yosry Ahmed
2024-02-02 8:12 ` Chengming Zhou
2024-02-01 15:49 ` [PATCH 4/6] mm/zswap: remove duplicate_entry debug value Chengming Zhou
2024-02-01 17:55 ` Johannes Weiner
2024-02-02 8:18 ` Chengming Zhou
2024-02-02 22:17 ` Yosry Ahmed
2024-02-02 22:28 ` Nhat Pham
2024-02-03 4:29 ` Chengming Zhou
2024-02-01 15:49 ` [PATCH 5/6] mm/zswap: only support zswap_exclusive_loads_enabled Chengming Zhou
2024-02-01 18:12 ` Johannes Weiner
2024-02-02 1:04 ` Yosry Ahmed
2024-02-02 12:57 ` Chengming Zhou [this message]
2024-02-02 16:26 ` Johannes Weiner
2024-02-03 4:33 ` Chengming Zhou
2024-02-02 22:15 ` Yosry Ahmed
2024-02-02 22:31 ` Nhat Pham
2024-02-01 15:49 ` [PATCH 6/6] mm/zswap: zswap entry doesn't need refcount anymore Chengming Zhou
2024-02-02 1:11 ` Yosry Ahmed
2024-02-02 13:00 ` Chengming Zhou
2024-02-02 16:28 ` Johannes Weiner
2024-02-02 22:33 ` Nhat Pham
2024-02-02 22:36 ` Yosry Ahmed
2024-02-02 22:44 ` Nhat Pham
2024-02-03 5:09 ` Chengming Zhou
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=d5455b43-aa22-4931-a6b3-062128f4d30f@bytedance.com \
--to=zhouchengming@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=yosryahmed@google.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