Skip to content

Commit db16826

Browse files
committed
Merge branch 'hwpoison' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6
* 'hwpoison' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6: (21 commits) HWPOISON: Enable error_remove_page on btrfs HWPOISON: Add simple debugfs interface to inject hwpoison on arbitary PFNs HWPOISON: Add madvise() based injector for hardware poisoned pages v4 HWPOISON: Enable error_remove_page for NFS HWPOISON: Enable .remove_error_page for migration aware file systems HWPOISON: The high level memory error handler in the VM v7 HWPOISON: Add PR_MCE_KILL prctl to control early kill behaviour per process HWPOISON: shmem: call set_page_dirty() with locked page HWPOISON: Define a new error_remove_page address space op for async truncation HWPOISON: Add invalidate_inode_page HWPOISON: Refactor truncate to allow direct truncating of page v2 HWPOISON: check and isolate corrupted free pages v2 HWPOISON: Handle hardware poisoned pages in try_to_unmap HWPOISON: Use bitmask/action code for try_to_unmap behaviour HWPOISON: x86: Add VM_FAULT_HWPOISON handling to x86 page fault handler v2 HWPOISON: Add poison check to page fault handling HWPOISON: Add basic support for poisoned pages in fault handler v3 HWPOISON: Add new SIGBUS error codes for hardware poison signals HWPOISON: Add support for poison swap entries v2 HWPOISON: Export some rmap vma locking to outside world ...
2 parents cd60451 + 465fdd9 commit db16826

40 files changed

Lines changed: 1331 additions & 68 deletions

‎Documentation/filesystems/vfs.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ struct address_space_operations {
536536
/* migrate the contents of a page to the specified target */
537537
int (*migratepage) (struct page *, struct page *);
538538
int (*launder_page) (struct page *);
539+
int (*error_remove_page) (struct mapping *mapping, struct page *page);
539540
};
540541

541542
writepage: called by the VM to write a dirty page to backing store.
@@ -694,6 +695,12 @@ struct address_space_operations {
694695
prevent redirtying the page, it is kept locked during the whole
695696
operation.
696697

698+
error_remove_page: normally set to generic_error_remove_page if truncation
699+
is ok for this address space. Used for memory failure handling.
700+
Setting this implies you deal with pages going away under you,
701+
unless you have them locked or reference counts increased.
702+
703+
697704
The File Object
698705
===============
699706

‎Documentation/sysctl/vm.txt‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Currently, these files are in /proc/sys/vm:
3232
- legacy_va_layout
3333
- lowmem_reserve_ratio
3434
- max_map_count
35+
- memory_failure_early_kill
36+
- memory_failure_recovery
3537
- min_free_kbytes
3638
- min_slab_ratio
3739
- min_unmapped_ratio
@@ -53,7 +55,6 @@ Currently, these files are in /proc/sys/vm:
5355
- vfs_cache_pressure
5456
- zone_reclaim_mode
5557

56-
5758
==============================================================
5859

5960
block_dump
@@ -275,6 +276,44 @@ e.g., up to one or two maps per allocation.
275276

276277
The default value is 65536.
277278

279+
=============================================================
280+
281+
memory_failure_early_kill:
282+
283+
Control how to kill processes when uncorrected memory error (typically
284+
a 2bit error in a memory module) is detected in the background by hardware
285+
that cannot be handled by the kernel. In some cases (like the page
286+
still having a valid copy on disk) the kernel will handle the failure
287+
transparently without affecting any applications. But if there is
288+
no other uptodate copy of the data it will kill to prevent any data
289+
corruptions from propagating.
290+
291+
1: Kill all processes that have the corrupted and not reloadable page mapped
292+
as soon as the corruption is detected. Note this is not supported
293+
for a few types of pages, like kernel internally allocated data or
294+
the swap cache, but works for the majority of user pages.
295+
296+
0: Only unmap the corrupted page from all processes and only kill a process
297+
who tries to access it.
298+
299+
The kill is done using a catchable SIGBUS with BUS_MCEERR_AO, so processes can
300+
handle this if they want to.
301+
302+
This is only active on architectures/platforms with advanced machine
303+
check handling and depends on the hardware capabilities.
304+
305+
Applications can override this setting individually with the PR_MCE_KILL prctl
306+
307+
==============================================================
308+
309+
memory_failure_recovery
310+
311+
Enable memory failure recovery (when supported by the platform)
312+
313+
1: Attempt recovery.
314+
315+
0: Always panic on a memory failure.
316+
278317
==============================================================
279318

280319
min_free_kbytes:

‎arch/x86/mm/fault.c‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
167167
info.si_errno = 0;
168168
info.si_code = si_code;
169169
info.si_addr = (void __user *)address;
170+
info.si_addr_lsb = si_code == BUS_MCEERR_AR ? PAGE_SHIFT : 0;
170171

171172
force_sig_info(si_signo, &info, tsk);
172173
}
@@ -790,10 +791,12 @@ out_of_memory(struct pt_regs *regs, unsigned long error_code,
790791
}
791792

792793
static void
793-
do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address)
794+
do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
795+
unsigned int fault)
794796
{
795797
struct task_struct *tsk = current;
796798
struct mm_struct *mm = tsk->mm;
799+
int code = BUS_ADRERR;
797800

798801
up_read(&mm->mmap_sem);
799802

@@ -809,7 +812,15 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address)
809812
tsk->thread.error_code = error_code;
810813
tsk->thread.trap_no = 14;
811814

812-
force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
815+
#ifdef CONFIG_MEMORY_FAILURE
816+
if (fault & VM_FAULT_HWPOISON) {
817+
printk(KERN_ERR
818+
"MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
819+
tsk->comm, tsk->pid, address);
820+
code = BUS_MCEERR_AR;
821+
}
822+
#endif
823+
force_sig_info_fault(SIGBUS, code, address, tsk);
813824
}
814825

815826
static noinline void
@@ -819,8 +830,8 @@ mm_fault_error(struct pt_regs *regs, unsigned long error_code,
819830
if (fault & VM_FAULT_OOM) {
820831
out_of_memory(regs, error_code, address);
821832
} else {
822-
if (fault & VM_FAULT_SIGBUS)
823-
do_sigbus(regs, error_code, address);
833+
if (fault & (VM_FAULT_SIGBUS|VM_FAULT_HWPOISON))
834+
do_sigbus(regs, error_code, address, fault);
824835
else
825836
BUG();
826837
}

‎fs/btrfs/inode.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5269,6 +5269,7 @@ static const struct address_space_operations btrfs_aops = {
52695269
.invalidatepage = btrfs_invalidatepage,
52705270
.releasepage = btrfs_releasepage,
52715271
.set_page_dirty = btrfs_set_page_dirty,
5272+
.error_remove_page = generic_error_remove_page,
52725273
};
52735274

52745275
static const struct address_space_operations btrfs_symlink_aops = {

‎fs/ext2/inode.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ const struct address_space_operations ext2_aops = {
819819
.writepages = ext2_writepages,
820820
.migratepage = buffer_migrate_page,
821821
.is_partially_uptodate = block_is_partially_uptodate,
822+
.error_remove_page = generic_error_remove_page,
822823
};
823824

824825
const struct address_space_operations ext2_aops_xip = {
@@ -837,6 +838,7 @@ const struct address_space_operations ext2_nobh_aops = {
837838
.direct_IO = ext2_direct_IO,
838839
.writepages = ext2_writepages,
839840
.migratepage = buffer_migrate_page,
841+
.error_remove_page = generic_error_remove_page,
840842
};
841843

842844
/*

‎fs/ext3/inode.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,7 @@ static const struct address_space_operations ext3_ordered_aops = {
18301830
.direct_IO = ext3_direct_IO,
18311831
.migratepage = buffer_migrate_page,
18321832
.is_partially_uptodate = block_is_partially_uptodate,
1833+
.error_remove_page = generic_error_remove_page,
18331834
};
18341835

18351836
static const struct address_space_operations ext3_writeback_aops = {
@@ -1845,6 +1846,7 @@ static const struct address_space_operations ext3_writeback_aops = {
18451846
.direct_IO = ext3_direct_IO,
18461847
.migratepage = buffer_migrate_page,
18471848
.is_partially_uptodate = block_is_partially_uptodate,
1849+
.error_remove_page = generic_error_remove_page,
18481850
};
18491851

18501852
static const struct address_space_operations ext3_journalled_aops = {
@@ -1859,6 +1861,7 @@ static const struct address_space_operations ext3_journalled_aops = {
18591861
.invalidatepage = ext3_invalidatepage,
18601862
.releasepage = ext3_releasepage,
18611863
.is_partially_uptodate = block_is_partially_uptodate,
1864+
.error_remove_page = generic_error_remove_page,
18621865
};
18631866

18641867
void ext3_set_aops(struct inode *inode)

‎fs/ext4/inode.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,6 +3386,7 @@ static const struct address_space_operations ext4_ordered_aops = {
33863386
.direct_IO = ext4_direct_IO,
33873387
.migratepage = buffer_migrate_page,
33883388
.is_partially_uptodate = block_is_partially_uptodate,
3389+
.error_remove_page = generic_error_remove_page,
33893390
};
33903391

33913392
static const struct address_space_operations ext4_writeback_aops = {
@@ -3401,6 +3402,7 @@ static const struct address_space_operations ext4_writeback_aops = {
34013402
.direct_IO = ext4_direct_IO,
34023403
.migratepage = buffer_migrate_page,
34033404
.is_partially_uptodate = block_is_partially_uptodate,
3405+
.error_remove_page = generic_error_remove_page,
34043406
};
34053407

34063408
static const struct address_space_operations ext4_journalled_aops = {
@@ -3415,6 +3417,7 @@ static const struct address_space_operations ext4_journalled_aops = {
34153417
.invalidatepage = ext4_invalidatepage,
34163418
.releasepage = ext4_releasepage,
34173419
.is_partially_uptodate = block_is_partially_uptodate,
3420+
.error_remove_page = generic_error_remove_page,
34183421
};
34193422

34203423
static const struct address_space_operations ext4_da_aops = {
@@ -3431,6 +3434,7 @@ static const struct address_space_operations ext4_da_aops = {
34313434
.direct_IO = ext4_direct_IO,
34323435
.migratepage = buffer_migrate_page,
34333436
.is_partially_uptodate = block_is_partially_uptodate,
3437+
.error_remove_page = generic_error_remove_page,
34343438
};
34353439

34363440
void ext4_set_aops(struct inode *inode)

‎fs/gfs2/aops.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ static const struct address_space_operations gfs2_writeback_aops = {
11351135
.direct_IO = gfs2_direct_IO,
11361136
.migratepage = buffer_migrate_page,
11371137
.is_partially_uptodate = block_is_partially_uptodate,
1138+
.error_remove_page = generic_error_remove_page,
11381139
};
11391140

11401141
static const struct address_space_operations gfs2_ordered_aops = {
@@ -1151,6 +1152,7 @@ static const struct address_space_operations gfs2_ordered_aops = {
11511152
.direct_IO = gfs2_direct_IO,
11521153
.migratepage = buffer_migrate_page,
11531154
.is_partially_uptodate = block_is_partially_uptodate,
1155+
.error_remove_page = generic_error_remove_page,
11541156
};
11551157

11561158
static const struct address_space_operations gfs2_jdata_aops = {
@@ -1166,6 +1168,7 @@ static const struct address_space_operations gfs2_jdata_aops = {
11661168
.invalidatepage = gfs2_invalidatepage,
11671169
.releasepage = gfs2_releasepage,
11681170
.is_partially_uptodate = block_is_partially_uptodate,
1171+
.error_remove_page = generic_error_remove_page,
11691172
};
11701173

11711174
void gfs2_set_aops(struct inode *inode)

‎fs/nfs/file.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ const struct address_space_operations nfs_file_aops = {
525525
.direct_IO = nfs_direct_IO,
526526
.migratepage = nfs_migrate_page,
527527
.launder_page = nfs_launder_page,
528+
.error_remove_page = generic_error_remove_page,
528529
};
529530

530531
/*

‎fs/ntfs/aops.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ const struct address_space_operations ntfs_aops = {
15501550
.migratepage = buffer_migrate_page, /* Move a page cache page from
15511551
one physical page to an
15521552
other. */
1553+
.error_remove_page = generic_error_remove_page,
15531554
};
15541555

15551556
/**
@@ -1569,6 +1570,7 @@ const struct address_space_operations ntfs_mst_aops = {
15691570
.migratepage = buffer_migrate_page, /* Move a page cache page from
15701571
one physical page to an
15711572
other. */
1573+
.error_remove_page = generic_error_remove_page,
15721574
};
15731575

15741576
#ifdef NTFS_RW

0 commit comments

Comments
 (0)