__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>hwpoison — The Linux Kernel documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=3918102e" />
<script src="../_static/documentation_options.js?v=5929fcd5"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Hugetlbfs Reservation" href="hugetlbfs_reserv.html" />
<link rel="prev" title="Heterogeneous Memory Management (HMM)" href="hmm.html" />
<link rel="stylesheet" href="../_static/custom.css" type="text/css" />
</head><body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/logo.svg" alt="Logo of The Linux Kernel"/>
</a></p>
<h1 class="logo"><a href="../index.html">The Linux Kernel</a></h1>
<p class="blurb">6.18.50</p>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
<p>
<h3 class="kernel-toc-contents">Contents</h3>
<input type="checkbox" class="kernel-toc-toggle" id = "kernel-toc-toggle" checked>
<label class="kernel-toc-title" for="kernel-toc-toggle"></label>
<div class="kerneltoc" id="kerneltoc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../process/development-process.html">Development process</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/submitting-patches.html">Submitting patches</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/code-of-conduct.html">Code of conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="../maintainer/index.html">Maintainer handbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/index.html">All development-process docs</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../core-api/index.html">Core API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../driver-api/index.html">Driver APIs</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../subsystem-apis.html">Subsystems</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="../subsystem-apis.html#core-subsystems">Core subsystems</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../core-api/index.html">Core API Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../driver-api/index.html">Driver implementer’s API guide</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="index.html">Memory Management Documentation</a></li>
<li class="toctree-l3"><a class="reference internal" href="../power/index.html">Power Management</a></li>
<li class="toctree-l3"><a class="reference internal" href="../scheduler/index.html">Scheduler</a></li>
<li class="toctree-l3"><a class="reference internal" href="../timers/index.html">Timers</a></li>
<li class="toctree-l3"><a class="reference internal" href="../locking/index.html">Locking</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#human-interfaces">Human interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#networking-interfaces">Networking interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#storage-interfaces">Storage interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#other-subsystems">Other subsystems</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../locking/index.html">Locking</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../process/license-rules.html">Licensing rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../doc-guide/index.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev-tools/index.html">Development tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev-tools/testing-overview.html">Testing guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../kernel-hacking/index.html">Hacking guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../trace/index.html">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fault-injection/index.html">Fault injection</a></li>
<li class="toctree-l1"><a class="reference internal" href="../livepatch/index.html">Livepatching</a></li>
<li class="toctree-l1"><a class="reference internal" href="../rust/index.html">Rust</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../admin-guide/index.html">Administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../kbuild/index.html">Build system</a></li>
<li class="toctree-l1"><a class="reference internal" href="../admin-guide/reporting-issues.html">Reporting issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Userspace tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../userspace-api/index.html">Userspace API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../firmware-guide/index.html">Firmware</a></li>
<li class="toctree-l1"><a class="reference internal" href="../devicetree/index.html">Firmware and Devicetree</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../arch/index.html">CPU architectures</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../staging/index.html">Unsorted documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../translations/index.html">Translations</a></li>
</ul>
</div>
<script type="text/javascript"> <!--
var sbar = document.getElementsByClassName("sphinxsidebar")[0];
let currents = document.getElementsByClassName("current")
if (currents.length) {
sbar.scrollTop = currents[currents.length - 1].offsetTop;
}
--> </script>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/mm/hwpoison.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="language-selection">
English
<ul>
<li><a href="../translations/zh_CN/mm/hwpoison.html">Chinese (Simplified)</a></li>
</ul>
</div>
<section id="hwpoison">
<h1>hwpoison<a class="headerlink" href="#hwpoison" title="Link to this heading">¶</a></h1>
<section id="what-is-hwpoison">
<h2>What is hwpoison?<a class="headerlink" href="#what-is-hwpoison" title="Link to this heading">¶</a></h2>
<p>Upcoming Intel CPUs have support for recovering from some memory errors
(<code class="docutils literal notranslate"><span class="pre">MCA</span> <span class="pre">recovery</span></code>). This requires the OS to declare a page “poisoned”,
kill the processes associated with it and avoid using it in the future.</p>
<p>This patchkit implements the necessary infrastructure in the VM.</p>
<p>To quote the overview comment:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>High 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.
</pre></div>
</div>
<p>The 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.</p>
<p>The main target right now is KVM guests, but it works for all kinds
of applications. KVM support requires a recent qemu-kvm release.</p>
<p>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.</p>
</section>
<section id="failure-recovery-modes">
<h2>Failure recovery modes<a class="headerlink" href="#failure-recovery-modes" title="Link to this heading">¶</a></h2>
<p>There are two (actually three) modes memory failure recovery can be in:</p>
<dl class="simple">
<dt>vm.memory_failure_recovery sysctl set to zero:</dt><dd><p>All memory failures cause a panic. Do not attempt recovery.</p>
</dd>
<dt>early kill</dt><dd><p>(can be controlled globally and per process)
Send SIGBUS to the application as soon as the error is detected
This allows applications who can process memory errors in a gentle
way (e.g. drop affected object)
This is the mode used by KVM qemu.</p>
</dd>
<dt>late kill</dt><dd><p>Send SIGBUS when the application runs into the corrupted page.
This is best for memory error unaware applications and default
Note some pages are always handled as late kill.</p>
</dd>
</dl>
</section>
<section id="user-control">
<h2>User control<a class="headerlink" href="#user-control" title="Link to this heading">¶</a></h2>
<dl>
<dt>vm.memory_failure_recovery</dt><dd><p>See sysctl.txt</p>
</dd>
<dt>vm.memory_failure_early_kill</dt><dd><p>Enable early kill mode globally</p>
</dd>
<dt>PR_MCE_KILL</dt><dd><p>Set early/late kill mode/revert to system default</p>
<dl>
<dt>arg1: PR_MCE_KILL_CLEAR:</dt><dd><p>Revert to system default</p>
</dd>
<dt>arg1: PR_MCE_KILL_SET:</dt><dd><p>arg2 defines thread specific mode</p>
<dl class="simple">
<dt>PR_MCE_KILL_EARLY:</dt><dd><p>Early kill</p>
</dd>
<dt>PR_MCE_KILL_LATE:</dt><dd><p>Late kill</p>
</dd>
<dt>PR_MCE_KILL_DEFAULT</dt><dd><p>Use system global default</p>
</dd>
</dl>
</dd>
</dl>
<p>Note that if you want to have a dedicated thread which handles
the SIGBUS(BUS_MCEERR_AO) on behalf of the process, you should
call prctl(PR_MCE_KILL_EARLY) on the designated thread. Otherwise,
the SIGBUS is sent to the main thread.</p>
</dd>
<dt>PR_MCE_KILL_GET</dt><dd><p>return current mode</p>
</dd>
</dl>
</section>
<section id="testing">
<h2>Testing<a class="headerlink" href="#testing" title="Link to this heading">¶</a></h2>
<ul>
<li><p>madvise(MADV_HWPOISON, ....) (as root) - Poison a page in the
process for testing</p></li>
<li><p>hwpoison-inject module through debugfs <code class="docutils literal notranslate"><span class="pre">/sys/kernel/debug/hwpoison/</span></code></p>
<dl class="simple">
<dt>corrupt-pfn</dt><dd><p>Inject hwpoison fault at PFN echoed into this file. This does
some early filtering to avoid corrupted unintended pages in test suites.</p>
</dd>
<dt>unpoison-pfn</dt><dd><p>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.</p>
</dd>
</dl>
<p>Note these injection interfaces are not stable and might change between
kernel versions</p>
<dl>
<dt>corrupt-filter-dev-major, corrupt-filter-dev-minor</dt><dd><p>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.</p>
</dd>
<dt>corrupt-filter-memcg</dt><dd><p>Limit injection to pages owned by memgroup. Specified by inode
number of the memcg.</p>
<p>Example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>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
</pre></div>
</div>
</dd>
<dt>corrupt-filter-flags-mask, corrupt-filter-flags-value</dt><dd><p>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 <a class="reference internal" href="../admin-guide/mm/pagemap.html"><span class="doc">Examining Process Page Tables</span></a></p>
</dd>
</dl>
</li>
<li><p>Architecture specific MCE injector</p>
<p>x86 has mce-inject, mce-test</p>
<p>Some portable hwpoison test programs in mce-test, see below.</p>
</li>
</ul>
</section>
<section id="references">
<h2>References<a class="headerlink" href="#references" title="Link to this heading">¶</a></h2>
<dl class="simple">
<dt><a class="reference external" href="http://halobates.de/mce-lc09-2.pdf">http://halobates.de/mce-lc09-2.pdf</a></dt><dd><p>Overview presentation from LinuxCon 09</p>
</dd>
<dt>git://git.kernel.org/pub/scm/utils/cpu/mce/mce-test.git</dt><dd><p>Test suite (hwpoison specific portable tests in tsrc)</p>
</dd>
<dt>git://git.kernel.org/pub/scm/utils/cpu/mce/mce-inject.git</dt><dd><p>x86 specific injector</p>
</dd>
</dl>
</section>
<section id="limitations">
<h2>Limitations<a class="headerlink" href="#limitations" title="Link to this heading">¶</a></h2>
<ul class="simple">
<li><p>Not all page types are supported and never will. Most kernel internal
objects cannot be recovered, only LRU pages for now.</p></li>
</ul>
<p>---
Andi Kleen, Oct 2009</p>
</section>
</section>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©The kernel development community.
|
Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
& <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
|
<a href="../_sources/mm/hwpoison.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| damon | Folder | 0755 |
|
|
| active_mm.html | File | 12.8 KB | 0644 |
|
| allocation-profiling.html | File | 13.65 KB | 0644 |
|
| arch_pgtable_helpers.html | File | 20.2 KB | 0644 |
|
| balance.html | File | 14.36 KB | 0644 |
|
| bootmem.html | File | 8 KB | 0644 |
|
| free_page_reporting.html | File | 10.17 KB | 0644 |
|
| highmem.html | File | 75.38 KB | 0644 |
|
| hmm.html | File | 40.36 KB | 0644 |
|
| hugetlbfs_reserv.html | File | 47.17 KB | 0644 |
|
| hwpoison.html | File | 15.86 KB | 0644 |
|
| index.html | File | 13.59 KB | 0644 |
|
| ksm.html | File | 17.68 KB | 0644 |
|
| memory-model.html | File | 21.35 KB | 0644 |
|
| mmu_notifier.html | File | 13.02 KB | 0644 |
|
| multigen_lru.html | File | 25.56 KB | 0644 |
|
| numa.html | File | 17.7 KB | 0644 |
|
| oom.html | File | 8.02 KB | 0644 |
|
| overcommit-accounting.html | File | 12.24 KB | 0644 |
|
| page_allocation.html | File | 8.03 KB | 0644 |
|
| page_cache.html | File | 8.4 KB | 0644 |
|
| page_frags.html | File | 10.44 KB | 0644 |
|
| page_migration.html | File | 22.8 KB | 0644 |
|
| page_owner.html | File | 19.73 KB | 0644 |
|
| page_reclaim.html | File | 7.99 KB | 0644 |
|
| page_table_check.html | File | 12.38 KB | 0644 |
|
| page_tables.html | File | 25.13 KB | 0644 |
|
| physical_memory.html | File | 58.06 KB | 0644 |
|
| process_addrs.html | File | 75.38 KB | 0644 |
|
| remap_file_pages.html | File | 10.2 KB | 0644 |
|
| shmfs.html | File | 8.03 KB | 0644 |
|
| slab.html | File | 14.86 KB | 0644 |
|
| split_page_table_lock.html | File | 14.96 KB | 0644 |
|
| swap-table.html | File | 10.67 KB | 0644 |
|
| swap.html | File | 7.95 KB | 0644 |
|
| transhuge.html | File | 19.52 KB | 0644 |
|
| unevictable-lru.html | File | 56.55 KB | 0644 |
|
| vmalloc.html | File | 8.09 KB | 0644 |
|
| vmalloced-kernel-stacks.html | File | 17.72 KB | 0644 |
|
| vmemmap_dedup.html | File | 23.59 KB | 0644 |
|
| zsmalloc.html | File | 34.19 KB | 0644 |
|