From nobody Fri Dec 19 18:29:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 282B017799F; Sat, 15 Feb 2025 03:52:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739591569; cv=none; b=dJhie5GHlcCGiPGO0KEHXR+KO1YrX8xim2L/jdG15zg2sONHmOZAZfVJH+aZVLhwwgxs5r+KPScvVm5cyCvPafVJG2F8WUyV18qdHbQ/8VLXArFPQ9zvQv6KRJ4C4SJ+EEiwjLZCKpWK+Vq/fN7PZJW8D1zdZBb5AIAwoeeXpkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739591569; c=relaxed/simple; bh=s4WmS2kRHPuaEIzsd7gYZwiPeVAc/SGM3MwLSlgJonA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=Eb/BXnoOou6YhFFhz1Blr67BovL1TFaFh2xM164OWOqLrigbBjEWdglsiNRNwIzfv0UzlwKavMfXWiP7QaekoEjhf+mer7KIfYNQgyrSCOKea/8JOdfA2FSQBCFFHX+WLcOtUjuPuObQ5ylJN8Q9QXJb++Vdvxnri5IU/h2ySKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 138A0C4CEE6; Sat, 15 Feb 2025 03:52:49 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tj9El-00000002hG1-06uK; Fri, 14 Feb 2025 22:53:03 -0500 Message-ID: <20250215035302.872962698@goodmis.org> User-Agent: quilt/0.68 Date: Fri, 14 Feb 2025 22:52:36 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Vincent Donnefort Subject: [for-linus][PATCH 5/5] ring-buffer: Update pages_touched to reflect persistent buffer content References: <20250215035231.786853904@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt The pages_touched field represents the number of subbuffers in the ring buffer that have content that can be read. This is used in accounting of "dirty_pages" and "buffer_percent" to allow the user to wait for the buffer to be filled to a certain amount before it reads the buffer in blocking mode. The persistent buffer never updated this value so it was set to zero, and this accounting would take it as it had no content. This would cause user space to wait for content even though there's enough content in the ring buffer that satisfies the buffer_percent. Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Vincent Donnefort Link: https://lore.kernel.org/20250214123512.0631436e@gandalf.local.home Fixes: 5f3b6e839f3ce ("ring-buffer: Validate boot range memory events") Signed-off-by: Steven Rostedt (Google) --- kernel/trace/ring_buffer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 0419d41a2060..bb6089c2951e 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1850,6 +1850,11 @@ static void rb_meta_validate_events(struct ring_buff= er_per_cpu *cpu_buffer) cpu_buffer->cpu); goto invalid; } + + /* If the buffer has content, update pages_touched */ + if (ret) + local_inc(&cpu_buffer->pages_touched); + entries +=3D ret; entry_bytes +=3D local_read(&head_page->page->commit); local_set(&cpu_buffer->head_page->entries, ret); --=20 2.47.2