u~sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget/translations/zh_CN/mm/hwpoisonmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/zh_TW/mm/hwpoisonmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/it_IT/mm/hwpoisonmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/ja_JP/mm/hwpoisonmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/ko_KR/mm/hwpoisonmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget/translations/sp_SP/mm/hwpoisonmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hhwpoisonh]hhwpoison}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh9/var/lib/git/docbuild/linux/Documentation/mm/hwpoison.rsthKubh)}(hhh](h)}(hWhat is hwpoison?h]hWhat is hwpoison?}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hUpcoming Intel CPUs have support for recovering from some memory errors (``MCA recovery``). This requires the OS to declare a page "poisoned", kill the processes associated with it and avoid using it in the future.h](hIUpcoming Intel CPUs have support for recovering from some memory errors (}(hhhhhNhNubhliteral)}(h``MCA recovery``h]h MCA recovery}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhubh). This requires the OS to declare a page “poisoned”, kill the processes associated with it and avoid using it in the future.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h@This patchkit implements the necessary infrastructure in the VM.h]h@This patchkit implements the necessary infrastructure in the VM.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(hTo quote the overview comment::h]hTo quote the overview comment:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh literal_block)}(hXHigh level machine check handler. Handles pages reported by the hardware as being corrupted usually due to a 2bit ECC memory or cache failure. This focusses on pages detected as corrupted in the background. When the current CPU tries to consume corruption the currently running process can just be killed directly instead. This implies that if the error cannot be handled for some reason it's safe to just ignore it because no corruption has been consumed yet. Instead when that happens another machine check will happen. Handles page cache pages in various states. The tricky part here is that we can access any page asynchronous to other VM users, because memory failures could happen anytime and anywhere, possibly violating some of their assumptions. This is why this code has to be extremely careful. Generally it tries to use normal locking rules, as in get the standard locks, even if that means the error handling takes potentially a long time. Some of the operations here are somewhat inefficient and have non linear algorithmic complexity, because the data structures have not been optimized for this case. This is in particular the case for the mapping from a vma to a process. Since this case is expected to be rare we hope we can get away with this.h]hXHigh level machine check handler. Handles pages reported by the hardware as being corrupted usually due to a 2bit ECC memory or cache failure. This focusses on pages detected as corrupted in the background. When the current CPU tries to consume corruption the currently running process can just be killed directly instead. This implies that if the error cannot be handled for some reason it's safe to just ignore it because no corruption has been consumed yet. Instead when that happens another machine check will happen. Handles page cache pages in various states. The tricky part here is that we can access any page asynchronous to other VM users, because memory failures could happen anytime and anywhere, possibly violating some of their assumptions. This is why this code has to be extremely careful. Generally it tries to use normal locking rules, as in get the standard locks, even if that means the error handling takes potentially a long time. Some of the operations here are somewhat inefficient and have non linear algorithmic complexity, because the data structures have not been optimized for this case. This is in particular the case for the mapping from a vma to a process. Since this case is expected to be rare we hope we can get away with this.}hj sbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1jhhhKhhhhubh)}(hThe code consists of a the high level handler in mm/memory-failure.c, a new page poison bit and various checks in the VM to handle poisoned pages.h]hThe code consists of a the high level handler in mm/memory-failure.c, a new page poison bit and various checks in the VM to handle poisoned pages.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hhhhubh)}(hThe main target right now is KVM guests, but it works for all kinds of applications. KVM support requires a recent qemu-kvm release.h]hThe main target right now is KVM guests, but it works for all kinds of applications. KVM support requires a recent qemu-kvm release.}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hhhhubh)}(hX,For the KVM use there was need for a new signal type so that KVM can inject the machine check into the guest with the proper address. This in theory allows other applications to handle memory failures too. The expectation is that most applications won't do that, but some very specialized ones might.h]hX.For the KVM use there was need for a new signal type so that KVM can inject the machine check into the guest with the proper address. This in theory allows other applications to handle memory failures too. The expectation is that most applications won’t do that, but some very specialized ones might.}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK0hhhhubeh}(h]what-is-hwpoisonah ]h"]what is hwpoison?ah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hFailure recovery modesh]hFailure recovery modes}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjLhhhhhK7ubh)}(hGThere are two (actually three) modes memory failure recovery can be in:h]hGThere are two (actually three) modes memory failure recovery can be in:}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjLhhubhdefinition_list)}(hhh](hdefinition_list_item)}(hkvm.memory_failure_recovery sysctl set to zero: All memory failures cause a panic. Do not attempt recovery. h](hterm)}(h.vm.memory_failure_recovery sysctl set to zero:h]h.vm.memory_failure_recovery sysctl set to zero:}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1jvhhhK /sys/fs/cgroup/mem/hwpoison/tasks memcg_ino=$(ls -id /sys/fs/cgroup/mem/hwpoison | cut -f1 -d' ') echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg page-types -p `pidof init` --hwpoison # shall do nothing page-types -p `pidof usemem` --hwpoison # poison its pages corrupt-filter-flags-mask, corrupt-filter-flags-value When specified, only poison pages if ((page_flags & mask) == value). This allows stress testing of many kinds of pages. The page_flags are the same as in /proc/kpageflags. The flag bits are defined in include/linux/kernel-page-flags.h and documented in Documentation/admin-guide/mm/pagemap.rst h](h)}(hFhwpoison-inject module through debugfs ``/sys/kernel/debug/hwpoison/``h](h'hwpoison-inject module through debugfs }(hj.hhhNhNubh)}(h``/sys/kernel/debug/hwpoison/``h]h/sys/kernel/debug/hwpoison/}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj.ubeh}(h]h ]h"]h$]h&]uh1hhhhKphj*ubjl)}(hhh](jq)}(hcorrupt-pfn Inject hwpoison fault at PFN echoed into this file. This does some early filtering to avoid corrupted unintended pages in test suites. h](jw)}(h corrupt-pfnh]h corrupt-pfn}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1jvhhhKthjMubj)}(hhh]h)}(hInject hwpoison fault at PFN echoed into this file. This does some early filtering to avoid corrupted unintended pages in test suites.h]hInject hwpoison fault at PFN echoed into this file. This does some early filtering to avoid corrupted unintended pages in test suites.}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKshj_ubah}(h]h ]h"]h$]h&]uh1jhjMubeh}(h]h ]h"]h$]h&]uh1jphhhKthjJubjq)}(hunpoison-pfn Software-unpoison page at PFN echoed into this file. This way a page can be reused again. This only works for Linux injected failures, not for real memory failures. Once any hardware memory failure happens, this feature is disabled. h](jw)}(h unpoison-pfnh]h unpoison-pfn}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jvhhhKzhj|ubj)}(hhh]h)}(hSoftware-unpoison page at PFN echoed into this file. This way a page can be reused again. This only works for Linux injected failures, not for real memory failures. Once any hardware memory failure happens, this feature is disabled.h]hSoftware-unpoison page at PFN echoed into this file. This way a page can be reused again. This only works for Linux injected failures, not for real memory failures. Once any hardware memory failure happens, this feature is disabled.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhjubah}(h]h ]h"]h$]h&]uh1jhj|ubeh}(h]h ]h"]h$]h&]uh1jphhhKzhjJubeh}(h]h ]h"]h$]h&]uh1jkhj*ubh)}(hWNote these injection interfaces are not stable and might change between kernel versionsh]hWNote these injection interfaces are not stable and might change between kernel versions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK|hj*ubjl)}(hhh](jq)}(hcorrupt-filter-dev-major, corrupt-filter-dev-minor Only handle memory failures to pages associated with the file system defined by block device major/minor. -1U is the wildcard value. This should be only used for testing with artificial injection. h](jw)}(h2corrupt-filter-dev-major, corrupt-filter-dev-minorh]h2corrupt-filter-dev-major, corrupt-filter-dev-minor}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jvhhhKhjubj)}(hhh]h)}(hOnly handle memory failures to pages associated with the file system defined by block device major/minor. -1U is the wildcard value. This should be only used for testing with artificial injection.h]hOnly handle memory failures to pages associated with the file system defined by block device major/minor. -1U is the wildcard value. This should be only used for testing with artificial injection.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jphhhKhjubjq)}(hX corrupt-filter-memcg Limit injection to pages owned by memgroup. Specified by inode number of the memcg. Example:: mkdir /sys/fs/cgroup/mem/hwpoison usemem -m 100 -s 1000 & echo `jobs -p` > /sys/fs/cgroup/mem/hwpoison/tasks memcg_ino=$(ls -id /sys/fs/cgroup/mem/hwpoison | cut -f1 -d' ') echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg page-types -p `pidof init` --hwpoison # shall do nothing page-types -p `pidof usemem` --hwpoison # poison its pages h](jw)}(hcorrupt-filter-memcgh]hcorrupt-filter-memcg}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jvhhhKhjubj)}(hhh](h)}(hSLimit injection to pages owned by memgroup. Specified by inode number of the memcg.h]hSLimit injection to pages owned by memgroup. Specified by inode number of the memcg.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj )}(hX^mkdir /sys/fs/cgroup/mem/hwpoison usemem -m 100 -s 1000 & echo `jobs -p` > /sys/fs/cgroup/mem/hwpoison/tasks memcg_ino=$(ls -id /sys/fs/cgroup/mem/hwpoison | cut -f1 -d' ') echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg page-types -p `pidof init` --hwpoison # shall do nothing page-types -p `pidof usemem` --hwpoison # poison its pagesh]hX^mkdir /sys/fs/cgroup/mem/hwpoison usemem -m 100 -s 1000 & echo `jobs -p` > /sys/fs/cgroup/mem/hwpoison/tasks memcg_ino=$(ls -id /sys/fs/cgroup/mem/hwpoison | cut -f1 -d' ') echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg page-types -p `pidof init` --hwpoison # shall do nothing page-types -p `pidof usemem` --hwpoison # poison its pages}hj"sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jphhhKhjubjq)}(hX]corrupt-filter-flags-mask, corrupt-filter-flags-value When specified, only poison pages if ((page_flags & mask) == value). This allows stress testing of many kinds of pages. The page_flags are the same as in /proc/kpageflags. The flag bits are defined in include/linux/kernel-page-flags.h and documented in Documentation/admin-guide/mm/pagemap.rst h](jw)}(h5corrupt-filter-flags-mask, corrupt-filter-flags-valueh]h5corrupt-filter-flags-mask, corrupt-filter-flags-value}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1jvhhhKhj<ubj)}(hhh]h)}(hX&When specified, only poison pages if ((page_flags & mask) == value). This allows stress testing of many kinds of pages. The page_flags are the same as in /proc/kpageflags. The flag bits are defined in include/linux/kernel-page-flags.h and documented in Documentation/admin-guide/mm/pagemap.rsth]hX&When specified, only poison pages if ((page_flags & mask) == value). This allows stress testing of many kinds of pages. The page_flags are the same as in /proc/kpageflags. The flag bits are defined in include/linux/kernel-page-flags.h and documented in Documentation/admin-guide/mm/pagemap.rst}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjNubah}(h]h ]h"]h$]h&]uh1jhj<ubeh}(h]h ]h"]h$]h&]uh1jphhhKhjubeh}(h]h ]h"]h$]h&]uh1jkhj*ubeh}(h]h ]h"]h$]h&]uh1jhj hhhNhNubj)}(hArchitecture specific MCE injector x86 has mce-inject, mce-test Some portable hwpoison test programs in mce-test, see below. h](h)}(h"Architecture specific MCE injectorh]h"Architecture specific MCE injector}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubh)}(hx86 has mce-inject, mce-testh]hx86 has mce-inject, mce-test}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjwubh)}(h