From: Nhat Pham <nphamcs@gmail.com>
To: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mike Rapoport <rppt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.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>,
Barry Song <21cnbao@gmail.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Yosry Ahmed <yosry.ahmed@linux.dev>,
Chengming Zhou <chengming.zhou@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Kairui Song <ryncsn@gmail.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>
Subject: Re: [PATCH] mm: Add Kcompressd for accelerated memory compression
Date: Thu, 1 May 2025 08:50:24 -0700 [thread overview]
Message-ID: <CAKEwX=MNVwd_Z1PyBt7swd2VhUVivRN-5E+kHm-3XAPka0d84w@mail.gmail.com> (raw)
In-Reply-To: <20250430082651.3152444-1-qun-wei.lin@mediatek.com>
On Wed, Apr 30, 2025 at 1:27 AM Qun-Wei Lin <qun-wei.lin@mediatek.com> wrote:
>
> This patch series introduces a new mechanism called kcompressd to
> improve the efficiency of memory reclaiming in the operating system.
>
> Problem:
> In the current system, the kswapd thread is responsible for both scanning
> the LRU pages and handling memory compression tasks (such as those
> involving ZSWAP/ZRAM, if enabled). 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.
>
> Solution:
> Introduced kcompressd to handle asynchronous compression during memory
> reclaim, improving efficiency by offloading compression tasks from
> kswapd. This allows kswapd to focus on its primary task of page reclaim
> without being burdened by the additional overhead of compression.
>
> In our handheld devices, we found that applying this mechanism under high
> memory pressure scenarios can increase the rate of pgsteal_anon per second
> by over 260% compared to the situation with only kswapd. Additionally, we
> observed a reduction of over 50% in page allocation stall occurrences,
> further demonstrating the effectiveness of kcompressd in alleviating memory
> pressure and improving system responsiveness.
>
Oh btw, testing this on a simple kernel building task triggers this:
[ 133.349908] WARNING: CPU: 0 PID: 50 at mm/memcontrol.c:5330
obj_cgroup_charge_zswap+0x22e/0x250
[ 133.350505] Modules linked in: virtio_net pata_acpi net_failover
failover virtio_rng rng_core ata_piix libata scsi_mod scsi_common
[ 133.351366] CPU: 0 UID: 0 PID: 50 Comm: kcompressd0 Not tainted
6.14.0-ge65b549702a5 #218
[ 133.351940] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
[ 133.352717] RIP: 0010:obj_cgroup_charge_zswap+0x22e/0x250
[ 133.353118] Code: d2 ff 85 c0 0f 85 7a fe ff ff be ff ff ff ff 48
c7 c7 88 da f1 91 e8 a1 b4 a3 00 85 c0 0f 85 61 fe ff ff 0f 0b e9 5a
fe ff ff <0f> 0b e9 f5 fd ff ff e8 36 ae a3 00 e9 78 fe ff ff e8 2c ae
a3 00
[ 133.354372] RSP: 0018:ffff9f99803bbc00 EFLAGS: 00010246
[ 133.354782] RAX: ffff970f42a9a900 RBX: 000000000000013e RCX: 0000000000000002
[ 133.355269] RDX: 0000000000000000 RSI: 000000000000013e RDI: ffff970f475eab40
[ 133.355774] RBP: ffff970f475eab40 R08: 0000000000000000 R09: 0000000000000000
[ 133.356269] R10: ffffffff90a21205 R11: ffffffff90a211ab R12: ffffffff90a21205
[ 133.356782] R13: ffffc4984041ff40 R14: ffff970f42e66000 R15: 000000000000013e
[ 133.357279] FS: 0000000000000000(0000) GS:ffff970fbdc00000(0000)
knlGS:0000000000000000
[ 133.357807] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 133.358186] CR2: 00007f33950c5030 CR3: 00000000038ea000 CR4: 00000000000006f0
[ 133.358656] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 133.359121] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 133.359597] Call Trace:
[ 133.359767] <TASK>
[ 133.359914] ? __warn+0x94/0x190
[ 133.360136] ? obj_cgroup_charge_zswap+0x22e/0x250
[ 133.360476] ? report_bug+0x168/0x170
[ 133.360742] ? handle_bug+0x53/0x90
[ 133.360982] ? exc_invalid_op+0x18/0x70
[ 133.361240] ? asm_exc_invalid_op+0x1a/0x20
[ 133.361536] ? zswap_store+0x755/0xf80
[ 133.361798] ? zswap_store+0x6fb/0xf80
[ 133.362071] ? zswap_store+0x755/0xf80
[ 133.362338] ? obj_cgroup_charge_zswap+0x22e/0x250
[ 133.362661] ? zswap_store+0x755/0xf80
[ 133.362943] zswap_store+0x7e7/0xf80
[ 133.363203] ? __pfx_kcompressd+0x10/0x10
[ 133.363472] kcompressd+0xb1/0x180
[ 133.363724] ? __pfx_autoremove_wake_function+0x10/0x10
[ 133.364082] kthread+0xef/0x230
[ 133.364298] ? __pfx_kthread+0x10/0x10
[ 133.364548] ret_from_fork+0x34/0x50
[ 133.364810] ? __pfx_kthread+0x10/0x10
[ 133.365063] ret_from_fork_asm+0x1a/0x30
[ 133.365321] </TASK>
[ 133.365471] irq event stamp: 18
[ 133.365680] hardirqs last enabled at (17): [<ffffffff914bd0ef>]
_raw_spin_unlock_irqrestore+0x4f/0x60
[ 133.366289] hardirqs last disabled at (18): [<ffffffff914b2031>]
__schedule+0x6b1/0xe80
[ 133.366824] softirqs last enabled at (0): [<ffffffff906b1caf>]
copy_process+0x9af/0x2b50
[ 133.367366] softirqs last disabled at (0): [<0000000000000000>] 0x0
[ 133.367844] ---[ end trace 0000000000000000 ]---
Seems like we're trigger this warning in the zswap cgroup check (see
obj_cgroup_may_zswap() in mm/memcontrol.c for more details):
VM_WARN_ON_ONCE(!(current->flags & PF_MEMALLOC));
Might wanna fix this...
next prev parent reply other threads:[~2025-05-01 15:50 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 8:26 Qun-Wei Lin
2025-04-30 17:05 ` Nhat Pham
2025-04-30 17:22 ` Nhat Pham
2025-04-30 21:51 ` Andrew Morton
2025-04-30 22:49 ` Barry Song
2025-05-07 15:11 ` Nhat Pham
2025-05-01 14:02 ` Johannes Weiner
2025-05-01 15:12 ` Nhat Pham
2025-06-16 3:41 ` Barry Song
2025-06-17 14:21 ` Nhat Pham
2025-06-23 5:16 ` Barry Song
2025-06-27 23:21 ` Nhat Pham
2025-07-09 3:25 ` Qun-wei Lin (林群崴)
2025-05-02 9:16 ` Qun-wei Lin (林群崴)
2025-05-01 15:50 ` Nhat Pham [this message]
2025-05-07 1:12 ` Harry Yoo
2025-05-07 1:50 ` Zi Yan
2025-05-07 2:04 ` Barry Song
2025-05-07 15:00 ` Nhat Pham
2025-05-07 15:12 ` Zi Yan
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=MNVwd_Z1PyBt7swd2VhUVivRN-5E+kHm-3XAPka0d84w@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=21cnbao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrew.yang@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=casper.li@mediatek.com \
--cc=chengming.zhou@linux.dev \
--cc=chinwen.chang@mediatek.com \
--cc=hannes@cmpxchg.org \
--cc=james.hsu@mediatek.com \
--cc=joshua.hahnjy@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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=qun-wei.lin@mediatek.com \
--cc=rppt@kernel.org \
--cc=ryncsn@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=shakeel.butt@linux.dev \
--cc=yosry.ahmed@linux.dev \
/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