From: Minchan Kim <minchan@kernel.org>
To: Barry Song <21cnbao@gmail.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
Qun-Wei Lin <qun-wei.lin@mediatek.com>,
Jens Axboe <axboe@kernel.dk>,
Vishal Verma <vishal.l.verma@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Chris Li <chrisl@kernel.org>, Ryan Roberts <ryan.roberts@arm.com>,
"Huang, Ying" <ying.huang@intel.com>,
Kairui Song <kasong@tencent.com>,
Dan Schatzberg <schatzberg.dan@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
nvdimm@lists.linux.dev, linux-mm@kvack.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Casper Li <casper.li@mediatek.com>,
Chinwen Chang <chinwen.chang@mediatek.com>,
Andrew Yang <andrew.yang@mediatek.com>,
James Hsu <james.hsu@mediatek.com>
Subject: Re: [PATCH 0/2] Improve Zram by separating compression context from kswapd
Date: Thu, 13 Mar 2025 10:33:00 -0700 [thread overview]
Message-ID: <Z9MWzDUxUigJrZXt@google.com> (raw)
In-Reply-To: <CAGsJ_4yaSx1vEiZdCouBveeH3D-bQDdvrhRpz=Kbvqn30Eh-nA@mail.gmail.com>
On Fri, Mar 14, 2025 at 05:58:00AM +1300, Barry Song wrote:
> On Fri, Mar 14, 2025 at 5:07 AM Minchan Kim <minchan@kernel.org> wrote:
> >
> > On Thu, Mar 13, 2025 at 04:45:54PM +1300, Barry Song wrote:
> > > On Thu, Mar 13, 2025 at 4:09 PM Sergey Senozhatsky
> > > <senozhatsky@chromium.org> wrote:
> > > >
> > > > On (25/03/12 11:11), Minchan Kim wrote:
> > > > > On Fri, Mar 07, 2025 at 08:01:02PM +0800, Qun-Wei Lin wrote:
> > > > > > This patch series introduces a new mechanism called kcompressd to
> > > > > > improve the efficiency of memory reclaiming in the operating system. The
> > > > > > main goal is to separate the tasks of page scanning and page compression
> > > > > > into distinct processes or threads, thereby reducing the load on the
> > > > > > kswapd thread and enhancing overall system performance under high memory
> > > > > > pressure conditions.
> > > > > >
> > > > > > 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,
> > > > > > especially under high memory pressure. The kswapd thread becomes a
> > > > > > single point of contention, causing delays in memory reclaiming and
> > > > > > overall system performance degradation.
> > > > >
> > > > > Isn't it general problem if backend for swap is slow(but synchronous)?
> > > > > I think zram need to support asynchrnous IO(can do introduce multiple
> > > > > threads to compress batched pages) and doesn't declare it's
> > > > > synchrnous device for the case.
> > > >
> > > > The current conclusion is that kcompressd will sit above zram,
> > > > because zram is not the only compressing swap backend we have.
> >
> > Then, how handles the file IO case?
>
> I didn't quite catch your question :-)
Sorry for not clear.
What I meant was zram is also used for fs backend storage, not only
for swapbackend. The multiple simultaneous compression can help the case,
too.
>
> >
> > >
> > > also. it is not good to hack zram to be aware of if it is kswapd
> > > , direct reclaim , proactive reclaim and block device with
> > > mounted filesystem.
> >
> > Why shouldn't zram be aware of that instead of just introducing
> > queues in the zram with multiple compression threads?
> >
>
> My view is the opposite of yours :-)
>
> Integrating kswapd, direct reclaim, etc., into the zram driver
> would violate layering principles. zram is purely a block device
That's the my question. What's the reason zram need to know about
kswapd, direct_reclaim and so on? I didn't understand your input.
> driver, and how it is used should be handled separately. Callers have
> greater flexibility to determine its usage, similar to how different
> I/O models exist in user space.
>
> Currently, Qun-Wei's patch checks whether the current thread is kswapd.
> If it is, compression is performed asynchronously by threads;
> otherwise, it is done in the current thread. In the future, we may
Okay, then, why should we do that without following normal asynchrnous
disk storage? VM justs put the IO request and sometimes congestion
control. Why is other logic needed for the case?
> have additional reclaim threads, such as for damon or
> madv_pageout, etc.
>
> > >
> > > so i am thinking sth as below
> > >
> > > page_io.c
> > >
> > > if (sync_device or zswap_enabled())
> > > schedule swap_writepage to a separate per-node thread
> >
> > I am not sure that's a good idea to mix a feature to solve different
> > layers. That wouldn't be only swap problem. Such an parallelism under
> > device is common technique these days and it would help file IO cases.
> >
>
> zswap and zram share the same needs, and handling this in page_io
> can benefit both through common code. It is up to the callers to decide
> the I/O model.
>
> I agree that "parallelism under the device" is a common technique,
> but our case is different—the device achieves parallelism with
> offload hardware, whereas we rely on CPUs, which can be scarce.
> These threads may also preempt CPUs that are critically needed
> by other non-compression tasks, and burst power consumption
> can sometimes be difficult to control.
That's general problem for common resources in the system and always
trace-off domain in the workload areas. Eng folks has tried to tune
them statically/dynamically depending on system behavior considering
what they priorites.
>
> > Furthermore, it would open the chance for zram to try compress
> > multiple pages at once.
>
> We are already in this situation when multiple callers use zram simultaneously,
> such as during direct reclaim or with a mounted filesystem.
>
> Of course, this allows multiple pages to be compressed simultaneously,
> even if the user is single-threaded. However, determining when to enable
> these threads and whether they will be effective is challenging, as it
> depends on system load. For example, Qun-Wei's patch chose not to use
> threads for direct reclaim as, I guess, it might be harmful.
Direct reclaim is already harmful and that's why VM has the logic
to throttle writeback or other special logics for kswapd or direct
reclaim path for th IO, which could be applied into the zram, too.
next prev parent reply other threads:[~2025-03-13 17:33 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
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 [this message]
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=Z9MWzDUxUigJrZXt@google.com \
--to=minchan@kernel.org \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrew.yang@mediatek.com \
--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=james.hsu@mediatek.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=nvdimm@lists.linux.dev \
--cc=qun-wei.lin@mediatek.com \
--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 \
--cc=ying.huang@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