Linux Trace Kernel
 help / color / mirror / Atom feed
* [PATCH 0/2] tracing: add ring-buffer memory usage statistics
@ 2026-09-05 11:27 Xiang Gao
  2026-09-05 11:27 ` [PATCH 1/2] tracing: add ring-buffer memory usage statistics in tracefs Xiang Gao
  2026-09-05 11:27 ` [PATCH 2/2] tracing: add per-CPU " Xiang Gao
  0 siblings, 2 replies; 4+ messages in thread
From: Xiang Gao @ 2026-09-05 11:27 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Mathieu Desnoyers, Lorenzo Stoakes, gao xu,
	yinchuang1, linux-trace-kernel, linux-kernel, Xiang Gao

Report the memory consumed by the tracing ring buffers, rather than the
usable data capacity exposed by buffer_size_kb. Android low-memory
diagnostics need this to attribute the memory used by tracing when
calculating lost RAM.

The buffers can be spread across the global trace array, dynamically
created instances, and snapshot buffers. Userspace currently has to
discover and sum every instance, and snapshot memory is not exposed by
the per-instance totals.

Patch 1 adds:

  /sys/kernel/tracing/trace_stats/memory_usage_kb

reporting:

  buffers: ...
  snapshot_buffers: ...

covering the global trace array and all instances across all CPUs.

Patch 2 adds the per-CPU view under
trace_stats/per_cpu/cpuN/memory_usage_kb.

The values account for the full pages backing the data sub-buffers and
reader page, plus the cached read page and mmap metadata page when
present. Slab-allocated ring-buffer metadata is not included.

Xiang Gao (2):
  tracing: add ring-buffer memory usage statistics in tracefs
  tracing: add per-CPU memory usage statistics in tracefs

 Documentation/trace/ftrace.rst |  15 +++++
 include/linux/ring_buffer.h    |   1 +
 kernel/trace/ring_buffer.c     |  41 +++++++++++++
 kernel/trace/trace.c           | 104 +++++++++++++++++++++++++++++++++
 4 files changed, 161 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-05 11:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-05 11:27 [PATCH 0/2] tracing: add ring-buffer memory usage statistics Xiang Gao
2026-09-05 11:27 ` [PATCH 1/2] tracing: add ring-buffer memory usage statistics in tracefs Xiang Gao
2026-09-05 11:38   ` sashiko-bot
2026-09-05 11:27 ` [PATCH 2/2] tracing: add per-CPU " Xiang Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox