Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Wenchao Hao <haowenchao22@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Minchan Kim <minchan@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Nhat Pham <nphamcs@gmail.com>,
	Joshua Hahn <joshua.hahnjy@gmail.com>,
	Barry Song <baohua@kernel.org>,
	Wenchao Hao <haowenchao@xiaomi.com>
Subject: Re: [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free()
Date: Sat, 27 Jun 2026 21:36:00 -0700	[thread overview]
Message-ID: <20260627213600.eb072ba84382807a8242efc9@linux-foundation.org> (raw)
In-Reply-To: <20260626015003.2965881-1-haowenchao22@gmail.com>

On Fri, 26 Jun 2026 09:49:59 +0800 Wenchao Hao <haowenchao22@gmail.com> wrote:

> From: Wenchao Hao <haowenchao@xiaomi.com>
> 
> This series reduces lock contention in zs_free(), which dominates the
> unmap path under memory pressure on Android (LMK kills) and on x86
> servers running zswap-heavy workloads.
> 
> The current zs_free() takes pool->lock (rwlock, read side) just to
> look up the size_class for a handle, then takes class->lock and holds
> it across __free_zspage() which can call into the buddy allocator and
> acquire zone->lock.  Two costs follow:
> 
>   * pool->lock reader-counter cacheline bouncing among concurrent
>     zs_free() callers.
>   * class->lock held across folio_put(), so any zone->lock wait
>     fans out to every other zs_free() on the same class.
> 
> The series tackles both:
> 
>   Patch 1: encode size_class index into obj alongside PFN and obj_idx,
>            so zs_free() can locate the class without pool->lock.
>   Patch 2: drop pool->lock from zs_free() on 64-bit; 32-bit unchanged.
>   Patch 3: move zspage page-freeing out of class->lock.
>   Patch 4: document the three free_zspage helper variants that result
>            from the split in patch 3.
> 
> Performance results:
> 
> Test: each process independently mmap 256MB, write data, madvise
> MADV_PAGEOUT to swap out via zram (lzo-rle), then concurrent munmap.
> 
> Raspberry Pi 4B (4-core ARM64 Cortex-A72):
> 
>   mode        Base       Patched     Speedup
>   single      59.0ms     56.0ms      1.05x
>   multi 2p    94.6ms     66.7ms      1.42x
>   multi 4p    202.9ms    110.6ms     1.83x
> 
> x86 (20-core Intel i7-12700, 16 concurrent processes):
> 
>   mode        Base       Patched     Speedup
>   single      11.7ms     9.8ms       1.19x
>   multi 2p    24.1ms     17.2ms      1.40x
>   multi 4p    63.0ms     45.3ms      1.39x

Well that's a nice result.

Sashiko AI review said ....  nothing.  I don't recall seeing that
before ;)

I'll add this series to mm.git for the next step, thanks.


      parent reply	other threads:[~2026-06-28  4:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  1:49 [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free() Wenchao Hao
2026-06-26  1:50 ` [PATCH v6 1/4] mm/zsmalloc: encode class index in obj value for lockless class lookup Wenchao Hao
2026-06-26  1:50 ` [PATCH v6 2/4] mm/zsmalloc: drop pool->lock from zs_free on 64-bit systems Wenchao Hao
2026-06-26  1:50 ` [PATCH v6 3/4] mm/zsmalloc: drop class lock before freeing zspage Wenchao Hao
2026-06-26  1:50 ` [PATCH v6 4/4] mm/zsmalloc: document free_zspage helper variants Wenchao Hao
2026-06-28  4:36 ` Andrew Morton [this message]

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=20260627213600.eb072ba84382807a8242efc9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=baohua@kernel.org \
    --cc=haowenchao22@gmail.com \
    --cc=haowenchao@xiaomi.com \
    --cc=joshua.hahnjy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=nphamcs@gmail.com \
    --cc=senozhatsky@chromium.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