Skip to content
Jakub Filak edited this page Aug 28, 2015 · 8 revisions

pstore

  • pstore is a file system for platform specific storage
  • every file in /sys/fs/pstore is a single record in the platform specific storage
  • pstore implements Bridge Pattern (pstore is abstraction, efi is implementation)
  • when a new pstore provider is being registered, a new kmsg_dumper, which dumps to the pstore, is created and registered through kmsg_dump_register()
  • the pstore kmsg_dumper uses kmsg_dump_get_buffer() to get next written part
  • only last 8KiB of kmsg buffer is dumped to pstore by default (last because kmsg_dump_get_buffer() reads the buffer from the end)
- known pstores:
  • efi - UEFI NVRAM
  • nvram - PPC NVRAM
  • erst - APEI ERST - ACPI v4.0
  • ramoops - built-in driver for storing in persistent RAM

pstore file names

Inodes for pstore records are created in fs/pstore/inode.c : pstore_mkfile(). The second argument (%s) of the pritnf format is pstore name (efi, nvram, erst, ramoops):
* PSTORE_TYPE_DMESG
  • "dmesg-%s-%lld%s"
  • kmsg_dump - oops/panic/..
  • automatically turned on when a pstore is being registered
* PSTORE_TYPE_CONSOLE
  • "console-%s-%lld"
  • saved messages of printk() - register_console()
  • can be turned on through kernel command line arguments
* PSTORE_TYPE_FTRACE
  • "ftrace-%s-%lld"
  • data from /sys/kernel/debug/pstore/record_ftrace
  • debugfs_create_dir(); debugfs_create_file()
  • can be turned on through kernel command line arguments
* PSTORE_TYPE_PMSG
  • "pmsg-%s-%lld"
  • data received from /dev/pmsg
  • register_chrdev(0, "pmsg", ...)
  • can be turned on through kernel command line arguments
* PSTORE_TYPE_MCE
  • "mce-%s-%lld"
  • apei_write_mce() -> "Fatal MCE"
* PSTORE_TYPE_UNKNOWN
  • "unknown-%s-%lld"
  • erst supports only DMESG and MCE, the other types are converted to UNKNOWN when reading stored data
* PSTORE_TYPE_PPC_RTAS
  • "rtas-%s-%lld"
  • only the pstore "nvram"
* PSTORE_TYPE_PPC_OF
  • "powerpc-ofw-%s-%lld"
  • only the pstore "nvram"
* PSTORE_TYPE_PPC_COMMON
  • "powerpc-common-%s-%lld"
  • only the pstore "nvram"
* PSTORE_TYPE_PPC_OPAL
  • "powerpc-opal-%s-%lld"
  • only the pstore "nvram"
* default:
  • "type%d-%s-%lld"

PSTORE_TYPE_DMESG file format

The first file line is created according to this template "$dump_reason#$dump_number 'Part'#$part_number".

Here are the dump reasons are specified in `fs/pstore/platform.c: get_reason_str()`:
  • Panic
  • Oops
  • Emergency
  • Restart
  • Halt
  • Poweroff
  • Unknown

The part number is descending, so "Part#1" is the last 1KiB of the kmsg buffer.

efi-pstore

  • files in pstore that represents UEFI NVRAM variables start with "[^-]*-efi-"
  • when firmware driver for efi is loaded, the driver registers itself as "pstore provider"
  • every write to efi pstore creates a new efi var of 1KiB of size, so each dmesg-efi-* file contains a single part the kmsg buffer

ABRT

ABRT is capable of detecting and reporting Kernel oopses in pstore ("dmesg-*" files). At first step the kmsg buffer is reconstructed - the files are joined in descending order - and then ABRT processes the buffer as a regular dmesg file (abrt-dump-oops).

/usr/bin/abrt-merge-pstoreoops

reconstructs the kmsg buffer from pstore files

/usr/sbin/abrt-harvest-pstoreoops

runs abrt-merge-pstoreoops and passes its output to abrt-dump-oops

/usr/lib/systemd/system/abrt-pstoreoops.service

runs abrt-harvest-pstoreoops at system start-up

If you want to play with the implementation but you do not have any pstore file, you can use these example files from the ABRT testsuite (pstore-harvest):