Code Monkey home page Code Monkey logo

mcelog's Introduction

mcelog

mcelog is the user space backend for logging machine check errors reported by the hardware to the kernel. The kernel does the immediate actions (like killing processes etc.) and mcelog decodes the errors and manages various other advanced error responses like offlining memory, CPUs or triggering events. In addition mcelog also handles corrected errors, by logging and accounting them. It primarily handles machine checks and thermal events, which are reported for errors detected by the CPU.

For more details on what mcelog can do and the underlying theory see mcelog.org.

It is recommended that mcelog runs on all x86 machines, both 64bit (since early 2.6) and 32bit (since 2.6.32).

mcelog can run in several modes:

  • cronjob
  • trigger
  • daemon

cronjob is the old method. mcelog runs every 5 minutes from cron and checks for errors. Disadvantage of this is that it can delay error reporting significantly (upto 10 minutes) and does not allow mcelog to keep extended state.

trigger is a newer method where the kernel runs mcelog on a error.

This is configured with:

echo /usr/sbin/mcelog > /sys/devices/system/machinecheck/machinecheck0/trigger

This is faster, but still doesn't allow mcelog to keep state, and has relatively high overhead for each error because a program has to be initialized from scratch.

In daemon mode mcelog runs continuously as a daemon in the background and wait for errors. It is enabled by running mcelog --daemon & from a init script. This is the fastest and most feature-ful.

The recommended mode is daemon, because several new functions (like page error predictive failure analysis) require a continuously running daemon.

Documentation

  • The primary reference documentation are the man pages.
  • lk10-mcelog.pdf has a overview over the errors mcelog handles (originally from Linux Kongress 2010).
  • mce.pdf is a very old paper describing the first releases of mcelog (some parts are obsolete).

For distributors

You can run mcelog from systemd or similar daemons. An example systemd unit file is in mcelog.service.

By default mcelog reports its version as the git tag. This can be overridden by setting up a .os_version file in the source directory. A build system could write the OS version to this file to mark the binary.

For older distributions using init scripts

Please install an init script by default that runs mcelog in daemon mode. The mcelog.init script is a good starting point. Also install a logrotated file (mcelog.logrotate) or equivalent when mcelog is running in daemon mode. These two are not in make install.

The installation also requires a config file /etc/mcelog.conf and the default triggers. These are all installed by make install

/dev/mcelog is needed for mcelog operation. If it's not there it can be created with:

mknod /dev/mcelog c 10 227

Normally it should be created automatically in udev.

Security

mcelog needs to run as root because it might trigger actions like page-offlining, which require CAP_SYS_ADMIN. Also it opens /dev/mcelog and an UNIX socket for client support.

It also opens /dev/mem to parse the BIOS DMI tables. It is careful to close the file descriptor and unmap any mappings after using them.

There is support for changing the user in daemon mode after opening the device and the sockets, but that would stop triggers from doing corrective action that require root.

In principle it would be possible to only keep CAP_SYS_ADMIN for page-offling, but that would prevent triggers from doing root-only actions not covered by it (and CAP_SYS_ADMIN is not that different from full root)

In daemon mode mcelog listens to a UNIX socket and processes requests from sh mcelog --client. This can be disabled in the configuration file. The uid/gid of the requestor is checked on access and is configurable (default 0/0 only). The command parsing code is very straight forward (server.c). The client parsing/reply is currently done with full privileges of the daemon.

Testing

There is a simple test suite in sh tests/. The test suite requires root to run and access to mce-inject and a kernel with MCE injection support CONFIG_X86_MCE_INJECT. It will kill any running mcelog daemon.

Run it with sh make test.

The test suite requires the mce-inject tool. The mce-inject executable must be either in $PATH or in the ../mce-inject directory.

You can also test under valgrind with sh make valgrind-test. For this valgrind needs to be installed of course. Advanced valgrind options can be specified with:

make VALGRIND="valgrind --option" valgrind-test

Other checks

make iccverify and make clangverify run the static verifiers in clang and icc respectively.

License

This program is licensed under the subject of the GNU Public General License, v.2

mcelog's People

Contributors

aegl avatar andikleen avatar prarit avatar paulmenzel avatar wrar avatar yhuang-intel avatar qzhuo2 avatar ruiwang1 avatar watologo1 avatar baruch avatar bldewolf avatar larrybaker avatar youquan-song avatar srilakshmidj avatar zoucao-ali avatar robinmholt avatar rworkman avatar jonmasters avatar jiridluhosrh avatar benkohler avatar pokab avatar splbio avatar yangzz-97 avatar hygonsoc avatar huangxiaodui avatar vincele avatar feandil avatar sderr avatar sikarash avatar pioy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.