~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/mm/hwpoison.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/mm/hwpoison.rst (Version linux-6.12-rc7) and /Documentation/mm/hwpoison.rst (Version linux-6.10.14)


  1 ========                                            1 ========
  2 hwpoison                                            2 hwpoison
  3 ========                                            3 ========
  4                                                     4 
  5 What is hwpoison?                                   5 What is hwpoison?
  6 =================                                   6 =================
  7                                                     7 
  8 Upcoming Intel CPUs have support for recoverin      8 Upcoming Intel CPUs have support for recovering from some memory errors
  9 (``MCA recovery``). This requires the OS to de      9 (``MCA recovery``). This requires the OS to declare a page "poisoned",
 10 kill the processes associated with it and avoi     10 kill the processes associated with it and avoid using it in the future.
 11                                                    11 
 12 This patchkit implements the necessary infrast     12 This patchkit implements the necessary infrastructure in the VM.
 13                                                    13 
 14 To quote the overview comment::                    14 To quote the overview comment::
 15                                                    15 
 16         High level machine check handler. Hand     16         High level machine check handler. Handles pages reported by the
 17         hardware as being corrupted usually du     17         hardware as being corrupted usually due to a 2bit ECC memory or cache
 18         failure.                                   18         failure.
 19                                                    19 
 20         This focusses on pages detected as cor     20         This focusses on pages detected as corrupted in the background.
 21         When the current CPU tries to consume      21         When the current CPU tries to consume corruption the currently
 22         running process can just be killed dir     22         running process can just be killed directly instead. This implies
 23         that if the error cannot be handled fo     23         that if the error cannot be handled for some reason it's safe to
 24         just ignore it because no corruption h     24         just ignore it because no corruption has been consumed yet. Instead
 25         when that happens another machine chec     25         when that happens another machine check will happen.
 26                                                    26 
 27         Handles page cache pages in various st     27         Handles page cache pages in various states. The tricky part
 28         here is that we can access any page as     28         here is that we can access any page asynchronous to other VM
 29         users, because memory failures could h     29         users, because memory failures could happen anytime and anywhere,
 30         possibly violating some of their assum     30         possibly violating some of their assumptions. This is why this code
 31         has to be extremely careful. Generally     31         has to be extremely careful. Generally it tries to use normal locking
 32         rules, as in get the standard locks, e     32         rules, as in get the standard locks, even if that means the
 33         error handling takes potentially a lon     33         error handling takes potentially a long time.
 34                                                    34 
 35         Some of the operations here are somewh     35         Some of the operations here are somewhat inefficient and have non
 36         linear algorithmic complexity, because     36         linear algorithmic complexity, because the data structures have not
 37         been optimized for this case. This is      37         been optimized for this case. This is in particular the case
 38         for the mapping from a vma to a proces     38         for the mapping from a vma to a process. Since this case is expected
 39         to be rare we hope we can get away wit     39         to be rare we hope we can get away with this.
 40                                                    40 
 41 The code consists of a the high level handler      41 The code consists of a the high level handler in mm/memory-failure.c,
 42 a new page poison bit and various checks in th     42 a new page poison bit and various checks in the VM to handle poisoned
 43 pages.                                             43 pages.
 44                                                    44 
 45 The main target right now is KVM guests, but i     45 The main target right now is KVM guests, but it works for all kinds
 46 of applications. KVM support requires a recent     46 of applications. KVM support requires a recent qemu-kvm release.
 47                                                    47 
 48 For the KVM use there was need for a new signa     48 For the KVM use there was need for a new signal type so that
 49 KVM can inject the machine check into the gues     49 KVM can inject the machine check into the guest with the proper
 50 address. This in theory allows other applicati     50 address. This in theory allows other applications to handle
 51 memory failures too. The expectation is that m     51 memory failures too. The expectation is that most applications
 52 won't do that, but some very specialized ones      52 won't do that, but some very specialized ones might.
 53                                                    53 
 54 Failure recovery modes                             54 Failure recovery modes
 55 ======================                             55 ======================
 56                                                    56 
 57 There are two (actually three) modes memory fa     57 There are two (actually three) modes memory failure recovery can be in:
 58                                                    58 
 59 vm.memory_failure_recovery sysctl set to zero:     59 vm.memory_failure_recovery sysctl set to zero:
 60         All memory failures cause a panic. Do      60         All memory failures cause a panic. Do not attempt recovery.
 61                                                    61 
 62 early kill                                         62 early kill
 63         (can be controlled globally and per pr     63         (can be controlled globally and per process)
 64         Send SIGBUS to the application as soon     64         Send SIGBUS to the application as soon as the error is detected
 65         This allows applications who can proce     65         This allows applications who can process memory errors in a gentle
 66         way (e.g. drop affected object)            66         way (e.g. drop affected object)
 67         This is the mode used by KVM qemu.         67         This is the mode used by KVM qemu.
 68                                                    68 
 69 late kill                                          69 late kill
 70         Send SIGBUS when the application runs      70         Send SIGBUS when the application runs into the corrupted page.
 71         This is best for memory error unaware      71         This is best for memory error unaware applications and default
 72         Note some pages are always handled as      72         Note some pages are always handled as late kill.
 73                                                    73 
 74 User control                                       74 User control
 75 ============                                       75 ============
 76                                                    76 
 77 vm.memory_failure_recovery                         77 vm.memory_failure_recovery
 78         See sysctl.txt                             78         See sysctl.txt
 79                                                    79 
 80 vm.memory_failure_early_kill                       80 vm.memory_failure_early_kill
 81         Enable early kill mode globally            81         Enable early kill mode globally
 82                                                    82 
 83 PR_MCE_KILL                                        83 PR_MCE_KILL
 84         Set early/late kill mode/revert to sys     84         Set early/late kill mode/revert to system default
 85                                                    85 
 86         arg1: PR_MCE_KILL_CLEAR:                   86         arg1: PR_MCE_KILL_CLEAR:
 87                 Revert to system default           87                 Revert to system default
 88         arg1: PR_MCE_KILL_SET:                     88         arg1: PR_MCE_KILL_SET:
 89                 arg2 defines thread specific m     89                 arg2 defines thread specific mode
 90                                                    90 
 91                 PR_MCE_KILL_EARLY:                 91                 PR_MCE_KILL_EARLY:
 92                         Early kill                 92                         Early kill
 93                 PR_MCE_KILL_LATE:                  93                 PR_MCE_KILL_LATE:
 94                         Late kill                  94                         Late kill
 95                 PR_MCE_KILL_DEFAULT                95                 PR_MCE_KILL_DEFAULT
 96                         Use system global defa     96                         Use system global default
 97                                                    97 
 98         Note that if you want to have a dedica     98         Note that if you want to have a dedicated thread which handles
 99         the SIGBUS(BUS_MCEERR_AO) on behalf of     99         the SIGBUS(BUS_MCEERR_AO) on behalf of the process, you should
100         call prctl(PR_MCE_KILL_EARLY) on the d    100         call prctl(PR_MCE_KILL_EARLY) on the designated thread. Otherwise,
101         the SIGBUS is sent to the main thread.    101         the SIGBUS is sent to the main thread.
102                                                   102 
103 PR_MCE_KILL_GET                                   103 PR_MCE_KILL_GET
104         return current mode                       104         return current mode
105                                                   105 
106 Testing                                           106 Testing
107 =======                                           107 =======
108                                                   108 
109 * madvise(MADV_HWPOISON, ....) (as root) - Poi    109 * madvise(MADV_HWPOISON, ....) (as root) - Poison a page in the
110   process for testing                             110   process for testing
111                                                   111 
112 * hwpoison-inject module through debugfs ``/sy    112 * hwpoison-inject module through debugfs ``/sys/kernel/debug/hwpoison/``
113                                                   113 
114   corrupt-pfn                                     114   corrupt-pfn
115         Inject hwpoison fault at PFN echoed in    115         Inject hwpoison fault at PFN echoed into this file. This does
116         some early filtering to avoid corrupte    116         some early filtering to avoid corrupted unintended pages in test suites.
117                                                   117 
118   unpoison-pfn                                    118   unpoison-pfn
119         Software-unpoison page at PFN echoed i    119         Software-unpoison page at PFN echoed into this file. This way
120         a page can be reused again.  This only    120         a page can be reused again.  This only works for Linux
121         injected failures, not for real memory    121         injected failures, not for real memory failures. Once any hardware
122         memory failure happens, this feature i    122         memory failure happens, this feature is disabled.
123                                                   123 
124   Note these injection interfaces are not stab    124   Note these injection interfaces are not stable and might change between
125   kernel versions                                 125   kernel versions
126                                                   126 
127   corrupt-filter-dev-major, corrupt-filter-dev    127   corrupt-filter-dev-major, corrupt-filter-dev-minor
128         Only handle memory failures to pages a    128         Only handle memory failures to pages associated with the file
129         system defined by block device major/m    129         system defined by block device major/minor.  -1U is the
130         wildcard value.  This should be only u    130         wildcard value.  This should be only used for testing with
131         artificial injection.                     131         artificial injection.
132                                                   132 
133   corrupt-filter-memcg                            133   corrupt-filter-memcg
134         Limit injection to pages owned by memg    134         Limit injection to pages owned by memgroup. Specified by inode
135         number of the memcg.                      135         number of the memcg.
136                                                   136 
137         Example::                                 137         Example::
138                                                   138 
139                 mkdir /sys/fs/cgroup/mem/hwpoi    139                 mkdir /sys/fs/cgroup/mem/hwpoison
140                                                   140 
141                 usemem -m 100 -s 1000 &           141                 usemem -m 100 -s 1000 &
142                 echo `jobs -p` > /sys/fs/cgrou    142                 echo `jobs -p` > /sys/fs/cgroup/mem/hwpoison/tasks
143                                                   143 
144                 memcg_ino=$(ls -id /sys/fs/cgr    144                 memcg_ino=$(ls -id /sys/fs/cgroup/mem/hwpoison | cut -f1 -d' ')
145                 echo $memcg_ino > /debug/hwpoi    145                 echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg
146                                                   146 
147                 page-types -p `pidof init`   -    147                 page-types -p `pidof init`   --hwpoison  # shall do nothing
148                 page-types -p `pidof usemem` -    148                 page-types -p `pidof usemem` --hwpoison  # poison its pages
149                                                   149 
150   corrupt-filter-flags-mask, corrupt-filter-fl    150   corrupt-filter-flags-mask, corrupt-filter-flags-value
151         When specified, only poison pages if (    151         When specified, only poison pages if ((page_flags & mask) ==
152         value).  This allows stress testing of    152         value).  This allows stress testing of many kinds of
153         pages. The page_flags are the same as     153         pages. The page_flags are the same as in /proc/kpageflags. The
154         flag bits are defined in include/linux    154         flag bits are defined in include/linux/kernel-page-flags.h and
155         documented in Documentation/admin-guid    155         documented in Documentation/admin-guide/mm/pagemap.rst
156                                                   156 
157 * Architecture specific MCE injector              157 * Architecture specific MCE injector
158                                                   158 
159   x86 has mce-inject, mce-test                    159   x86 has mce-inject, mce-test
160                                                   160 
161   Some portable hwpoison test programs in mce-    161   Some portable hwpoison test programs in mce-test, see below.
162                                                   162 
163 References                                        163 References
164 ==========                                        164 ==========
165                                                   165 
166 http://halobates.de/mce-lc09-2.pdf                166 http://halobates.de/mce-lc09-2.pdf
167         Overview presentation from LinuxCon 09    167         Overview presentation from LinuxCon 09
168                                                   168 
169 git://git.kernel.org/pub/scm/utils/cpu/mce/mce    169 git://git.kernel.org/pub/scm/utils/cpu/mce/mce-test.git
170         Test suite (hwpoison specific portable    170         Test suite (hwpoison specific portable tests in tsrc)
171                                                   171 
172 git://git.kernel.org/pub/scm/utils/cpu/mce/mce    172 git://git.kernel.org/pub/scm/utils/cpu/mce/mce-inject.git
173         x86 specific injector                     173         x86 specific injector
174                                                   174 
175                                                   175 
176 Limitations                                       176 Limitations
177 ===========                                       177 ===========
178 - Not all page types are supported and never w    178 - Not all page types are supported and never will. Most kernel internal
179   objects cannot be recovered, only LRU pages     179   objects cannot be recovered, only LRU pages for now.
180                                                   180 
181 ---                                               181 ---
182 Andi Kleen, Oct 2009                              182 Andi Kleen, Oct 2009
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php