From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
Vincent Donnefort <vdonnefort@google.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/tracing: Flush persistent ring buffer cache on panic
Date: Wed, 2 Dec 2026 08:50:57 -0500 [thread overview]
Message-ID: <20261202085057.5a08a448@gandalf.local.home> (raw)
In-Reply-To: <20261202053440.2609843-1-mhiramat@kernel.org>
On Wed, 2 Dec 2026 14:34:40 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> Persistent ring buffers (configured via reserve_mem= and
> trace_instance=...@...) are mapped as write-back (WB) cached memory.
> While x86-TSO keeps caches coherent across CPUs during normal
> operation, it does not guarantee that dirty cache lines are written back
> to DRAM before a hard reset triggered on panic (for example,
> emergency_restart() via acpi_reboot() writing to port 0xcf9, where
> neither stop_this_cpu() on normal WB memory nor acpi_reboot() flushes
> CPU caches).
>
> Currently arch/x86/include/asm/Kbuild falls back to
> asm-generic/ring_buffer.h, leaving arch_ring_buffer_flush_range() as a
> no-op on x86. On real x86 hardware, a panic-triggered reboot therefore
> loses dirty cache lines in L1/L2/LLC for the persistent ring buffer: on
> the next boot, rb_validate_buffer() either detects inconsistent pages
> ("Ring buffer meta [N] invalid buffer page") and discards the affected
> CPU buffer, or validates up to a stale commit pointer in DRAM and
> silently drops the last several milliseconds of trace events immediately
> preceding the panic.
>
> Implement arch_ring_buffer_flush_range() for x86 using
> clflush_cache_range() (chunked by SZ_2G to accommodate unsigned long
> ranges against clflush_cache_range()'s unsigned int size parameter),
> falling back to wbinvd() if X86_FEATURE_CLFLUSH is not available.
> Because CLFLUSH/CLFLUSHOPT broadcast across the cache coherence domain
> and require no IPIs, locks, or sleeping, the panicking CPU can safely
> write back dirty lines from all halted CPUs in panic/NMI context.
>
> Tested on an x86_64 Intel system with repeated sysrq-c panic reboots:
> without this change, 0/5 runs preserved a trace_marker written
> immediately before panic and 1-4 CPUs per reboot reported invalid buffer
> pages; with this change, 5/5 runs preserved the final pre-panic
> trace_marker with 0 invalid buffer pages across all 8 CPUs.
>
> Fixes: a494d3c8d539 ("ring-buffer: Flush and stop persistent ring buffer on panic")
> Cc: stable@vger.kernel.org
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
-- Steve
next prev parent reply other threads:[~2026-12-02 13:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 5:34 [PATCH] x86/tracing: Flush persistent ring buffer cache on panic Masami Hiramatsu (Google)
2026-12-02 13:50 ` Steven Rostedt [this message]
2026-12-03 2:07 ` Masami Hiramatsu (Google)
2026-12-03 2:10 ` Steven Rostedt
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=20261202085057.5a08a448@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=geert@linux-m68k.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--cc=vdonnefort@google.com \
--cc=x86@kernel.org \
/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