From: Jianyue Wu <wujianyue000@gmail.com>
To: akpm@linux-foundation.org
Cc: shakeel.butt@linux.dev, hannes@cmpxchg.org, mhocko@kernel.org,
roman.gushchin@linux.dev, muchun.song@linux.dev,
linux-mm@kvack.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, inwardvessel@gmail.com,
Jianyue Wu <wujianyue000@gmail.com>
Subject: [PATCH v4 0/1] mm: memcg: optimize stat output to reduce printf overhead
Date: Fri, 23 Jan 2026 23:01:07 +0800 [thread overview]
Message-ID: <20260123150108.43443-1-wujianyue000@gmail.com> (raw)
In-Reply-To: <87ec59f7-2d76-4c7a-a2b0-57bc4e801d1d@gmail.com>
This patch optimizes memcg stat output by replacing seq_buf_printf() with
a lightweight helper and replacing seq_printf() in numa stat functions with
direct seq operations.
Changes in v4:
- Embed separator and newline in buffer to reduce function calls in
memcg_seq_buf_print_stat() (suggested by JP Kobryn)
- Optimize memory_numa_stat_show() and memcg_numa_stat_show() by replacing
seq_printf() with seq_puts() and seq_put_decimal_ull()
- Add comments explaining the optimization approach
- Note: Did not add a separate API for the numa stat case because the output
format "N0=value0 N1=value1" is too specific - the "N" prefix and node ID
are separate values that don't fit a name=value pattern. Using
seq_put_decimal_ull() directly is more flexible and clear.
Changes in v3:
- Rebased to latest mm-unstable
- Updated commit message to clarify the optimization approach
Changes in v2:
- Initial version with seq_buf optimization
Performance improvement (1M reads of memory.stat + memory.numa_stat):
- Before: real 0m9.663s, user 0m4.840s, sys 0m4.823s
- After: real 0m8.909s, user 0m4.661s, sys 0m4.247s
- Result: ~11% sys time reduction
Jianyue Wu (1):
mm: optimize stat output for 11% sys time reduce
mm/memcontrol-v1.c | 84 ++++++++++++++++++++++++-------------------
mm/memcontrol-v1.h | 4 +++
mm/memcontrol.c | 88 +++++++++++++++++++++++++++++++++++++---------
3 files changed, 123 insertions(+), 53 deletions(-)
--
2.43.0
next prev parent reply other threads:[~2026-01-23 15:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-08 9:37 [PATCH] mm: optimize stat output for 11% sys time reduce Jianyue Wu
2026-01-08 19:10 ` Andrew Morton
2026-01-08 22:49 ` Roman Gushchin
2026-01-08 23:52 ` Jiany Wu
2026-01-08 23:56 ` Jiany Wu
2026-01-10 4:22 ` [PATCH v2] " Jianyue Wu
2026-01-10 23:33 ` Andrew Morton
2026-01-11 4:37 ` Jianyue Wu
2026-01-13 0:23 ` Shakeel Butt
2026-01-13 0:29 ` Shakeel Butt
2026-01-22 11:42 ` [PATCH v3] " Jianyue Wu
2026-01-22 17:13 ` Andrew Morton
2026-01-22 21:12 ` Shakeel Butt
2026-01-23 1:07 ` Jianyue Wu
2026-01-23 8:14 ` JP Kobryn
2026-01-23 13:24 ` Jianyue Wu
2026-01-23 15:01 ` Jianyue Wu [this message]
2026-01-23 15:01 ` [PATCH v4 1/1] " Jianyue Wu
2026-01-23 15:06 ` Jianyue Wu
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=20260123150108.43443-1-wujianyue000@gmail.com \
--to=wujianyue000@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=inwardvessel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@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