From: Nhat Pham <nphamcs@gmail.com>
To: "Qun-wei Lin (林群崴)" <Qun-wei.Lin@mediatek.com>
Cc: "21cnbao@gmail.com" <21cnbao@gmail.com>,
"Andrew Yang (楊智強)" <Andrew.Yang@mediatek.com>,
"Casper Li (李中榮)" <casper.li@mediatek.com>,
"chrisl@kernel.org" <chrisl@kernel.org>,
"James Hsu (徐慶薰)" <James.Hsu@mediatek.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"ira.weiny@intel.com" <ira.weiny@intel.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"dave.jiang@intel.com" <dave.jiang@intel.com>,
"schatzberg.dan@gmail.com" <schatzberg.dan@gmail.com>,
"Chinwen Chang (張錦文)" <chinwen.chang@mediatek.com>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"ryan.roberts@arm.com" <ryan.roberts@arm.com>,
"minchan@kernel.org" <minchan@kernel.org>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"kasong@tencent.com" <kasong@tencent.com>,
"nvdimm@lists.linux.dev" <nvdimm@lists.linux.dev>,
"vishal.l.verma@intel.com" <vishal.l.verma@intel.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
"dan.j.williams@intel.com" <dan.j.williams@intel.com>
Subject: Re: [PATCH 0/2] Improve Zram by separating compression context from kswapd
Date: Mon, 10 Mar 2025 10:30:48 -0700 [thread overview]
Message-ID: <CAKEwX=Onwhy7FkB97tw4JonN3POj=dDp3ixsfS14=_3x3=KvuA@mail.gmail.com> (raw)
In-Reply-To: <CAKEwX=PNHik8O6swwRPsuDovtCNLxXRQUsiXZSSq8ZbzFvJV0w@mail.gmail.com>
On Mon, Mar 10, 2025 at 9:58 AM Nhat Pham <nphamcs@gmail.com> wrote:
>
> On Mon, Mar 10, 2025 at 6:22 AM Qun-wei Lin (林群崴)
> <Qun-wei.Lin@mediatek.com> wrote:
> >
> >
> > Thank you for your explanation. Compared to the original single kswapd,
> > we expect t1 to have a slight increase in re-scan time. However, since
> > our kcompressd can focus on compression tasks and we can have multiple
> > kcompressd instances (kcompressd0, kcompressd1, ...) running in
> > parallel, we anticipate that the number of times a folio needs be re-
> > scanned will not be too many.
> >
> > In our experiments, we fixed the CPU and DRAM at a certain frequency.
> > We created a high memory pressure enviroment using a memory eater and
> > recorded the increase in pgsteal_anon per second, which was around 300,
> > 000. Then we applied our patch and measured again, that pgsteal_anon/s
> > increased to over 800,000.
> >
> > > >
> > > > >
> > > > > Problem:
> > > > > In the current system, the kswapd thread is responsible for both
> > > > > scanning the LRU pages and compressing pages into the ZRAM. This
> > > > > combined responsibility can lead to significant performance
> > > > > bottlenecks,
> > > >
> > > > What bottleneck are we talking about? Is one stage slower than the
> > > > other?
> > > >
> > > > > especially under high memory pressure. The kswapd thread becomes
> > > > > a
> > > > > single point of contention, causing delays in memory reclaiming
> > > > > and
> > > > > overall system performance degradation.
> > > > >
> > > > > Target:
> > > > > The target of this invention is to improve the efficiency of
> > > > > memory
> > > > > reclaiming. By separating the tasks of page scanning and page
> > > > > compression into distinct processes or threads, the system can
> > > > > handle
> > > > > memory pressure more effectively.
> > > >
> > > > I'm not a zram maintainer, so I'm definitely not trying to stop
> > > > this
> > > > patch. But whatever problem zram is facing will likely occur with
> > > > zswap too, so I'd like to learn more :)
> > >
> > > Right, this is likely something that could be addressed more
> > > generally
> > > for zswap and zram.
> > >
> >
> > Yes, we also hope to extend this to other swap devices, but currently,
> > we have only modified zram. We are not very familiar with zswap and
> > would like to ask if anyone has any suggestions for modifications?
> >
>
> My understanding is right now schedule_bio_write is the work
> submission API right? We can make it generic, having it accept a
> callback and a generic untyped pointer which can be casted into a
> backend-specific context struct. For zram it would contain struct zram
> and the bio. For zswap, depending on at which point do you want to
> begin offloading the work - it could simply be just the folio itself
> if we offload early, or a more complicated scheme.
To expand a bit - zswap_store() is where all the logic lives. It's
fairly straightforward: checking zswap cgroup limits, acquire the
zswap pool (a combination of compression algorithm and backend memory
allocator, which is just zsmalloc now), perform compression, then ask
for a slot from zsmalloc and store it there.
You can probably just offload the whole thing here, or perform some
steps of the sequence before offloading the rest :) One slight
complication is don't forget to fallback to disk swapping - unlike
zram, zswap is originally designed as a "cache" for underlying swap
files on disk, which we can fallback to if the compression attempt
fails. Everything should be fairly straightforward though :)
>
>
>
> > > Thanks
> > > Barry
> >
> > Best Regards,
> > Qun-wei
> >
> >
next prev parent reply other threads:[~2025-03-10 17:31 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 12:01 Qun-Wei Lin
2025-03-07 12:01 ` [PATCH 1/2] mm: Split BLK_FEAT_SYNCHRONOUS and SWP_SYNCHRONOUS_IO into separate read and write flags Qun-Wei Lin
2025-03-07 12:01 ` [PATCH 2/2] kcompressd: Add Kcompressd for accelerated zram compression Qun-Wei Lin
2025-03-07 19:41 ` Barry Song
2025-03-07 23:13 ` Nhat Pham
2025-03-07 23:14 ` Nhat Pham
2025-03-10 13:26 ` Qun-wei Lin (林群崴)
[not found] ` <20250309010541.3152-1-hdanton@sina.com>
2025-03-09 19:56 ` Nhat Pham
2025-03-09 20:44 ` Barry Song
2025-03-09 22:20 ` Nhat Pham
2025-03-10 13:23 ` Qun-wei Lin (林群崴)
[not found] ` <20250310103427.3216-1-hdanton@sina.com>
2025-03-10 17:44 ` Barry Song
[not found] ` <20250310230902.3282-1-hdanton@sina.com>
2025-03-11 3:57 ` Barry Song
2025-03-11 6:36 ` Greg KH
2025-03-11 5:02 ` Sergey Senozhatsky
2025-03-10 13:26 ` Qun-wei Lin (林群崴)
2025-03-11 7:05 ` Barry Song
2025-03-11 7:25 ` Barry Song
2025-03-11 14:33 ` Qun-wei Lin (林群崴)
2025-03-07 19:34 ` [PATCH 0/2] Improve Zram by separating compression context from kswapd Barry Song
2025-03-10 13:21 ` Qun-wei Lin (林群崴)
2025-03-07 23:03 ` Nhat Pham
2025-03-08 5:41 ` Barry Song
2025-03-10 13:22 ` Qun-wei Lin (林群崴)
2025-03-10 16:58 ` Nhat Pham
2025-03-10 17:30 ` Nhat Pham [this message]
2025-03-11 4:58 ` Sergey Senozhatsky
2025-03-11 9:33 ` Barry Song
2025-03-11 14:12 ` Qun-wei Lin (林群崴)
2025-03-12 5:19 ` Sergey Senozhatsky
2025-03-12 18:11 ` Minchan Kim
2025-03-13 3:09 ` Sergey Senozhatsky
2025-03-13 3:45 ` Barry Song
2025-03-13 16:07 ` Minchan Kim
2025-03-13 16:58 ` Barry Song
2025-03-13 17:33 ` Minchan Kim
2025-03-13 20:37 ` Barry Song
2025-03-13 3:52 ` Barry Song
2025-03-13 9:30 ` Barry Song
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='CAKEwX=Onwhy7FkB97tw4JonN3POj=dDp3ixsfS14=_3x3=KvuA@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=21cnbao@gmail.com \
--cc=Andrew.Yang@mediatek.com \
--cc=James.Hsu@mediatek.com \
--cc=Qun-wei.Lin@mediatek.com \
--cc=akpm@linux-foundation.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=axboe@kernel.dk \
--cc=casper.li@mediatek.com \
--cc=chinwen.chang@mediatek.com \
--cc=chrisl@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=kasong@tencent.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=matthias.bgg@gmail.com \
--cc=minchan@kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=ryan.roberts@arm.com \
--cc=schatzberg.dan@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vishal.l.verma@intel.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