ramoops.txt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. Ramoops oops/panic logger
  2. =========================
  3. Sergiu Iordache <sergiu@chromium.org>
  4. Updated: 17 November 2011
  5. 0. Introduction
  6. Ramoops is an oops/panic logger that writes its logs to RAM before the system
  7. crashes. It works by logging oopses and panics in a circular buffer. Ramoops
  8. needs a system with persistent RAM so that the content of that area can
  9. survive after a restart.
  10. 1. Ramoops concepts
  11. Ramoops uses a predefined memory area to store the dump. The start and size
  12. and type of the memory area are set using three variables:
  13. * "mem_address" for the start
  14. * "mem_size" for the size. The memory size will be rounded down to a
  15. power of two.
  16. * "mem_type" to specifiy if the memory type (default is pgprot_writecombine).
  17. Typically the default value of mem_type=0 should be used as that sets the pstore
  18. mapping to pgprot_writecombine. Setting mem_type=1 attempts to use
  19. pgprot_noncached, which only works on some platforms. This is because pstore
  20. depends on atomic operations. At least on ARM, pgprot_noncached causes the
  21. memory to be mapped strongly ordered, and atomic operations on strongly ordered
  22. memory are implementation defined, and won't work on many ARMs such as omaps.
  23. The memory area is divided into "record_size" chunks (also rounded down to
  24. power of two) and each oops/panic writes a "record_size" chunk of
  25. information.
  26. Dumping both oopses and panics can be done by setting 1 in the "dump_oops"
  27. variable while setting 0 in that variable dumps only the panics.
  28. The module uses a counter to record multiple dumps but the counter gets reset
  29. on restart (i.e. new dumps after the restart will overwrite old ones).
  30. Ramoops also supports software ECC protection of persistent memory regions.
  31. This might be useful when a hardware reset was used to bring the machine back
  32. to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat
  33. corrupt, but usually it is restorable.
  34. 2. Setting the parameters
  35. Setting the ramoops parameters can be done in 2 different manners:
  36. 1. Use the module parameters (which have the names of the variables described
  37. as before).
  38. For quick debugging, you can also reserve parts of memory during boot
  39. and then use the reserved memory for ramoops. For example, assuming a machine
  40. with > 128 MB of memory, the following kernel command line will tell the
  41. kernel to use only the first 128 MB of memory, and place ECC-protected ramoops
  42. region at 128 MB boundary:
  43. "mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1"
  44. 2. Use a platform device and set the platform data. The parameters can then
  45. be set through that platform data. An example of doing that is:
  46. #include <linux/pstore_ram.h>
  47. [...]
  48. static struct ramoops_platform_data ramoops_data = {
  49. .mem_size = <...>,
  50. .mem_address = <...>,
  51. .mem_type = <...>,
  52. .record_size = <...>,
  53. .dump_oops = <...>,
  54. .ecc = <...>,
  55. };
  56. static struct platform_device ramoops_dev = {
  57. .name = "ramoops",
  58. .dev = {
  59. .platform_data = &ramoops_data,
  60. },
  61. };
  62. [... inside a function ...]
  63. int ret;
  64. ret = platform_device_register(&ramoops_dev);
  65. if (ret) {
  66. printk(KERN_ERR "unable to register platform device\n");
  67. return ret;
  68. }
  69. You can specify either RAM memory or peripheral devices' memory. However, when
  70. specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
  71. very early in the architecture code, e.g.:
  72. #include <linux/memblock.h>
  73. memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
  74. 3. Dump format
  75. The data dump begins with a header, currently defined as "====" followed by a
  76. timestamp and a new line. The dump then continues with the actual data.
  77. 4. Reading the data
  78. The dump data can be read from the pstore filesystem. The format for these
  79. files is "dmesg-ramoops-N", where N is the record number in memory. To delete
  80. a stored record from RAM, simply unlink the respective pstore file.
  81. 5. Persistent function tracing
  82. Persistent function tracing might be useful for debugging software or hardware
  83. related hangs. The functions call chain log is stored in a "ftrace-ramoops"
  84. file. Here is an example of usage:
  85. # mount -t debugfs debugfs /sys/kernel/debug/
  86. # echo 1 > /sys/kernel/debug/pstore/record_ftrace
  87. # reboot -f
  88. [...]
  89. # mount -t pstore pstore /mnt/
  90. # tail /mnt/ftrace-ramoops
  91. 0 ffffffff8101ea64 ffffffff8101bcda native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
  92. 0 ffffffff8101ea44 ffffffff8101bcf6 native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
  93. 0 ffffffff81020084 ffffffff8101a4b5 hpet_disable <- native_machine_shutdown+0x75/0x90
  94. 0 ffffffff81005f94 ffffffff8101a4bb iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
  95. 0 ffffffff8101a6a1 ffffffff8101a437 native_machine_emergency_restart <- native_machine_restart+0x37/0x40
  96. 0 ffffffff811f9876 ffffffff8101a73a acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
  97. 0 ffffffff8101a514 ffffffff8101a772 mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
  98. 0 ffffffff811d9c54 ffffffff8101a7a0 __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
  99. 0 ffffffff811d9c34 ffffffff811d9c80 __delay <- __const_udelay+0x30/0x40
  100. 0 ffffffff811d9d14 ffffffff811d9c3f delay_tsc <- __delay+0xf/0x20