mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: <xu.xin16@zte.com.cn>
To: <akpm@linux-foundation.org>
Cc: <david@kernel.org>, <ljs@kernel.org>, <hughd@google.com>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<michel@lespinasse.org>, <corbet@lwn.net>,
	<wang.yaxin@zte.com.cn>
Subject: Re: [PATCH v5 0/5] KSM: performance optimizations for rmap_walk_ksm
Date: Wed, 20 May 2026 14:26:41 +0800 (CST)	[thread overview]
Message-ID: <20260520142641245K2bbRXvUcRR_Q3Gdbygi9@zte.com.cn> (raw)
In-Reply-To: <20260519100156.05043f9d043889a5f60e22d3@linux-foundation.org>

> > Two key highlights:
> > 
> > 1. Lock hold time drops from >500ms to <2ms
> >    - In our benchmark (20,000 VMAs sharing an anon_vma), worst-case
> >      anon_vma lock hold time during KSM rmap walk went from 705ms
> >      down to 1.67ms (max) and 1.44ms (avg).
> 
> How real-worldish is that benchmark?
> 
> How much effect are our users likely to see from this patchset in their
> real-world workloads?

Hi Andrew,

Thank you for your thoughtful question.

The benchmark intentionally simulates a scenario where many VMAs share the
same anon_vma without any fork() involved. This happens in real systems
when applications repeatedly split existing VMAs via mprotect(2) or
madvise(2) (e.g., MADV_DONTNEED, MADV_FREE) on sub‑ranges of a large
anonymous mapping.

Real-world examples:

 - JVM / Go runtime: These use mmap for heap regions and later call
mprotect(PROT_NONE) for garbage collection barriers or guard pages,
splitting the original VMA into thousands of small pieces over time.

 - Database engines (MySQL, PostgreSQL): Large shared memory buffers
or anonymous mappings are managed with madvise(MADV_DONTNEED) to release
specific pages, which also splits VMAs.

* Why the benchmark numbers are realistic: We observed ~20,000 VMAs sharing
one anon_vma on a production system running a Java application with KSM
enabled. The lock hold time before the patch was measured at 228 ms (max)
during rmap walks triggered by memory compaction and page migration.
The benchmark reproduces that VMA count and lock‑hold behavior in a
controlled environment.

For systems that do not have thousands of VMAs per anon_vma, the
patch adds negligible overhead (a single pgoff comparison). For systems
that do suffer from this issue, the improvement is dramatic:
1) Worst‑case anon_vma lock hold time drops from hundreds of milliseconds
to under 2 ms.2)This directly reduces blocking of parallel operations that
need the same lock – page faults, reclaim, migration, compaction, mlock, and
exit_mmap.

End‑users will see lower tail latency (fewer application stalls),
higher throughput under memory pressure, and no more spurious
lockup warnings or container timeouts caused by excessive lock hold
times.

In short: workloads that do not hit this pathological pattern are
unaffected; those that do will see a 100x to 500x reduction in lock
hold times, which translates directly into a more responsive system.

I hope this clarifies the real‑world relevance. Thank you for pushing
us to make the changelog clearer.

Best regards,
xu xi

  reply	other threads:[~2026-05-20  6:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19 14:05 xu.xin16
2026-05-19 14:09 ` [PATCH v5 1/5] mm/rmap: add tracepoint for rmap_walk xu.xin16
2026-05-19 14:11 ` [PATCH v5 2/5] tools/testing: add rmap walk latency benchmark xu.xin16
2026-05-19 14:12 ` [PATCH v5 3/5] ksm: add pgoff into ksm_rmap_item xu.xin16
2026-05-19 14:14 ` [PATCH v5 4/5] ksm: Optimize rmap_walk_ksm by passing a suitable pgoff xu.xin16
2026-05-19 14:18 ` [PATCH v5 5/5] ksm: add mremap selftests for ksm_rmap_walk xu.xin16
2026-05-19 17:01 ` [PATCH v5 0/5] KSM: performance optimizations for rmap_walk_ksm Andrew Morton
2026-05-20  6:26   ` xu.xin16 [this message]
2026-05-20  6:37   ` xu.xin16

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=20260520142641245K2bbRXvUcRR_Q3Gdbygi9@zte.com.cn \
    --to=xu.xin16@zte.com.cn \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=michel@lespinasse.org \
    --cc=wang.yaxin@zte.com.cn \
    /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

all inboxes | Powered by JetHome®