From: Chengming Zhou <chengming.zhou@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
david@redhat.com, aarcange@redhat.com, hughd@google.com,
shr@devkernel.io
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
zhouchengming@bytedance.com,
Chengming Zhou <chengming.zhou@linux.dev>
Subject: [PATCH v2 0/3] mm/ksm: cmp_and_merge_page() optimizations and cleanup
Date: Fri, 21 Jun 2024 15:54:28 +0800 [thread overview]
Message-ID: <20240621-b4-ksm-scan-optimize-v2-0-1c328aa9e30b@linux.dev> (raw)
Changes in v2:
- Fix the comments of try_to_merge_with_zero_page(), per David.
- Drop the last one patch in this version since it's a very rare case
and hard to testing to prove.
- Rebase on the latest mm/mm-stable branch.
- Link to v1: https://lore.kernel.org/r/20240524-b4-ksm-scan-optimize-v1-0-053b31bd7ab4@linux.dev
Hello,
This series mainly optimizes cmp_and_merge_page() to have more efficient
separate code flow for ksm page and non-ksm anon page.
- ksm page: don't need to calculate the checksum obviously.
- anon page: don't need to search stable tree if changing fast and try
to merge with zero page before searching ksm page on stable tree.
Please see the patch-2 for details.
Patch-3 is cleanup also a little optimization for the chain()/chain_prune
interfaces, which made the stable_tree_search()/stable_tree_insert() over
complex.
I have done simple testing using "hackbench -g 1 -l 300000" (maybe I need
to use a better workload) on my machine, have seen a little CPU usage
decrease of ksmd and some improvements of cmp_and_merge_page() latency:
We can see the latency of cmp_and_merge_page() when handling non-ksm
anon pages has been improved.
Thanks for review and comments!
Before:
- ksm page
[128, 256) 21 | |
[256, 512) 12509 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[512, 1K) 769 |@@@ |
[1K, 2K) 99 | |
[2K, 4K) 4 | |
[4K, 8K) 2 | |
[8K, 16K) 8 | |
- anon page
[512, 1K) 19 | |
[1K, 2K) 7160 |@@@@@@@@@@@ |
[2K, 4K) 33516 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[4K, 8K) 33172 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
[8K, 16K) 11305 |@@@@@@@@@@@@@@@@@ |
[16K, 32K) 1303 |@@ |
[32K, 64K) 16 | |
[64K, 128K) 6 | |
[128K, 256K) 6 | |
[256K, 512K) 9 | |
[512K, 1M) 3 | |
[1M, 2M) 2 | |
[2M, 4M) 1 | |
After:
- ksm page
[128, 256) 9 | |
[256, 512) 915 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[512, 1K) 41 |@@ |
[1K, 2K) 1 | |
[2K, 4K) 1 | |
- anon page
[512, 1K) 374 | |
[1K, 2K) 5367 |@@@@ |
[2K, 4K) 64362 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[4K, 8K) 27721 |@@@@@@@@@@@@@@@@@@@@@@ |
[8K, 16K) 1047 | |
[16K, 32K) 63 | |
[32K, 64K) 7 | |
[64K, 128K) 6 | |
[128K, 256K) 5 | |
[256K, 512K) 3 | |
[512K, 1M) 1 | |
Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>
---
Chengming Zhou (3):
mm/ksm: refactor out try_to_merge_with_zero_page()
mm/ksm: don't waste time searching stable tree for fast changing page
mm/ksm: optimize the chain()/chain_prune() interfaces
mm/ksm.c | 250 +++++++++++++++++++++------------------------------------------
1 file changed, 82 insertions(+), 168 deletions(-)
---
base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f
change-id: 20240621-b4-ksm-scan-optimize-e614a3a52217
Best regards,
--
Chengming Zhou <chengming.zhou@linux.dev>
next reply other threads:[~2024-06-21 7:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 7:54 Chengming Zhou [this message]
2024-06-21 7:54 ` [PATCH v2 1/3] mm/ksm: refactor out try_to_merge_with_zero_page() Chengming Zhou
2024-06-21 7:54 ` [PATCH v2 2/3] mm/ksm: don't waste time searching stable tree for fast changing page Chengming Zhou
2024-06-21 7:54 ` [PATCH v2 3/3] mm/ksm: optimize the chain()/chain_prune() interfaces Chengming Zhou
2024-06-22 1:09 ` Andrew Morton
2024-06-28 23:59 ` [PATCH v2 0/3] mm/ksm: cmp_and_merge_page() optimizations and cleanup Andrew Morton
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=20240621-b4-ksm-scan-optimize-v2-0-1c328aa9e30b@linux.dev \
--to=chengming.zhou@linux.dev \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shr@devkernel.io \
--cc=zhouchengming@bytedance.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;
as well as URLs for NNTP newsgroup(s).