VOOZH about

URL: https://www.phoronix.com/news/NVIDIA-Optimize-Printf-Memcg

⇱ NVIDIA Optimizes Printing Of Linux Memory Stats For 11% System Time Savings - Phoronix


👁 Phoronix

NVIDIA Optimizes Printing Of Linux Memory Stats For 11% System Time Savings

Written by Michael Larabel in Linux Kernel on 8 January 2026 at 08:19 AM EST. 4 Comments
A NVIDIA engineer restructuring some of the printf-related code within the memory resource controller "memcg" statistics printing code to reduce the system time by 11% for dumping those stats.

NVIDIA continues investing more and more into lower-level Linux kernel engineering improvements given their grand successes in the data center, beyond just their traditional scope of GPU and networking subsystems. One of their latest improvements they are working to upstream is to the memory management code to optimize the statistics output printing for an 11% reduction in system time needed. This is for reading the likes of /sys/fs/cgroup/memory.stat and /sys/fs/cgroup/memory.numa_stat.

👁 NVIDIA memcg stats output benchmark


It's less than a one second difference in their memcg stat output testing -- and that's benchmarking it one million times -- albeit all the little optimizations add up over time. Leave no stone unturned especially with Intel having long been known for their relentless Linux kernel optimizations albeit over the past year have lost a number of their Linux kernel engineers and a reduction in resources, so it's nice seeing NVIDIA engineers working more in these areas.
"Replace seq_printf/seq_buf_printf with lightweight helpers to avoid printf parsing in memcg stats output.

Key changes:
- Add memcg_seq_put_name_val() for seq_file "name value\n" formatting
- Add memcg_seq_buf_put_name_val() for seq_buf "name value\n" formatting
- Update __memory_events_show(), swap_events_show(), memory_stat_format(), memory_numa_stat_show(), and related helpers"

Those frequently making use of the memcg stats output can find the proposed patch on the Linux kernel mailing list.

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.