Skip to content

mm: memcg: optimize stat output to reduce printf overhead

Jianyue Wu cgroups linux-mm lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest1 patch 3 repliesIn review
  2. v31 patch 5 repliesSuperseded
  3. v21 patch 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch4 repliesSuperseded

Changes in v4 from the cover letter

- 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.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/1mm: optimize stat output for 11% sys time reducemm/memcontrol-v1.c mm/memcontrol-v1.h mm/memcontrol.c+123 -533 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchShakeel ButtJP Kobryn
1/1A-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/1] mm: memcg: optimize stat output to reduce printf overhead

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(-)
Signature · 1 line
2.43.0