pstore/blk: add best-effort polled panic_write for block devices
Subsystems (3)
PATCH 1/1 pstore/blk: add best-effort polled panic_write for block devices
The NVIDIA Jetson Thor platform is unable to use RAM for storing panic logs because its DRAM ECC scrub runs during the reset path, so a RAM carveout is not preserved in a way Linux can rely on after reboot. Hence, there is no persistent RAM region available for ramoops. NVMe storage is available on the Jetson Thor platform which would be the desired pstore/blk backend for storing panic dmesg records.
pstore/blk already has a best-effort mode for normal block devices, but it does not currently support panic dmesg records from that mode. The best-effort path opens the configured block device and wires only the pstore/zone read and write callbacks. During a panic, pstore/zone uses its optional panic_write callback for dmesg records. Without that callback, the panic record is only marked dirty in memory and the reboot happens before the normal write path can flush it. The generic block write path is not suitable for this callback because it can sleep and depends on normal block-layer completion handling.
Add a best-effort panic_write implementation for block devices that can submit nonblocking polled writes. The writer uses a static bio and bvec array, maps the pstore buffer pages, submits REQ_POLLED | REQ_NOWAIT, and polls completion with bio_poll(BLK_POLL_ONESHOT). Writes are split to queue limits and must be sector and logical-block aligned, which matches pstore/zone panic dmesg FLUSH_ALL records.
Only enable the callback when the queue has poll hardware queues, the block device supports nowait submission, and FUA is available if the write cache is enabled. Unsupported devices continue to attach in best-effort mode without panic_write and log the reason. Use REQ_FUA for data writes, but avoid REQ_PREFLUSH because flush requests do not provide a poll cookie that can be waited on from the panic path.
Tag the write as metadata, priority, sync and idle I/O. These flags keep the record on the urgent metadata path while avoiding writeback-throttle waits in configurations where that policy is active.
This makes pstore/blk best-effort mode usable with NVMe devices that expose poll queues, such as NVMe devices configured with nvme.poll_queues=. It is not a replacement for driver-native panic hooks.
Tested on a Jetson platform with an NVMe partition and nvme.poll_queues=4 by triggering panic via "echo c > /proc/sysrq-trigger"; after reboot the kmsg dump was recovered from /sys/fs/pstore/dmesg-pstore-blk-0 and from the raw partition.
--- Documentation/admin-guide/pstore-blk.rst | 33 +++ fs/pstore/blk.c | 322 ++++++++++++++++++++++- 2 files changed, 353 insertions(+), 2 deletions(-)
Documentation/admin-guide/pstore-blk.rst +33 -0
@@ -219,6 +219,39 @@ pstore/blk supports psblk_blkdev_info(), which is defined in *linux/pstore_blk.h*, to get information of using block device, such as the device number, sector count and start sector of the whole disk. +Panic writes in best-effort mode +-------------------------------- + +When ``best_effort=y`` is used with a suitable block device, pstore/blk can +register a ``panic_write`` callback for panic dmesg records. The callback +submits write BIOs with ``REQ_POLLED`` and polls them with ``bio_poll()`` so +that pstore/blk does not depend on normal completion interrupts for the panic +record. + +The block device must support all of the following when pstore/blk registers: + +1. polled hardware queues (``BLK_FEAT_POLL`` with ``HCTX_TYPE_POLL`` queues), +#. nowait bio submission, and +#. FUA writes if the device write cache is enabled. + +If any requirement is missing, pstore/blk still attaches in best-effort mode +but leaves ``panic_write`` disabled. The boot log reports whether the panic +writer was enabled, for example:: + + pstore_blk: attached /dev/nvme0n1p3 (...) (panic_write enabled) + +or:: + + pstore_blk: '/dev/nvme0n1p3' cannot use polled panic writes: missing polled hardware queues + pstore_blk: attached /dev/nvme0n1p3 (...) (no dedicated panic_write!) + +Some drivers create poll queues only when requested by a module parameter or +kernel command-line option, such as ``nvme.poll_queues=`` for NVMe. + +The panic writer uses ``REQ_FUA`` for the data write. It does not use +``REQ_PREFLUSH`` because flush requests do not provide a poll cookie that can +be waited on with ``bio_poll()`` from the panic path. + pstore block internals ----------------------
fs/pstore/blk.c +320 -2
352 lines not on this page · raw message
Signature · 1 line
2.43.0