diff options
author | Andi Kleen <andi@firstfloor.org> | 2009-09-16 05:50:15 -0400 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2009-09-16 05:50:15 -0400 |
commit | 6a46079cf57a7f7758e8b926980a4f852f89b34d (patch) | |
tree | efd72e830201370d6273bd436dda5a3c4cd6ed9b /include/linux | |
parent | 4db96cf077aa938b11fe7ac79ecc9b29ec00fbab (diff) |
HWPOISON: The high level memory error handler in the VM v7
Add the high level memory handler that poisons pages
that got corrupted by hardware (typically by a two bit flip in a DIMM
or a cache) on the Linux level. The goal is to prevent everyone
from accessing these pages in the future.
This done at the VM level by marking a page hwpoisoned
and doing the appropriate action based on the type of page
it is.
The code that does this is portable and lives in mm/memory-failure.c
To quote the overview comment:
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 focuses 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.
There are in principle two strategies to kill processes on poison:
- just unmap the data and wait for an actual reference before
killing
- kill as soon as corruption is detected.
Both have advantages and disadvantages and should be used
in different situations. Right now both are implemented and can
be switched with a new sysctl vm.memory_failure_early_kill
The default is early kill.
The patch does some rmap data structure walking on its own to collect
processes to kill. This is unusual because normally all rmap data structure
knowledge is in rmap.c only. I put it here for now to keep
everything together and rmap knowledge has been seeping out anyways
Includes contributions from Johannes Weiner, Chris Mason, Fengguang Wu,
Nick Piggin (who did a lot of great work) and others.
Cc: npiggin@suse.de
Cc: riel@redhat.com
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Rik van Riel <riel@redhat.com>
Reviewed-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/mm.h | 7 | ||||
-rw-r--r-- | include/linux/rmap.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index a16018f7d61c..1ffca03f34b7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1309,5 +1309,12 @@ void vmemmap_populate_print_last(void); | |||
1309 | extern int account_locked_memory(struct mm_struct *mm, struct rlimit *rlim, | 1309 | extern int account_locked_memory(struct mm_struct *mm, struct rlimit *rlim, |
1310 | size_t size); | 1310 | size_t size); |
1311 | extern void refund_locked_memory(struct mm_struct *mm, size_t size); | 1311 | extern void refund_locked_memory(struct mm_struct *mm, size_t size); |
1312 | |||
1313 | extern void memory_failure(unsigned long pfn, int trapno); | ||
1314 | extern int __memory_failure(unsigned long pfn, int trapno, int ref); | ||
1315 | extern int sysctl_memory_failure_early_kill; | ||
1316 | extern int sysctl_memory_failure_recovery; | ||
1317 | extern atomic_long_t mce_bad_pages; | ||
1318 | |||
1312 | #endif /* __KERNEL__ */ | 1319 | #endif /* __KERNEL__ */ |
1313 | #endif /* _LINUX_MM_H */ | 1320 | #endif /* _LINUX_MM_H */ |
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index ce989f1fc2ed..3c1004e50747 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h | |||
@@ -129,6 +129,7 @@ int try_to_munlock(struct page *); | |||
129 | */ | 129 | */ |
130 | struct anon_vma *page_lock_anon_vma(struct page *page); | 130 | struct anon_vma *page_lock_anon_vma(struct page *page); |
131 | void page_unlock_anon_vma(struct anon_vma *anon_vma); | 131 | void page_unlock_anon_vma(struct anon_vma *anon_vma); |
132 | int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma); | ||
132 | 133 | ||
133 | #else /* !CONFIG_MMU */ | 134 | #else /* !CONFIG_MMU */ |
134 | 135 | ||