diff options
author | Andi Kleen <andi@firstfloor.org> | 2009-09-16 11:50:05 +0200 |
---|---|---|
committer | Andi Kleen <ak@linux.intel.com> | 2009-09-16 11:50:05 +0200 |
commit | a7420aa54dbf699a5a05feba3c859b6baaa3938c (patch) | |
tree | 97119d311149c902b3bd3a6157e70fb79c876462 /include/linux/swapops.h | |
parent | 10be22dfe1e6ad978269dc275147e0ed049187bb (diff) | |
download | op-kernel-dev-a7420aa54dbf699a5a05feba3c859b6baaa3938c.zip op-kernel-dev-a7420aa54dbf699a5a05feba3c859b6baaa3938c.tar.gz |
HWPOISON: Add support for poison swap entries v2
Memory migration uses special swap entry types to trigger special actions on
page faults. Extend this mechanism to also support poisoned swap entries, to
trigger poison handling on page faults. This allows follow-on patches to
prevent processes from faulting in poisoned pages again.
v2: Fix overflow in MAX_SWAPFILES (Fengguang Wu)
v3: Better overflow fix (Hidehiro Kawai)
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'include/linux/swapops.h')
-rw-r--r-- | include/linux/swapops.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/linux/swapops.h b/include/linux/swapops.h index 6ec39ab..cd42e30 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -131,3 +131,41 @@ static inline int is_write_migration_entry(swp_entry_t entry) #endif +#ifdef CONFIG_MEMORY_FAILURE +/* + * Support for hardware poisoned pages + */ +static inline swp_entry_t make_hwpoison_entry(struct page *page) +{ + BUG_ON(!PageLocked(page)); + return swp_entry(SWP_HWPOISON, page_to_pfn(page)); +} + +static inline int is_hwpoison_entry(swp_entry_t entry) +{ + return swp_type(entry) == SWP_HWPOISON; +} +#else + +static inline swp_entry_t make_hwpoison_entry(struct page *page) +{ + return swp_entry(0, 0); +} + +static inline int is_hwpoison_entry(swp_entry_t swp) +{ + return 0; +} +#endif + +#if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION) +static inline int non_swap_entry(swp_entry_t entry) +{ + return swp_type(entry) >= MAX_SWAPFILES; +} +#else +static inline int non_swap_entry(swp_entry_t entry) +{ + return 0; +} +#endif |