On Sat, Sep 05, 2026 at 07:27:30PM +0800, Xiang Gao wrote:
> 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
> 
> 

It looks like you have sent the same v1 again.

-- 
Vincent

Reply via email to