aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2011-12-15 13:48:12 -0500
committerTony Luck <tony.luck@intel.com>2012-01-03 15:06:32 -0500
commitcd42f4a3b2b1c4cbd997363dc57821953d73fd87 (patch)
treec7db057922def7f742fbcd283324051bdd92b053 /mm
parentdc47ce90c3a822cd7c9e9339fe4d5f61dcb26b50 (diff)
HWPOISON: Clean up memory_failure() vs. __memory_failure()
There is only one caller of memory_failure(), all other users call __memory_failure() and pass in the flags argument explicitly. The lone user of memory_failure() will soon need to pass flags too. Add flags argument to the callsite in mce.c. Delete the old memory_failure() function, and then rename __memory_failure() without the leading "__". Provide clearer message when action optional memory errors are ignored. Acked-by: Borislav Petkov <bp@amd64.org> Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/hwpoison-inject.c4
-rw-r--r--mm/madvise.c2
-rw-r--r--mm/memory-failure.c46
3 files changed, 24 insertions, 28 deletions
diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c
index c7fc7fd00e32..cc448bb983ba 100644
--- a/mm/hwpoison-inject.c
+++ b/mm/hwpoison-inject.c
@@ -45,7 +45,7 @@ static int hwpoison_inject(void *data, u64 val)
45 * do a racy check with elevated page count, to make sure PG_hwpoison 45 * do a racy check with elevated page count, to make sure PG_hwpoison
46 * will only be set for the targeted owner (or on a free page). 46 * will only be set for the targeted owner (or on a free page).
47 * We temporarily take page lock for try_get_mem_cgroup_from_page(). 47 * We temporarily take page lock for try_get_mem_cgroup_from_page().
48 * __memory_failure() will redo the check reliably inside page lock. 48 * memory_failure() will redo the check reliably inside page lock.
49 */ 49 */
50 lock_page(hpage); 50 lock_page(hpage);
51 err = hwpoison_filter(hpage); 51 err = hwpoison_filter(hpage);
@@ -55,7 +55,7 @@ static int hwpoison_inject(void *data, u64 val)
55 55
56inject: 56inject:
57 printk(KERN_INFO "Injecting memory failure at pfn %lx\n", pfn); 57 printk(KERN_INFO "Injecting memory failure at pfn %lx\n", pfn);
58 return __memory_failure(pfn, 18, MF_COUNT_INCREASED); 58 return memory_failure(pfn, 18, MF_COUNT_INCREASED);
59} 59}
60 60
61static int hwpoison_unpoison(void *data, u64 val) 61static int hwpoison_unpoison(void *data, u64 val)
diff --git a/mm/madvise.c b/mm/madvise.c
index 74bf193eff04..f5ab745672b7 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -251,7 +251,7 @@ static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
251 printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n", 251 printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n",
252 page_to_pfn(p), start); 252 page_to_pfn(p), start);
253 /* Ignore return value for now */ 253 /* Ignore return value for now */
254 __memory_failure(page_to_pfn(p), 0, MF_COUNT_INCREASED); 254 memory_failure(page_to_pfn(p), 0, MF_COUNT_INCREASED);
255 } 255 }
256 return ret; 256 return ret;
257} 257}
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 06d3479513aa..ab259bb0adc5 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -984,7 +984,25 @@ static void clear_page_hwpoison_huge_page(struct page *hpage)
984 ClearPageHWPoison(hpage + i); 984 ClearPageHWPoison(hpage + i);
985} 985}
986 986
987int __memory_failure(unsigned long pfn, int trapno, int flags) 987/**
988 * memory_failure - Handle memory failure of a page.
989 * @pfn: Page Number of the corrupted page
990 * @trapno: Trap number reported in the signal to user space.
991 * @flags: fine tune action taken
992 *
993 * This function is called by the low level machine check code
994 * of an architecture when it detects hardware memory corruption
995 * of a page. It tries its best to recover, which includes
996 * dropping pages, killing processes etc.
997 *
998 * The function is primarily of use for corruptions that
999 * happen outside the current execution context (e.g. when
1000 * detected by a background scrubber)
1001 *
1002 * Must run in process context (e.g. a work queue) with interrupts
1003 * enabled and no spinlocks hold.
1004 */
1005int memory_failure(unsigned long pfn, int trapno, int flags)
988{ 1006{
989 struct page_state *ps; 1007 struct page_state *ps;
990 struct page *p; 1008 struct page *p;
@@ -1156,29 +1174,7 @@ out:
1156 unlock_page(hpage); 1174 unlock_page(hpage);
1157 return res; 1175 return res;
1158} 1176}
1159EXPORT_SYMBOL_GPL(__memory_failure); 1177EXPORT_SYMBOL_GPL(memory_failure);
1160
1161/**
1162 * memory_failure - Handle memory failure of a page.
1163 * @pfn: Page Number of the corrupted page
1164 * @trapno: Trap number reported in the signal to user space.
1165 *
1166 * This function is called by the low level machine check code
1167 * of an architecture when it detects hardware memory corruption
1168 * of a page. It tries its best to recover, which includes
1169 * dropping pages, killing processes etc.
1170 *
1171 * The function is primarily of use for corruptions that
1172 * happen outside the current execution context (e.g. when
1173 * detected by a background scrubber)
1174 *
1175 * Must run in process context (e.g. a work queue) with interrupts
1176 * enabled and no spinlocks hold.
1177 */
1178void memory_failure(unsigned long pfn, int trapno)
1179{
1180 __memory_failure(pfn, trapno, 0);
1181}
1182 1178
1183#define MEMORY_FAILURE_FIFO_ORDER 4 1179#define MEMORY_FAILURE_FIFO_ORDER 4
1184#define MEMORY_FAILURE_FIFO_SIZE (1 << MEMORY_FAILURE_FIFO_ORDER) 1180#define MEMORY_FAILURE_FIFO_SIZE (1 << MEMORY_FAILURE_FIFO_ORDER)
@@ -1251,7 +1247,7 @@ static void memory_failure_work_func(struct work_struct *work)
1251 spin_unlock_irqrestore(&mf_cpu->lock, proc_flags); 1247 spin_unlock_irqrestore(&mf_cpu->lock, proc_flags);
1252 if (!gotten) 1248 if (!gotten)
1253 break; 1249 break;
1254 __memory_failure(entry.pfn, entry.trapno, entry.flags); 1250 memory_failure(entry.pfn, entry.trapno, entry.flags);
1255 } 1251 }
1256} 1252}
1257 1253