From nobody Fri Jun 19 09:31:03 2026 Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) (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 203283E3C49 for ; Fri, 24 Apr 2026 20:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777062597; cv=none; b=TtaEsPbwZqRPzRDmHR/M681aN6H/Q34PP5vV627GF3WvIki8jpzmBKPNd8a6osPD9LB99IvoQeWqecWFyDejYgHZP4Xz3IBXS+tGYTouDiN1W8I2NfFXhIk4CyVQZkzpUbexUD9C6eLJS4fvnc9eyW1lF/ZfFbBd9KaRtqintDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777062597; c=relaxed/simple; bh=4/UgBp6wQtFvYOKwwgj8ruYtdqHY7gIZltOkm+BWv3M=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=ah8iMxm12e8q9S3vpVpsiLuiA7CDAzcYey/ET41Muf8oEQM1W01x6CZBVwVylPY6ImntmRHot2U6Oa18U4oc/ppxI5WpEb4m9GZnNe7l1Pl7x8tS3UzLWupw79tyiBR/7mFHDXesyS461hhZL5zLqv619v461aufhNwZvSy/MG4= 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.10 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 omf19.hostedemail.com (lb01b-stub [10.200.18.250]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 697F21C0077; Fri, 24 Apr 2026 20:23:26 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf19.hostedemail.com (Postfix) with ESMTPA id E891420025; Fri, 24 Apr 2026 20:23:24 +0000 (UTC) Date: Fri, 24 Apr 2026 16:23:30 -0400 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mathieu Desnoyers Subject: [GIT PULL] ring-buffer: Fix for 7.1 Message-ID: <20260424162330.247c0898@gandalf.local.home> 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-Transfer-Encoding: quoted-printable X-Stat-Signature: d7dwg35hpkhwj7yduhodp7hhtxrix6wf X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: E891420025 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1+Vwr9ESerNB/r35W2G7+VvcFGEEntfUyE= X-HE-Tag: 1777062204-562089 X-HE-Meta: U2FsdGVkX1+GTaYQg8XyCwJKIL6PDIh6AUh7kqS3NobsPmlY91tLro+H+U6xYiCC66evUIcmzOEVDKMRp+se/Ct7SjSawCjUydpl7Ghrq5Kkji01Cs9wNAzoJX1G2tqB3uPiQfk7lUZt5DFLIrsPucrfx5PoLj3h8x7c1Ogr6VYvl5HY6Pr9J74HWaYopXgWdAOO9SzW9M85UKy3TS4PzWec8kIVyuXiGtbFL9Nf+cawMcmrB/JKTLnJ9GT7j36gsJrTeN4pVYj0ygol9M/b39LeHQIIg+qqyAQbhgWcQmyFWeL/WdNcg6aItI+NCdxHffYvew1wkGjcufgzAuUrZGd7b0yMoWDPPpffvH6mxMedQi9+OdlaTTI9bq+gdHVu5V015UZORJn3Wu9tveaVoDJFmwzNAjZGy+plUjFz60T80a8ivLtMjBYjhecgygntcw/4I8ZTDJ74eDZstyOvh0VlOgxQI2ZWoN8FrmTf+urSl+2yazDobFy+sVD70fkWb5vPuV5lEn4witzwz0ZZ7Zhsee6Y3Kdkhdqek6Eg/JlMgGAJdQjZyBUCTOwKN3ON4CEAgyYbJB8wougwyO1Th65N2/TxTNId9UvQGZrmkxCefsxhwdD/kFhTLuNKi6At Content-Type: text/plain; charset="utf-8" Linus, ring-buffer fix for 7.1: - Fix accounting of persistent ring buffer rewind On boot up, the head page is moved back to the earliest point of the saved ring buffer. This is because the ring buffer being read by user space on a crash may not save the part it read. Rewinding the head page back to the earliest saved position helps keep those events from being lost. The number of events is also read during boot up and displayed in the stats file in the tracefs directory. It's also used for other accounting as well. On boot up, the "reader page" is accounted for but a rewind may put it back into the buffer and then the reader page may be accounted for again. Save off the original reader page and skip accounting it when scanning the pages in the ring buffer. Please pull the latest trace-ring-buffer-v7.1-3 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git trace-ring-buffer-v7.1-3 Tag SHA1: dce7a5a900b30a256337c89f337a94e5783b7b11 Head SHA1: 92d5a606721f759ebebf448b3bd2b7a781d50bd0 Masami Hiramatsu (Google) (1): ring-buffer: Do not double count the reader_page ---- kernel/trace/ring_buffer.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) --------------------------- commit 92d5a606721f759ebebf448b3bd2b7a781d50bd0 Author: Masami Hiramatsu (Google) Date: Fri Apr 24 15:52:10 2026 +0900 ring-buffer: Do not double count the reader_page =20 Since the cpu_buffer->reader_page is updated if there are unwound pages. After that update, we should skip the page if it is the original reader_page, because the original reader_page is already checked. =20 Cc: stable@vger.kernel.org Cc: Catalin Marinas Cc: Will Deacon Cc: Mathieu Desnoyers Cc: Ian Rogers Link: https://patch.msgid.link/177701353063.2223789.1471163147644103306= .stgit@mhiramat.tok.corp.google.com Fixes: ca296d32ece3 ("tracing: ring_buffer: Rewind persistent ring buff= er on reboot") Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index cef49f8871d2..5326924615a4 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1884,7 +1884,7 @@ static int rb_validate_buffer(struct buffer_data_page= *dpage, int cpu) static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer) { struct ring_buffer_cpu_meta *meta =3D cpu_buffer->ring_meta; - struct buffer_page *head_page, *orig_head; + struct buffer_page *head_page, *orig_head, *orig_reader; unsigned long entry_bytes =3D 0; unsigned long entries =3D 0; int ret; @@ -1895,16 +1895,17 @@ static void rb_meta_validate_events(struct ring_buf= fer_per_cpu *cpu_buffer) return; =20 orig_head =3D head_page =3D cpu_buffer->head_page; + orig_reader =3D cpu_buffer->reader_page; =20 /* Do the reader page first */ - ret =3D rb_validate_buffer(cpu_buffer->reader_page->page, cpu_buffer->cpu= ); + ret =3D rb_validate_buffer(orig_reader->page, cpu_buffer->cpu); if (ret < 0) { pr_info("Ring buffer reader page is invalid\n"); goto invalid; } entries +=3D ret; - entry_bytes +=3D local_read(&cpu_buffer->reader_page->page->commit); - local_set(&cpu_buffer->reader_page->entries, ret); + entry_bytes +=3D local_read(&orig_reader->page->commit); + local_set(&orig_reader->entries, ret); =20 ts =3D head_page->page->time_stamp; =20 @@ -2007,8 +2008,8 @@ static void rb_meta_validate_events(struct ring_buffe= r_per_cpu *cpu_buffer) /* Iterate until finding the commit page */ for (i =3D 0; i < meta->nr_subbufs + 1; i++, rb_inc_page(&head_page)) { =20 - /* Reader page has already been done */ - if (head_page =3D=3D cpu_buffer->reader_page) + /* The original reader page has already been checked/counted. */ + if (head_page =3D=3D orig_reader) continue; =20 ret =3D rb_validate_buffer(head_page->page, cpu_buffer->cpu);