Thanks, Steve.

For the initial implementation, I plan to add:

  /sys/kernel/tracing/trace_stats/total_memory_kb

The file would use an extensible key/value format. Initially it would
report the ring-buffer data capacity:

  total:                   395664
  ring_buffer:             395664
  ring_buffer_live:        395544
  ring_buffer_snapshot:       120

Here, ring_buffer is the sum of ring_buffer_live and
ring_buffer_snapshot. The values cover the global trace array and all
tracing instances across all tracing CPUs.

Additional accounted categories, such as event memory, could be appended
later and included in total. Per-CPU statistics could be exposed
separately under trace_stats/per_cpu/cpuN/ to avoid mixing aggregate and
per-CPU values in one file.

Userspace would parse fields by name and ignore unknown fields, so new
categories can be added without changing the existing format.

Does this initial format look reasonable?

Thanks,
Xiang



发件人: Steven Rostedt <rostedt@goodmis.org>
发送时间: 2026年8月11日 22:08:30
收件人: Xiang Gao
抄送: Masami Hiramatsu; Mathieu Desnoyers; Lorenzo Stoakes; gao xu; 印闯; linux-trace-kernel@vger.kernel.org; linux-kernel@vger.kernel.org; linux-mm@kvack.org; 高翔
主题: [External Mail]Re: [RFC] tracing: aggregate ring-buffer usage statistics
 
[外部邮件] 此邮件来源于小米公司外部,请谨慎处理。若对邮件安全性存疑,请将邮件转发给misec@xiaomi.com进行反馈

On Tue, 11 Aug 2026 19:48:18 +0800
Xiang Gao <gxxa03070307@gmail.com> wrote:

> One possible interface would be under:
>
>   /sys/kernel/tracing/trace_stats/
>
> It could provide an aggregate buffer value together with a breakdown
> for main and snapshot buffers. Per-CPU statistics could also be added
> if useful.

As I previous said. I'm OK with adding a file there.

-- Steve