From: Suren Baghdasaryan <surenb@google.com>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Li Zetao <lizetao.kernel@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
akpm@linux-foundation.org, linux-mm@kvack.org
Subject: Re: [PATCH mm-next] alloc_tag: add total bytes allocation information
Date: Mon, 7 Jul 2025 19:05:18 -0700 [thread overview]
Message-ID: <CAJuCfpHCxGeg-8xsEjKP-mp8T1aWgjs-cwUir4x98TOPakt_9g@mail.gmail.com> (raw)
In-Reply-To: <aqrm4lieghuw5pvlubla6h5mxwkihlg5be3bnn3446xjd4kt5r@f7txjfhrlvkh>
On Sun, Jul 6, 2025 at 8:21 AM Kent Overstreet
<kent.overstreet@linux.dev> wrote:
>
> On Sun, Jul 06, 2025 at 02:01:41PM +0800, Li Zetao wrote:
> > Hi,
> >
> > On 2025/7/3 1:14, Kent Overstreet wrote:
> > > +cc Peter, Ingo, Steven
> > >
> > > On Wed, Jul 02, 2025 at 12:38:06AM +0800, LiZetao wrote:
> > > > From bb3537ee638ac80eebcfe9160961e36df8d3ee4c Mon Sep 17 00:00:00 2001
> > > > From: Li Zetao<lizetao.kernel@gmail.com>
> > > > Date: Tue, 1 Jul 2025 09:30:16 +0000
> > > > Subject: [PATCH mm-next] alloc_tag: add total bytes allocation information
> > > >
> > > > Some performance monitoring tools focus on real-time memory
> > > > usage anddisplay the total amount of memory applied, which is
> > > > convenient for analyzing the memory usage ratio.
> > > >
> > > > Added total information in /proc/allocinfo to feedback the
> > > > total amount of memory applied to the user. Example is as
> > > > follows:
> > > >
> > > > root:~# cat /proc/allocinfo|tail
> > > > 98112 168 lib/radix-tree.c:338 func:__radix_tree_preload
> > > > 12848 22 lib/radix-tree.c:276 func:radix_tree_node_alloc
> > > > 300760 515 lib/radix-tree.c:253 func:radix_tree_node_alloc
> > > > 0 0 lib/xarray.c:1214 func:xas_try_split
> > > > 0 0 lib/xarray.c:1059 func:xas_split_alloc
> > > > 208488 357 lib/xarray.c:378 func:xas_alloc
> > > > 0 0 lib/xarray.c:344 func:__xas_nomem
> > > > 0 0 lib/xarray.c:341 func:__xas_nomem
> > > > 0 0 lib/xarray.c:309 func:xas_nomem
> > > > total: 102208196
Sorry for the late reply.
I'm trying to understand why this math has to be done in the kernel.
Why the userspace parser of this file can't simply read the file,
calculate the total allocations size and report it? I don't see the
value of doing that in the kernel as any allocation size can change at
any time even while we are reading this file. So, if you are concerned
about correctness of the reported total, it won't be any more correct
even if you do this inside the kernel AFAICT.
> > > This makes it harder to process the output (numfmt chokes on lines it
> > > don't understand, which makes the header a real problem).
> > >
> > > Given this and the per-numa-node patchset, I am inclined towards adding
> > > an ioctl interface and a userspace tool to do the processing.
> >
> > In my opinion, using ioctl is not very convenient. What do you think if a
> > file like
> >
> > /proc/allocinfo_total can solve this problem?
>
> We definitely don't want to dump more stuff in /proc, no.
>
> There have been multiple proposals that would dump more stuff in
> /proc/allocinfo, and we can't realistically do all that with a text
> interface - that needs to stay stable and simple.
>
> A userspace program reading data out via an ioctl will solve all the
> things people have been wanting:
>
> - Someone has been reading data out at high frequency for logging pretty
> graphs: we want to avoid string serialization/deserialization
>
> - An ioctl is easier to make extensible (unless we want to go json, but
> I'm not sure the kernel is ready for that...)
>
> - and that gives us a place to add commandline switches and arguments
> for displaying the data different ways (like the top command).
>
> I don't have time to implement it myself, but I can guide someone and do
> code review.
next prev parent reply other threads:[~2025-07-08 2:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 16:38 LiZetao
2025-07-02 17:14 ` Kent Overstreet
2025-07-02 20:19 ` Steven Rostedt
2025-07-06 6:01 ` Li Zetao
2025-07-06 15:21 ` Kent Overstreet
2025-07-08 2:05 ` Suren Baghdasaryan [this message]
2025-07-08 2:16 ` Kent Overstreet
2025-07-08 14:38 ` Suren Baghdasaryan
2025-07-08 15:13 ` Kent Overstreet
2025-07-08 15:22 ` Suren Baghdasaryan
2025-07-08 17:23 ` Kent Overstreet
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=CAJuCfpHCxGeg-8xsEjKP-mp8T1aWgjs-cwUir4x98TOPakt_9g@mail.gmail.com \
--to=surenb@google.com \
--cc=akpm@linux-foundation.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-mm@kvack.org \
--cc=lizetao.kernel@gmail.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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