[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXKRIOpDrZG37_wz@linux.dev>
Date: Thu, 22 Jan 2026 13:12:19 -0800
From: Shakeel Butt <shakeel.butt@...ux.dev>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jianyue Wu <wujianyue000@...il.com>, hannes@...xchg.org,
mhocko@...nel.org, roman.gushchin@...ux.dev, muchun.song@...ux.dev,
linux-mm@...ck.org, cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
inwardvessel@...il.com
Subject: Re: [PATCH v3] mm: optimize stat output for 11% sys time reduce
On Thu, Jan 22, 2026 at 09:13:51AM -0800, Andrew Morton wrote:
> On Thu, 22 Jan 2026 19:42:42 +0800 Jianyue Wu <wujianyue000@...il.com> wrote:
>
> > 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
> > - Introduce local variables to improve readability and reduce line length
> >
> > Performance:
> > - 1M reads of memory.stat+memory.numa_stat
> > - Before: real 0m9.663s, user 0m4.840s, sys 0m4.823s
> > - After: real 0m9.051s, user 0m4.775s, sys 0m4.275s (~11.4% sys drop)
>
> So the tl;dr here is "vfprintf() is slow".
>
> It's quite a large change, although not a complex one.
>
> Do we need to change so much? Would some subset of these changes
> provide most of the benefit?
>
> It does rather uglify things so there's a risk that helpful people will
> send "cleanups" which switch back to using *printf*. Explanatory code
> comments would help prevent that but we'd need a lot of them.
>
> I dunno, what do people think? Does the benefit justify the change?
It does come with significant benefit but there is no urgency and we can
definitely decrease the ugliness. JP told me he has some ideas to
improve this.
Andrew, let's skip this patch for the upcoming merge window and you can
drop it from mm-tree if it is a burden.
Powered by blists - more mailing lists