Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: gao xu <gaoxu2@honor.com>,
	"David Hildenbrand (Arm)" <david@kernel.org>,
	Xiang Gao <gxxa03070307@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	"liam@infradead.org" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	"linux-trace-kernel@vger.kernel.org"
	<linux-trace-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Xiang Gao <gaoxiang17@xiaomi.com>
Subject: Re: [PATCH] tracing: report buffer memory in /proc/meminfo
Date: Tue, 11 Aug 2026 08:44:56 -0400	[thread overview]
Message-ID: <20260811084456.4699daf8@gandalf.local.home> (raw)
In-Reply-To: <anrPJN-V8K4fhGzZ@lucifer>

On Tue, 11 Aug 2026 08:34:13 +0100
"Lorenzo Stoakes (ARM)" <ljs@kernel.org> wrote:


> > > Agreed. This doesn't belong in the meminfo. If you want memory statistics for
> > > tracing, I may be OK if you add a "total_memory_kb" file in the
> > > /sys/kernel/tracing/trace_stats/ directory.  
> > Would it be possible to include this info in show_mem()?
> > This would be helpful for analyzing low-memory and OOM issues.  
> 
> You have to back up requests with reasons, it's not a case of 'please add X to
> Y' and then we deign to do it or not.
> 
> Justifications are required. We could add endless crap to show_mem() until the
> CoWs come home, maybe even list the number of emojis used since last boot
> obviously.
> 
> So - why are you asking for this? Is it only a handful of KiB used for tracing?
> Is it GiB? If so maybe it's because you're doing something crazy? Why does a
> kernelfs file not suffice, etc.?

Well, it can be gigabytes. When you boot up, the ring buffer is set to the
minimal amount which is two pages per CPU. On a 4K page machine with 32
CPUs, that works out to be around 128K.

You can see the minimal size by looking at the buffer_size_kb:

 ~# cat /sys/kernel/tracing/buffer_size_kb 
 7 (expanded: 1408)

(it's 7K of data storage rounded down after subtracting the meta data per page:
  4096 - 16 = 4080; 4080 * 2 / 1024 = 7 )

Notice that "expanded: 1408"? That means when tracing starts (enabling an
event or function tracing) it will expand to 1408K of data storage.

That means on that same 32 CPU machine, if tracing is started, the buffers
will expand to 45M. That's without the user increasing the size of the ring
buffer (by writing a bigger number into that buffer_size_kb file).

Now I do know of some companies that make the per CPU ring buffer 1 GB
each. On a 128 CPU machine, that is 128G of memory used for the ring buffer.

> 
> You need to engage with the discussion and back things up rather just asking
> like you were typing into an LLM prompt...
> 
> But in general, no, it makes absolutely no sense to randomly output some trace
> information there, unless you're about to offer up the most compelling argument
> since the invention of marmite and butter on toast.
> 
> show_mem() is for critical memory information displayed at the point of OOM or
> sysrq-please-help-me, not random stats.

I wonder if it would be useful to show the tracing buffer if it is over
some watermark. That is, if the ring buffer is more than 10% of the memory
in the system, perhaps it would be good to show that?

-- Steve

      reply	other threads:[~2026-08-11 12:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10  9:40 [PATCH] tracing: report buffer memory in /proc/meminfo Xiang Gao
2026-08-10 10:52 ` David Hildenbrand (Arm)
2026-08-10 11:22   ` Lorenzo Stoakes (ARM)
2026-08-10 14:57     ` Steven Rostedt
2026-08-11  6:22       ` gao xu
2026-08-11  7:34         ` Lorenzo Stoakes (ARM)
2026-08-11 12:44           ` Steven Rostedt [this message]

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=20260811084456.4699daf8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=gaoxiang17@xiaomi.com \
    --cc=gaoxu2@honor.com \
    --cc=gxxa03070307@gmail.com \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.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