mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
To: Xiang Gao <gaoxiang17@xiaomi.com>
Cc: Donggeun Yoo <donggeunyoo.kernel@gmail.com>,
	Xiang Gao <gxxa03070307@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Vincent Donnefort <vdonnefort@google.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lorenzo Stoakes <ljs@kernel.org>, gao xu <gaoxu2@honor.com>,
	yinchuang1@xiaomi.com, linux-trace-kernel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] tracing: add ring-buffer memory usage statistics in tracefs
Date: Mon, 14 Sep 2026 01:37:25 +0900	[thread overview]
Message-ID: <20260913163725.755443-1-donggeunyoo.kernel@gmail.com> (raw)
In-Reply-To: <20260911155017.3377254-2-gaoxiang17@xiaomi.com>

On Fri, Sep 11, 2026 at 11:50:16PM +0800, Xiang Gao wrote:
> +	/* The cached read page, if present, is a full sub-buffer page. */
> +	if (cpu_buffer->free_page)
> +		size += subbuf_size;

Have you compile-tested this one? free_page is a struct, not a pointer:

  kernel/trace/ring_buffer.c:6594:13: error: used struct type value where scalar is required
   6594 |         if (cpu_buffer->free_page)
        |             ^~~~~~~~~~

cpu_buffer->free_page.data should do it.

> +	list_for_each_entry(tr, &ftrace_trace_arrays, list) {
> +		for_each_tracing_cpu(cpu)
> +			trace_array_buffer_memory(tr, cpu, &stats.buffers,
> +						  &stats.snapshot);
> +	}

With that fixed the walk does match the changelog, but temp_buffer is out
of its reach. tracer_alloc_buffers() allocates it and never attaches it to
a trace array, so it is not on ftrace_trace_arrays, and its pages are the
kind you are counting: sub-buffers and a reader page from the page
allocator, not remote and not slab.

It is three sub-buffers per CPU at order 0 and is never resized, so it
disappears into the noise once a real buffer is sized up. At rest it does
not. On an 8 CPU x86_64 guest the file reports

  buffers: 96

while temp_buffer holds another 96K. Freeing it hands back 24 pages, which
is what ring_buffer_memory_size() predicts for it.

Was that deliberate? For lost RAM accounting I would have expected it in.

  reply	other threads:[~2026-09-13 16:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-07  9:26   ` Vincent Donnefort
2026-09-05 11:27 ` [PATCH 2/2] tracing: add per-CPU " Xiang Gao
2026-09-11 15:50 ` [PATCH v2 0/2] tracing: add ring-buffer memory usage statistics Xiang Gao
2026-09-11 15:50   ` [PATCH v2 1/2] tracing: add ring-buffer memory usage statistics in tracefs Xiang Gao
2026-09-13 16:37     ` Donggeun Yoo [this message]
2026-09-11 15:50   ` [PATCH v2 2/2] tracing: add per-CPU " Xiang Gao
2026-09-16  6:33   ` [PATCH v3 0/2] tracing: add ring-buffer memory usage statistics Xiang Gao
2026-09-16  6:33     ` [PATCH v3 1/2] tracing: add ring-buffer memory usage statistics in tracefs Xiang Gao
2026-09-16  6:33     ` [PATCH v3 2/2] tracing: add per-CPU " Xiang Gao
2026-09-11 17:22 ` [PATCH 0/2] tracing: add ring-buffer memory usage statistics Vincent Donnefort

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=20260913163725.755443-1-donggeunyoo.kernel@gmail.com \
    --to=donggeunyoo.kernel@gmail.com \
    --cc=gaoxiang17@xiaomi.com \
    --cc=gaoxu2@honor.com \
    --cc=gxxa03070307@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=ljs@kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=vdonnefort@google.com \
    --cc=yinchuang1@xiaomi.com \
    /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

all inboxes | Powered by JetHome®