From nobody Sun May 24 20:33:09 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 15BD329E0FD; Thu, 21 May 2026 13:47:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; cv=none; b=RLOj6DG2BhOCDuYCv1lUUn+g5hJstDmV616Y75QH+B0Or0b+pj7Gio1MgVzPhaDInkOExsNjnlJ9aRQeb4g/r+fAxuIjt/fkIXBONuaeHWCtrDLkudKuDImbY4+qzeyxBbXaPWNwP8DciQfseGA4ODtZknjDu1QjglVjRFbsiPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; c=relaxed/simple; bh=C/+huzwQQy8ajj4rVvsB+pzWHwDeRzD/4SFseRN/mrQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=rOXm8VLnlOnyJY877ugihwhlVAbDEXKbAbGALVwHh876SodbaXCyvsTxzq2lBchmg09t/RzlYn8Tt/BvU9om1cp2SZZIqFNHm98O/iB4/UNeqxilX0u0kaTigeKrWiDkcGPy49rEjOeLahwQbuqzGzwgeZll7Rzd8NUesTc4aFk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CVMYSt6b; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CVMYSt6b" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4D221F00A3B; Thu, 21 May 2026 13:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779371223; bh=0uiGPbL5sV7QZfJFJdgMkoYkhlZGTYfT5nxjMkpUgQY=; h=Date:From:To:Cc:Subject:References; b=CVMYSt6bbbT6mXSen8zWSa2qfSg84Qh+w3s4AWGaVvrk3Y+ZVin2iua4QVvlGiz+6 JZuGrwOTTb4CKUAcpTatC6qf+/AgsvlbuNuC9MvL3oHOQvkb70sqXaZp5Dn/v28CgB 4AJTBbgSr0JwayD9hmaMKKQjKSQtPRsoWcKZB3aQpwGBRIzOrYU8u5eIBEHbpN0BqI pYmYhLECzuDU9CQd+kD60ZsFWkQ9p6eZQTeo+NscLAH9FMyOi7YZhkqpGDvdrStW70 5SGXQ7gA96QCr4nkg7V3YbVyLLHRsMU21QewoIyA98QbtAT2/MxmJh4fWNf1UEh0zo /2p3t0IyytBug== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQ3kD-00000005MQV-0WyH; Thu, 21 May 2026 09:47:25 -0400 Message-ID: <20260521134724.958034353@kernel.org> User-Agent: quilt/0.69 Date: Thu, 21 May 2026 09:47:11 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org Subject: [for-linus][PATCH 1/5] ring-buffer: Fix reporting of missed events in iterator References: <20260521134710.628917428@kernel.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 When tracing is active while reading the trace file, if the iterator reading the buffer detects that the writer has passed the iterator head, it will reset and set a "missed events" flag. This flag is passed to the output processing to show the user that events were missed: CPU:4 [LOST EVENTS] The problem is that the flag is reset after it is checked in ring_buffer_iter_dropped(). But the "trace" file iterates over all the CPU ring buffers and it will check if they are dropped when figuring out which buffer to print next. This prematurely clears the missed_events flag if the CPU buffer with the missed events is not the one that is printed next. On the iteration where the CPU buffer with the missed events is printed, the check if it had missed events would return false and the output does not show that events were missed. Do not reset the missed_events flag when checking if there were missed events, but instead clear it when moving the iterator head to the next event. Cc: stable@vger.kernel.org Cc: Mathieu Desnoyers Link: https://patch.msgid.link/20260520220801.4fd09d13@fedora Fixes: c9b7a4a72ff64 ("ring-buffer/tracing: Have iterator acknowledge dropp= ed events") Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt --- kernel/trace/ring_buffer.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 5326924615a4..fcd93d49851e 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -5407,6 +5407,7 @@ static void rb_iter_reset(struct ring_buffer_iter *it= er) iter->head_page =3D cpu_buffer->reader_page; iter->head =3D cpu_buffer->reader_page->read; iter->next_event =3D iter->head; + iter->missed_events =3D 0; =20 iter->cache_reader_page =3D iter->head_page; iter->cache_read =3D cpu_buffer->read; @@ -6086,10 +6087,7 @@ ring_buffer_peek(struct trace_buffer *buffer, int cp= u, u64 *ts, */ bool ring_buffer_iter_dropped(struct ring_buffer_iter *iter) { - bool ret =3D iter->missed_events !=3D 0; - - iter->missed_events =3D 0; - return ret; + return iter->missed_events !=3D 0; } EXPORT_SYMBOL_GPL(ring_buffer_iter_dropped); =20 @@ -6251,7 +6249,7 @@ void ring_buffer_iter_advance(struct ring_buffer_iter= *iter) unsigned long flags; =20 raw_spin_lock_irqsave(&cpu_buffer->reader_lock, flags); - + iter->missed_events =3D 0; rb_advance_iter(iter); =20 raw_spin_unlock_irqrestore(&cpu_buffer->reader_lock, flags); --=20 2.53.0 From nobody Sun May 24 20:33:09 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3D2641DF73A; Thu, 21 May 2026 13:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; cv=none; b=j40WQ4vj/pewDGgFfmeM0zkvHkHD3djwYfrPinQbi7OFoL+wnwvKYd0u0dyLjYcEx5Y3tEneDospQVfj1feNMQJ1LRb4AbBsr7Fw1RrGfqybqIJRLpZwrQkP7uyM28QG1Qyrbom3HwteL/Xe/XBoKqFIIxoGVToHGkKqt3CMIEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; c=relaxed/simple; bh=F3iikO8Uz4EAcJ0IAlwvXdvSQl038zdaQaUE1ubP9Cg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tlAEj+ttgvoz9Y8fC3nsrEisxP1adO3U5Atz5VTwQAmWh3ZkxpN2OL0mbPoPg3y3EnfYdfw8TcS2NTIoiouXvSYOZQYD7naCEDr3R8VYivpW9mBpXUjPp7gm5KNSfaly0ZoocHoVQ1FDsyPyLMUNqSj+gZpMFlaoHIi6nTdiSFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ns0D8nbR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ns0D8nbR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECAB11F00A3C; Thu, 21 May 2026 13:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779371224; bh=nF7qMQGaaHbZQ+n3UDyZ5sDFLWW9T5KuUMLMWM67Bfw=; h=Date:From:To:Cc:Subject:References; b=Ns0D8nbRmiQhLgEyTwiF9KWItApa+lSh6E77szodT4VyJyY1YuxAF8LATpazvxPtn 2sCkDV6Kit5/XU6S+EOg2c1+XUj72a5ablaBn6zQtoDVJm2SrYbSeWkP/RQng2jF8u 8ZntpkxdjyjFrUl0nQuAavSaFCKISo7mV5DqpDknYd2zU8GToknii7cHA9wdTZzIbn ibFtGsl1HCcQ83lIHP6YANoZIgf3hynkphhsp/l+22xiQwYGadBOn+wiulghu4BUiU qGeJgAHTmTU+4ag0TVKSj1dB5wHpVlXATtEuRL7TTnRh1AErtttqrBz2Ej+qP4JPN+ CLk+J/8aOr6/w== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQ3kD-00000005MQz-1DyS; Thu, 21 May 2026 09:47:25 -0400 Message-ID: <20260521134725.147297264@kernel.org> User-Agent: quilt/0.69 Date: Thu, 21 May 2026 09:47:12 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Will Deacon , Ian Rogers , Catalin Marinas , Geert Uytterhoeven Subject: [for-linus][PATCH 2/5] ring-buffer: Flush and stop persistent ring buffer on panic References: <20260521134710.628917428@kernel.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: "Masami Hiramatsu (Google)" On real hardware, panic and machine reboot may not flush hardware cache to memory. This means the persistent ring buffer, which relies on a coherent state of memory, may not have its events written to the buffer and they may be lost. Moreover, there may be inconsistency with the counters which are used for validation of the integrity of the persistent ring buffer which may cause all data to be discarded. To avoid this issue, stop recording of the ring buffer on panic and flush the cache of the ring buffer's memory. Fixes: e645535a954a ("tracing: Add option to use memmapped memory for trace= boot instance") Cc: stable@vger.kernel.org Cc: Will Deacon Cc: Mathieu Desnoyers Cc: Ian Rogers Link: https://patch.msgid.link/177751969602.2136606.12031934362587643488.st= git@mhiramat.tok.corp.google.com Signed-off-by: Masami Hiramatsu (Google) Acked-by: Catalin Marinas Acked-by: Geert Uytterhoeven Signed-off-by: Steven Rostedt --- arch/alpha/include/asm/Kbuild | 1 + arch/arc/include/asm/Kbuild | 1 + arch/arm/include/asm/Kbuild | 1 + arch/arm64/include/asm/ring_buffer.h | 10 ++++++++++ arch/csky/include/asm/Kbuild | 1 + arch/hexagon/include/asm/Kbuild | 1 + arch/loongarch/include/asm/Kbuild | 1 + arch/m68k/include/asm/Kbuild | 1 + arch/microblaze/include/asm/Kbuild | 1 + arch/mips/include/asm/Kbuild | 1 + arch/nios2/include/asm/Kbuild | 1 + arch/openrisc/include/asm/Kbuild | 1 + arch/parisc/include/asm/Kbuild | 1 + arch/powerpc/include/asm/Kbuild | 1 + arch/riscv/include/asm/Kbuild | 1 + arch/s390/include/asm/Kbuild | 1 + arch/sh/include/asm/Kbuild | 1 + arch/sparc/include/asm/Kbuild | 1 + arch/um/include/asm/Kbuild | 1 + arch/x86/include/asm/Kbuild | 1 + arch/xtensa/include/asm/Kbuild | 1 + include/asm-generic/ring_buffer.h | 13 +++++++++++++ kernel/trace/ring_buffer.c | 22 ++++++++++++++++++++++ 23 files changed, 65 insertions(+) create mode 100644 arch/arm64/include/asm/ring_buffer.h create mode 100644 include/asm-generic/ring_buffer.h diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild index 483965c5a4de..b154b4e3dfa8 100644 --- a/arch/alpha/include/asm/Kbuild +++ b/arch/alpha/include/asm/Kbuild @@ -5,4 +5,5 @@ generic-y +=3D agp.h generic-y +=3D asm-offsets.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D text-patching.h diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index 4c69522e0328..483caacc6988 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -5,5 +5,6 @@ generic-y +=3D extable.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h generic-y +=3D parport.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h generic-y +=3D text-patching.h diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild index 03657ff8fbe3..decad5f2c826 100644 --- a/arch/arm/include/asm/Kbuild +++ b/arch/arm/include/asm/Kbuild @@ -3,6 +3,7 @@ generic-y +=3D early_ioremap.h generic-y +=3D extable.h generic-y +=3D flat.h generic-y +=3D parport.h +generic-y +=3D ring_buffer.h =20 generated-y +=3D mach-types.h generated-y +=3D unistd-nr.h diff --git a/arch/arm64/include/asm/ring_buffer.h b/arch/arm64/include/asm/= ring_buffer.h new file mode 100644 index 000000000000..62316c406888 --- /dev/null +++ b/arch/arm64/include/asm/ring_buffer.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_ARM64_RING_BUFFER_H +#define _ASM_ARM64_RING_BUFFER_H + +#include + +/* Flush D-cache on persistent ring buffer */ +#define arch_ring_buffer_flush_range(start, end) dcache_clean_pop(start, e= nd) + +#endif /* _ASM_ARM64_RING_BUFFER_H */ diff --git a/arch/csky/include/asm/Kbuild b/arch/csky/include/asm/Kbuild index 3a5c7f6e5aac..7dca0c6cdc84 100644 --- a/arch/csky/include/asm/Kbuild +++ b/arch/csky/include/asm/Kbuild @@ -9,6 +9,7 @@ generic-y +=3D qrwlock.h generic-y +=3D qrwlock_types.h generic-y +=3D qspinlock.h generic-y +=3D parport.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h generic-y +=3D vmlinux.lds.h generic-y +=3D text-patching.h diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbu= ild index 1efa1e993d4b..0f887d4238ed 100644 --- a/arch/hexagon/include/asm/Kbuild +++ b/arch/hexagon/include/asm/Kbuild @@ -5,4 +5,5 @@ generic-y +=3D extable.h generic-y +=3D iomap.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D text-patching.h diff --git a/arch/loongarch/include/asm/Kbuild b/arch/loongarch/include/asm= /Kbuild index 9034b583a88a..7e92957baf6a 100644 --- a/arch/loongarch/include/asm/Kbuild +++ b/arch/loongarch/include/asm/Kbuild @@ -10,5 +10,6 @@ generic-y +=3D qrwlock.h generic-y +=3D user.h generic-y +=3D ioctl.h generic-y +=3D mmzone.h +generic-y +=3D ring_buffer.h generic-y +=3D statfs.h generic-y +=3D text-patching.h diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild index b282e0dd8dc1..62543bf305ff 100644 --- a/arch/m68k/include/asm/Kbuild +++ b/arch/m68k/include/asm/Kbuild @@ -3,5 +3,6 @@ generated-y +=3D syscall_table.h generic-y +=3D extable.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D spinlock.h generic-y +=3D text-patching.h diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/a= sm/Kbuild index 7178f990e8b3..0030309b47ad 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild @@ -5,6 +5,7 @@ generic-y +=3D extable.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h generic-y +=3D parport.h +generic-y +=3D ring_buffer.h generic-y +=3D syscalls.h generic-y +=3D tlb.h generic-y +=3D user.h diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild index 684569b2ecd6..9771c3d85074 100644 --- a/arch/mips/include/asm/Kbuild +++ b/arch/mips/include/asm/Kbuild @@ -12,5 +12,6 @@ generic-y +=3D mcs_spinlock.h generic-y +=3D parport.h generic-y +=3D qrwlock.h generic-y +=3D qspinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h generic-y +=3D text-patching.h diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild index 28004301c236..0a2530964413 100644 --- a/arch/nios2/include/asm/Kbuild +++ b/arch/nios2/include/asm/Kbuild @@ -5,6 +5,7 @@ generic-y +=3D cmpxchg.h generic-y +=3D extable.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D spinlock.h generic-y +=3D user.h generic-y +=3D text-patching.h diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/K= build index cef49d60d74c..8aa34621702d 100644 --- a/arch/openrisc/include/asm/Kbuild +++ b/arch/openrisc/include/asm/Kbuild @@ -8,4 +8,5 @@ generic-y +=3D spinlock_types.h generic-y +=3D spinlock.h generic-y +=3D qrwlock_types.h generic-y +=3D qrwlock.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h diff --git a/arch/parisc/include/asm/Kbuild b/arch/parisc/include/asm/Kbuild index 4fb596d94c89..d48d158f7241 100644 --- a/arch/parisc/include/asm/Kbuild +++ b/arch/parisc/include/asm/Kbuild @@ -4,4 +4,5 @@ generated-y +=3D syscall_table_64.h generic-y +=3D agp.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbu= ild index 2e23533b67e3..805b5aeebb6f 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild @@ -5,4 +5,5 @@ generated-y +=3D syscall_table_spu.h generic-y +=3D agp.h generic-y +=3D mcs_spinlock.h generic-y +=3D qrwlock.h +generic-y +=3D ring_buffer.h generic-y +=3D early_ioremap.h diff --git a/arch/riscv/include/asm/Kbuild b/arch/riscv/include/asm/Kbuild index bd5fc9403295..7721b63642f4 100644 --- a/arch/riscv/include/asm/Kbuild +++ b/arch/riscv/include/asm/Kbuild @@ -14,5 +14,6 @@ generic-y +=3D ticket_spinlock.h generic-y +=3D qrwlock.h generic-y +=3D qrwlock_types.h generic-y +=3D qspinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h generic-y +=3D vmlinux.lds.h diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild index 80bad7de7a04..0c1fc47c3ba0 100644 --- a/arch/s390/include/asm/Kbuild +++ b/arch/s390/include/asm/Kbuild @@ -7,3 +7,4 @@ generated-y +=3D unistd_nr.h generic-y +=3D asm-offsets.h generic-y +=3D mcs_spinlock.h generic-y +=3D mmzone.h +generic-y +=3D ring_buffer.h diff --git a/arch/sh/include/asm/Kbuild b/arch/sh/include/asm/Kbuild index 4d3f10ed8275..f0403d3ee8ab 100644 --- a/arch/sh/include/asm/Kbuild +++ b/arch/sh/include/asm/Kbuild @@ -3,4 +3,5 @@ generated-y +=3D syscall_table.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h generic-y +=3D parport.h +generic-y +=3D ring_buffer.h generic-y +=3D text-patching.h diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild index 17ee8a273aa6..49c6bb326b75 100644 --- a/arch/sparc/include/asm/Kbuild +++ b/arch/sparc/include/asm/Kbuild @@ -4,4 +4,5 @@ generated-y +=3D syscall_table_64.h generic-y +=3D agp.h generic-y +=3D kvm_para.h generic-y +=3D mcs_spinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D text-patching.h diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index 1b9b82bbe322..2a1629ba8140 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild @@ -17,6 +17,7 @@ generic-y +=3D module.lds.h generic-y +=3D parport.h generic-y +=3D percpu.h generic-y +=3D preempt.h +generic-y +=3D ring_buffer.h generic-y +=3D runtime-const.h generic-y +=3D softirq_stack.h generic-y +=3D switch_to.h diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index 4566000e15c4..078fd2c0d69d 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -14,3 +14,4 @@ generic-y +=3D early_ioremap.h generic-y +=3D fprobe.h generic-y +=3D mcs_spinlock.h generic-y +=3D mmzone.h +generic-y +=3D ring_buffer.h diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild index 13fe45dea296..e57af619263a 100644 --- a/arch/xtensa/include/asm/Kbuild +++ b/arch/xtensa/include/asm/Kbuild @@ -6,5 +6,6 @@ generic-y +=3D mcs_spinlock.h generic-y +=3D parport.h generic-y +=3D qrwlock.h generic-y +=3D qspinlock.h +generic-y +=3D ring_buffer.h generic-y +=3D user.h generic-y +=3D text-patching.h diff --git a/include/asm-generic/ring_buffer.h b/include/asm-generic/ring_b= uffer.h new file mode 100644 index 000000000000..201d2aee1005 --- /dev/null +++ b/include/asm-generic/ring_buffer.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Generic arch dependent ring_buffer macros. + */ +#ifndef __ASM_GENERIC_RING_BUFFER_H__ +#define __ASM_GENERIC_RING_BUFFER_H__ + +#include + +/* Flush cache on ring buffer range if needed. Do nothing by default. */ +#define arch_ring_buffer_flush_range(start, end) do { } while (0) + +#endif /* __ASM_GENERIC_RING_BUFFER_H__ */ diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index fcd93d49851e..7b07d2004cc6 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include =20 +#include #include #include #include @@ -559,6 +561,7 @@ struct trace_buffer { =20 unsigned long range_addr_start; unsigned long range_addr_end; + struct notifier_block flush_nb; =20 struct ring_buffer_meta *meta; =20 @@ -2521,6 +2524,16 @@ static void rb_free_cpu_buffer(struct ring_buffer_pe= r_cpu *cpu_buffer) kfree(cpu_buffer); } =20 +/* Stop recording on a persistent buffer and flush cache if needed. */ +static int rb_flush_buffer_cb(struct notifier_block *nb, unsigned long eve= nt, void *data) +{ + struct trace_buffer *buffer =3D container_of(nb, struct trace_buffer, flu= sh_nb); + + ring_buffer_record_off(buffer); + arch_ring_buffer_flush_range(buffer->range_addr_start, buffer->range_addr= _end); + return NOTIFY_DONE; +} + static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flag= s, int order, unsigned long start, unsigned long end, @@ -2651,6 +2664,12 @@ static struct trace_buffer *alloc_buffer(unsigned lo= ng size, unsigned flags, =20 mutex_init(&buffer->mutex); =20 + /* Persistent ring buffer needs to flush cache before reboot. */ + if (start && end) { + buffer->flush_nb.notifier_call =3D rb_flush_buffer_cb; + atomic_notifier_chain_register(&panic_notifier_list, &buffer->flush_nb); + } + return_ptr(buffer); =20 fail_free_buffers: @@ -2749,6 +2768,9 @@ ring_buffer_free(struct trace_buffer *buffer) { int cpu; =20 + if (buffer->range_addr_start && buffer->range_addr_end) + atomic_notifier_chain_unregister(&panic_notifier_list, &buffer->flush_nb= ); + cpuhp_state_remove_instance(CPUHP_TRACE_RB_PREPARE, &buffer->node); =20 irq_work_sync(&buffer->irq_work.work); --=20 2.53.0 From nobody Sun May 24 20:33:09 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 5174E2D12F3 for ; Thu, 21 May 2026 13:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; cv=none; b=Osru0pNbQJTHit5o4Hdwa96wq+3n5gXMEYW+O7gescc8S7ErvrZqjvN9pJ+oFm1HZNEyTEoQ694NQYfbHLhheEu5OtIs4nx+yBftCYE4jK5QEH5h/NGcIuJQ4zu01W29si2PY7pWO1Lynx8xRI+0NFjgynt24ySerHvPeQLEmLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; c=relaxed/simple; bh=HipBzwZbSzE7ksr//g8ykugyaefNuo+SYSzJKfHdl2Y=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=PKXFS7EiCLVudja6sl0QCbGBFkr7B4BT4iWEk68ieHS868nLNkhCFCT9rINc0+vZZ3xJC5KsXVmO32dn9q5Y+a+SsMWidLyHibOSxTA5kNq1nOPa4UdDZkutaCvh3xTXHdCNZd5Yr0VJcdhmKSQNiBlQpDJt5N4p+B7l+jOM3/M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UvXHar1k; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UvXHar1k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24F9C1F00A3F; Thu, 21 May 2026 13:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779371224; bh=AtgZUkr0l5IwFjKUqHKTZ0sBSZvBMwOZ6pEXD1xGKMA=; h=Date:From:To:Cc:Subject:References; b=UvXHar1kjfAh1aQ+C2HnZn9Z76xWqqbACuB7mSpXX94JOU89gGof+Y9enThk5JUlN zIyK6jhLTtoQvG1evsPKgeJJM730vxlDm+avQ0UUWgWrHsYul3pIJ4ZvhYKR0l3AmS 2A2VtfkNGL4dlP7dA0eLE6aJr92WYxVkZtd4cT9mOhTEFhubPzNtP3Vj0Y3CWhMTeo 6BrNfSTd07tbX/Od1hJch2HOXKiPOg/qeiymOJjmvjrCesWcGQ6k/wrRUDebEDhhRP ubBuPttOiJsTaUutXksgc9SYSoSrtvV9m+MZTUutCOxiRsUJu5yGx4hLKB3O7/avm1 UwJqMaWeFJrwA== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQ3kD-00000005MRT-1uyu; Thu, 21 May 2026 09:47:25 -0400 Message-ID: <20260521134725.311592796@kernel.org> User-Agent: quilt/0.69 Date: Thu, 21 May 2026 09:47:13 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort , David Carlier Subject: [for-linus][PATCH 3/5] tracing: Fix nr_subbufs initialization in simple_ring_buffer_init_mm() References: <20260521134710.628917428@kernel.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: David Carlier nr_subbufs in the ring buffer metadata is always initialized to zero because it is assigned from cpu_buffer->nr_pages before the page initialization loop has run. While nr_subbufs is not currently read by the kernel, it should reflect the actual buffer geometry in the meta page for correctness. Move the assignment after the page loop so that cpu_buffer->nr_pages holds the final count. Link: https://patch.msgid.link/20260512135420.99194-1-devnexen@gmail.com Fixes: 34e5b958bdad ("tracing: Introduce simple_ring_buffer") Reviewed-by: Vincent Donnefort Assisted-by: Claude:claude-opus-4-7 Signed-off-by: David Carlier Signed-off-by: Steven Rostedt --- 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_b= uffer.c index 02af2297ae5a..f731f14d0ff7 100644 --- a/kernel/trace/simple_ring_buffer.c +++ b/kernel/trace/simple_ring_buffer.c @@ -395,7 +395,6 @@ int simple_ring_buffer_init_mm(struct simple_rb_per_cpu= *cpu_buffer, =20 memset(cpu_buffer->meta, 0, sizeof(*cpu_buffer->meta)); cpu_buffer->meta->meta_page_size =3D PAGE_SIZE; - cpu_buffer->meta->nr_subbufs =3D cpu_buffer->nr_pages; =20 /* The reader page is not part of the ring initially */ page =3D load_page(desc->page_va[0]); @@ -437,6 +436,7 @@ int simple_ring_buffer_init_mm(struct simple_rb_per_cpu= *cpu_buffer, return ret; } =20 + cpu_buffer->meta->nr_subbufs =3D cpu_buffer->nr_pages; /* Close the ring */ bpage->link.next =3D &cpu_buffer->tail_page->link; cpu_buffer->tail_page->link.prev =3D &bpage->link; --=20 2.53.0 From nobody Sun May 24 20:33:09 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 6575E37BE6A for ; Thu, 21 May 2026 13:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; cv=none; b=ZSfbY3t4xBxg2Gc9AP1sRqY/IrJJNeWr3Q6DfdQ70pS6pU4GuL33pVSKIkGrojyrdlzzfOJjj1uz65g1hmWdeMeiQyS7qo81+0OT4pgzt4/6/mSTBoeEgJZjAqJSrH/cnTOZSSItLmplMs24yAU+qQth2PlfcwYq//m6ZNPHbAw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371225; c=relaxed/simple; bh=rP+WnGwz1FcEVciOzghel2ALRqmEA82Tbhd3o0IdQjg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=eXkT7yXqCsiq74dGlZn/yaOmBxHXqax+eMnYmp80NgEQIFYlPEyUNFKRLEu50EGTm8VchQQHK+gdWcEL22t7a/xvWEH73yHFD0KZ/wehL9xa7ZxrUA4NE3QJu2oVs4zvkCgkOWt5OzaDwa3uDXAbc9dIDUSoUKZITS+WdGv0zH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BEsyF3Wy; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BEsyF3Wy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B5E01F00ADE; Thu, 21 May 2026 13:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779371224; bh=nTJ61wXaXZbaJ71A6SRncamqCeqTfeu6ZHV7bFIcNCQ=; h=Date:From:To:Cc:Subject:References; b=BEsyF3WyaDDWaYzkdlNgn0DOcPqWxQItAWUp3hvkF8IHBhAarojTqWWJvw3AR6+Yp ruYwkzIENJCeTGO1vIrhfGJoxDDnzpfhoFzjusW8rbwyYx985paWLAjRZeLmHArd71 HvGfQxcbTsuDOEva7X9aYKMPWa+xBBR4fc6i3kNQXbPnDGdhxpC625L/O3EA1LuuIj 3Rqven9A2LvB7D4jMnYHim5zU3efWmw7mKtAhiDGZ7/dzdrG6dmUEnrODrJAtw99MF rUoS6G+4qMKOdWyLQKiBlvfJrvGvYJVmQQU669CqHu2hhu9RjF4pHHu7nFeC1pyIT7 OyAwOc5VYWUCg== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQ3kD-00000005MRy-2cpa; Thu, 21 May 2026 09:47:25 -0400 Message-ID: <20260521134725.477015754@kernel.org> User-Agent: quilt/0.69 Date: Thu, 21 May 2026 09:47:14 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort Subject: [for-linus][PATCH 4/5] tracing: Fix unload_page for simple_ring_buffer init rollback References: <20260521134710.628917428@kernel.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: Vincent Donnefort The unload_page callback expects the return value of load_page() as its argument: ret =3D load_page(va); unload(ret). Fix the rollback code in simple_ring_buffer_init_mm() where the descriptor's VA is used instead of the loaded page address. Link: https://patch.msgid.link/20260512141614.1759430-1-vdonnefort@google.c= om Fixes: 635923081c79 ("tracing: load/unload page callbacks for simple_ring_b= uffer") Signed-off-by: Vincent Donnefort Signed-off-by: Steven Rostedt --- 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_b= uffer.c index f731f14d0ff7..f4642f5adda3 100644 --- a/kernel/trace/simple_ring_buffer.c +++ b/kernel/trace/simple_ring_buffer.c @@ -430,7 +430,7 @@ int simple_ring_buffer_init_mm(struct simple_rb_per_cpu= *cpu_buffer, =20 if (ret) { for (i--; i >=3D 0; i--) - unload_page((void *)desc->page_va[i]); + unload_page(bpages[i].page); unload_page(cpu_buffer->meta); =20 return ret; --=20 2.53.0 From nobody Sun May 24 20:33:09 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 83E0A3C819E for ; Thu, 21 May 2026 13:47:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371226; cv=none; b=AyV5lQaECgh1hz8aF1y8r/zK4aHTuAlUpREzUAAhKvD/ZhyRuBD9gD/AjHfIPI89+THzophNpJAP1n+oUn5cIL2uD/m8Ab+f34bFprFPESDVDw/NcvvEvIeMM9KBOIakAGeh5G7Llo8T8KziFht6DUcN3/TIS3ARyUotkXmdm2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779371226; c=relaxed/simple; bh=uslIoqmzcEZWtww7upAqRcFT35B1VWlcNAGmLw/xnsU=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tzKCHMrK17duX/yTi9/1JSaFRI3DyBGdtduYYTzPNgrisMcdZDyKhx6+d6B54tm8WJyFHrMqmGAoFghhJUkX7ha0kVxUosq1kkspjRhS03U0/R3AT4XZKn2Dlp0oGgiYf7KzvOSSaU8aGSPxMmkUMiaHtUCtmxjBrxnRtiW524o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Eto/MGFw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Eto/MGFw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71F881F00A3E; Thu, 21 May 2026 13:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779371224; bh=Rmd81ZKl/0JPJy3Z/bsvNjMegsIAuD7HYU0yoOfNNDs=; h=Date:From:To:Cc:Subject:References; b=Eto/MGFwwuvK2wtwKF5U2F56D8MrBn5FHfT8rfjyfrgVqW8WbZn8YzNivzmNUpXmi uIgh2wQuErW1fJGUhLaaOXX2lXJLdG5u7QsKLv3hmG3cwJqnhv8JIISmsrdH4HFbDU tukJocVrjUXP7sIzb+PVp3xxrSQ2cO2I8T2X5rf0/AT3rT/nAFrxKBUCmX1FMLuCXQ uCKM7DrVA5zrIRtL66A4eiHTK4qQkyrKm1TTkQAY18KdabyIEw/erL+Jr/WxhzqCPd qAjhyiHUPUvMkOtjNhAmfp1fnO2jfF6JVDZlMo4iiACMjw7CDz4VmhOVDPdtB7r4Jg R1Th0Y6ydgLcQ== Received: from rostedt by gandalf with local (Exim 4.99.2) (envelope-from ) id 1wQ3kD-00000005MSS-3G6O; Thu, 21 May 2026 09:47:25 -0400 Message-ID: <20260521134725.646411250@kernel.org> User-Agent: quilt/0.69 Date: Thu, 21 May 2026 09:47:15 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort , Marc Zyngier , Arnd Bergmann , Nathan Chancellor , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [for-linus][PATCH 5/5] tracing: Create output file from cmd_check_undefined References: <20260521134710.628917428@kernel.org> 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="utf-8" Content-Transfer-Encoding: quoted-printable From: =3D?UTF-8?q?Thomas=3D20Wei=3DC3=3D9Fschuh?=3D As the output file is currently never created, the check will run every time, even if the inputs have not changed. Create an empty output file which allows make to skip the execution when it is not necessary. Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Cc: Vincent Donnefort Cc: Marc Zyngier Cc: Arnd Bergmann Link: https://patch.msgid.link/20260520-tracing-ringbuffer-check-v1-1-d979c= fab1338@weissschuh.net Fixes: 1211907ac0b5 ("tracing: Generate undef symbols allowlist for simple_= ring_buffer") Fixes: 58b4bd18390e ("tracing: Adjust cmd_check_undefined to show unexpecte= d undefined symbols") Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Thomas Wei=C3=9Fschuh Signed-off-by: Steven Rostedt --- kernel/trace/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/trace/Makefile b/kernel/trace/Makefile index 9b0834134cae..8d3d96e847d8 100644 --- a/kernel/trace/Makefile +++ b/kernel/trace/Makefile @@ -154,7 +154,8 @@ quiet_cmd_check_undefined =3D NM $< echo "Unexpected symbols in $<:" >&2; \ echo "$$undefsyms" >&2; \ false; \ - fi + fi; \ + touch $@ =20 $(obj)/%.o.checked: $(obj)/%.o $(obj)/undefsyms_base.o FORCE $(call if_changed,check_undefined) --=20 2.53.0