From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C06333EDAC2 for ; Wed, 18 Mar 2026 19:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773862066; cv=none; b=ttVTCWEuredBkon6NNv5TebfSFFLKUYf18qkVPgyAs7qxgCofE8ybnJo6JlR75uxtNyNHVeyR+YX2mki7r17EJLRbJU3FuXxavjb8USoNHXGFRAZ9b9H6LGirXyek/li8yzxTD6KCWLCknKCXgxoF7y3m9/n7prX6rY+BG+n/eI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773862066; c=relaxed/simple; bh=vtaBATzJR8xVGnfJH1oKTvRnZsOODHq2bNKE9oU2FCk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tim2DohNXKUOPvlJZ4icUOZvywye3tjI05EDuL0nBpsmtNNfzs8yBs4XgiDACI5BsIL9/LMXUQwIrgEt3X1P9gqvoW/quq1hukTzNrwNw+nUGROmD7JVLHhiIQQrsGfTjEfEj2TCT2ENo/maaVWfti3Qv3JZNkuC76B4JDPKdoQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AA063B5DA4; Wed, 18 Mar 2026 19:27:37 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf03.hostedemail.com (Postfix) with ESMTPA id C99EA6000B; Wed, 18 Mar 2026 19:27:35 +0000 (UTC) Date: Wed, 18 Mar 2026 15:28:04 -0400 From: Steven Rostedt To: David Carlier Cc: Masami Hiramatsu , Mathieu Desnoyers , linux-kernel@vger.kernel.org, Vincent Donnefort , maz@kernel.org Subject: Re: [PATCH] tracing: Fix nr_subbufs initialization in simple_ring_buffer_init_mm() Message-ID: <20260318152804.26a8d6be@gandalf.local.home> In-Reply-To: <20260318171907.19640-1-devnexen@gmail.com> References: <20260318171907.19640-1-devnexen@gmail.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: C99EA6000B X-Rspamd-Server: rspamout06 X-Stat-Signature: 86xzcsgq8c6ej87aeisqxio69mt9cm63 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX19YqeIxpw0/8gKYGdTVDTkjxgIjB3/Q694= X-HE-Tag: 1773862055-698207 X-HE-Meta: U2FsdGVkX19KbJ5f6Df+71eqN1m//jJHWO0uYFo9UggzoYSIqHGIKdbE+Rr5O97vRWbl4lS4OlAyWtH2cwWNrg1p59jh8QUjlDgtyfo4guniTc0W76G/I8gNHanBN8TZ1Ycn9RXK2Crd8RweR6zJ2X/janAtMYtSFo9wEXZeCH5Nv7d12rAIMv2FMHGzOaXZv4fuLjp6SyJmEHiGSER/WsI6d9mSZuUKfsdR9uX+jHPbctkC38zjZyqBkH3KEXyI9WVjw4L5ByVtH3Lwl4+xQF0e8MQMVGsOs/DiEAUG18xmyc5iGo4rHBL3KXAa45GX2hid6D8u2Hacm/CaxPjC0VLXNpBpBwSF On Wed, 18 Mar 2026 17:19:07 +0000 David Carlier wrote: > In simple_ring_buffer_init_mm(), meta->nr_subbufs is assigned from > cpu_buffer->nr_pages at line 398, but cpu_buffer was just zeroed by > memset() at line 390. The actual page count is only computed later in > the loop (lines 410-429), so nr_subbufs is always set to 0. Did you use an AI agent to discover this? If so, you need to disclose that. (AI agents are typically the only one that uses line numbers to describe problems like this) > > This field is part of struct trace_buffer_meta (UAPI), exposed to > consumers who rely on it for buffer geometry calculations (e.g., > data_len = subbuf_size * nr_subbufs). A value of 0 breaks ring buffer > consumption entirely. > > Fix by using desc->nr_page_va directly, which holds the correct total > page count (reader + ring pages) and is available at this point. This > matches the UAPI documentation: "Number of subbufs in the ring-buffer, > including the reader." As this will likely be pulled into mainline via the ARM64 tree, and they are currently the only ones actually using this code, this should go through them. -- Steve > > Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer") > Signed-off-by: David Carlier > --- > kernel/trace/simple_ring_buffer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/simple_ring_buffer.c b/kernel/trace/simple_ring_buffer.c > index 02af2297ae5a..e991a0d8def2 100644 > --- a/kernel/trace/simple_ring_buffer.c > +++ b/kernel/trace/simple_ring_buffer.c > @@ -395,7 +395,7 @@ int simple_ring_buffer_init_mm(struct simple_rb_per_cpu *cpu_buffer, > > memset(cpu_buffer->meta, 0, sizeof(*cpu_buffer->meta)); > cpu_buffer->meta->meta_page_size = PAGE_SIZE; > - cpu_buffer->meta->nr_subbufs = cpu_buffer->nr_pages; > + cpu_buffer->meta->nr_subbufs = desc->nr_page_va; > > /* The reader page is not part of the ring initially */ > page = load_page(desc->page_va[0]);