1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ramoops oops/panic logger

Posted at

Ramoops oops/panic logger
Sergiu Iordache

Updated: 17 November 2011

Introduction

Ramoops is an oops/panic logger that writes its logs to RAM before the system crashes. It works by logging oopses and panics in a circular buffer. Ramoops needs a system with persistent RAM so that the content of that area can survive after a restart.

Ramoopsは、oops/panic loggerです。system crashする前にログをRAMに書き込むことができます。これは、oopsesやpanisをcircular buffer(訳注: リングバッファ)で記録します。Ramoopsには再起動後にもその領域のコンテンツが参照できるように、永続的なRAMを備えたシステムが必要です。

Ramoops concepts

Ramoops uses a predefined memory area to store the dump. The start and size and type of the memory area are set using three variables:

Ramoopsはdumpを記録するために事前に定義されたmemory areaを利用します。メモリの開始位置、サイズ、タイプを設定するのに3つの変数を用います。

  • mem_address for the start
  • mem_size for the size. The memory size will be rounded down to a power of two.

  • mem_type to specifiy if the memory type (default is pgprot_writecombine).

  • mem_address メモリの開始位置

  • mem_size メモリのサイズ。メモリサイズは2のべき乗で切り捨てられます。

  • mem_type メモリタイプを表現する(デフォルトはpgprot_writecombine)

Typically the default value of mem_type=0 should be used as that sets the pstore mapping to pgprot_writecombine. Setting mem_type=1 attempts to use pgprot_noncached, which only works on some platforms. This is because pstore depends on atomic operations. At least on ARM, pgprot_noncached causes the memory to be mapped strongly ordered, and atomic operations on strongly ordered memory are implementation defined, and won’t work on many ARMs such as omaps.

通常、mem_type=0のデフォルトの値が、psore mappingをpgprot_writecombineに設定するために用いられます。mem_type=1を設定する事で、pgprot_noncacheが試しに用いられますが、これは一部のシステムでしか使えません。これは、pstoreはatomic operationが要求されるからです。少なくともARMでは、pgprot_noncachedによってメモリがstrong orderedでmappingされ、strong ordered memoryのatomic操作は実装定義であり、omapsなどの多くのARMでは機能しません。

The memory area is divided into record_size chunks (also rounded down to power of two) and each oops/panic writes a record_size chunk of information.

メモリ領域はrecord_size chunksに分割され(これも2の累乗に切り捨てられます)、各oops/panicは情報のrecord_size chunksを書き込みます。

Dumping both oopses and panics can be done by setting 1 in the dump_oops variable while setting 0 in that variable dumps only the panics.

oopsesとpanicsをdumpするためには、dump_oops変数を1に設定してください。その変数に0を設定すると、panicsのみなります。

The module uses a counter to record multiple dumps but the counter gets reset on restart (i.e. new dumps after the restart will overwrite old ones).

moduleは複数のdumpを記録しますが、再起動した後counterはリセットされます(つまり、再起動後には古いダンプを新しいダンプが上書きします)。

Ramoops also supports software ECC protection of persistent memory regions. This might be useful when a hardware reset was used to bring the machine back to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat corrupt, but usually it is restorable.

Ramoopsはまた永続メモリ領域のsoftware ECC protectionをサポートしています。これは、ハードウェアリセットを利用してマシンをもとの状態に戻した場合に役立ちます(つまり、watchdog が発生した)。このようなケースでは、RAMが多少破損している場合もありますが、通常は復旧可能です。

Setting the parameters

Setting the ramoops parameters can be done in several different manners:

ramoops parameterを設定するには、いくつかの方法を用いる事ができます。

A. Use the module parameters (which have the names of the variables described as before). For quick debugging, you can also reserve parts of memory during boot and then use the reserved memory for ramoops. For example, assuming a machine with > 128 MB of memory, the following kernel command line will tell the kernel to use only the first 128 MB of memory, and place ECC-protected ramoops region at 128 MB boundary:

A. module parameterを用いる方法(前述した変数の名前を用います)。簡単にdebugするために、起動時にメモリの一部を予約し、ramoopsに予約されたメモリを用いることができます。例えば、machineが128MBのメモリを備えているならば、kernel command lineでは最初の128MBのmemoryだけを用いるように指示できます。そして、ECC protectedに128MB boundaryでramoops regionを配置するように、カーネルに指示をします。

mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1

B. Use Device Tree bindings, as described in Documentation/devicetree/bindings/reserved-memory/ramoops.txt. For example:

B. Device Tree bindingを使う方法、これは、 Documentation/devicetree/bindings/reserved-memory/ramoops.txt.に記載があります。例えば:

reserved-memory {
        #address-cells = <2>;
        #size-cells = <2>;
        ranges;

        ramoops@8f000000 {
                compatible = "ramoops";
                reg = <0 0x8f000000 0 0x100000>;
                record-size = <0x4000>;
                console-size = <0x4000>;
        };
};

C. Use a platform device and set the platform data. The parameters can then be set through that platform data. An example of doing that is:

C. platform deviceを用いて、platform dataを設定する方法。parametersは、その platform dataを介して設定できます。 これを行う例は次のとおりです。


# include <linux/pstore_ram.h>
[...]

static struct ramoops_platform_data ramoops_data = {
      .mem_size               = <...>,
      .mem_address            = <...>,
      .mem_type               = <...>,
      .record_size            = <...>,
      .dump_oops              = <...>,
      .ecc                    = <...>,
};

static struct platform_device ramoops_dev = {
      .name = "ramoops",
      .dev = {
              .platform_data = &ramoops_data,
      },
};

[... inside a function ...]
int ret;

ret = platform_device_register(&ramoops_dev);
if (ret) {
      printk(KERN_ERR "unable to register platform device\n");
      return ret;
}

You can specify either RAM memory or peripheral devices’ memory. However, when specifying RAM, be sure to reserve the memory by issuing memblock_reserve() very early in the architecture code, e.g.:

RAMメモリまたはperipheral deviceのメモリを指定できます。 ただし、RAMを指定する場合は、architecture codeの非常に早い段階でmemblock_reserve)を発行してメモリを予約してください。

# include <linux/memblock.h>

memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);

Dump format

The data dump begins with a header, currently defined as ==== followed by a timestamp and a new line. The dump then continues with the actual data.

data dumpは、===として定義されているヘッダーで始まります。タイムスタンプと改行が続きます。 その後、dumpは実際のdataが続きます。

Reading the data

The dump data can be read from the pstore filesystem. The format for these files is dmesg-ramoops-N, where N is the record number in memory. To delete a stored record from RAM, simply unlink the respective pstore file.

dump dataは、pstore filesystemから読み出す事ができます。このファイルのフォーマットは、dmesg-ramoops-Nです。Nはmemory上のrecode numberになります。RAMから保持されたrecodeを削除するためには、単純には関連するpstore fileを削除してください。

Persistent function tracing

Persistent function tracing might be useful for debugging software or hardware related hangs. The functions call chain log is stored in a ftrace-ramoops file. Here is an example of usage:

永続的な関数tracingは、hangに関連したsoftwareやhardwareのdebuggingに有効です。functions call chain logは、ftrace-ramoops fileに記録されます。その実例を示します。

# mount -t debugfs debugfs /sys/kernel/debug/
# echo 1 > /sys/kernel/debug/pstore/record_ftrace
# reboot -f
[...]
# mount -t pstore pstore /mnt/
# tail /mnt/ftrace-ramoops
0 ffffffff8101ea64  ffffffff8101bcda  native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
0 ffffffff8101ea44  ffffffff8101bcf6  native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
0 ffffffff81020084  ffffffff8101a4b5  hpet_disable <- native_machine_shutdown+0x75/0x90
0 ffffffff81005f94  ffffffff8101a4bb  iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
0 ffffffff8101a6a1  ffffffff8101a437  native_machine_emergency_restart <- native_machine_restart+0x37/0x40
0 ffffffff811f9876  ffffffff8101a73a  acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
0 ffffffff8101a514  ffffffff8101a772  mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
0 ffffffff811d9c54  ffffffff8101a7a0  __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
0 ffffffff811d9c34  ffffffff811d9c80  __delay <- __const_udelay+0x30/0x40
0 ffffffff811d9d14  ffffffff811d9c3f  delay_tsc <- __delay+0xf/0x20

もともと、Linux Kernelのソースコードの一部なので、GPLv2扱いになる(はずの認識)。

https://www.kernel.org/doc/html/latest/index.html

Licensing documentation

The following describes the license of the Linux kernel source code (GPLv2), how to properly mark the license of individual files in the source tree, as well as links to the full license text.

https://www.kernel.org/doc/html/latest/process/license-rules.html#kernel-licensing

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?