33
33
* are rare we hope to get away with this. This avoids impacting the core
34
34
* VM.
35
35
*/
36
+
37
+ #define pr_fmt (fmt ) "Memory failure: " fmt
38
+
36
39
#include <linux/kernel.h>
37
40
#include <linux/mm.h>
38
41
#include <linux/page-flags.h>
@@ -252,7 +255,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
252
255
short addr_lsb = tk -> size_shift ;
253
256
int ret = 0 ;
254
257
255
- pr_err ("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n" ,
258
+ pr_err ("%#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n" ,
256
259
pfn , t -> comm , t -> pid );
257
260
258
261
if ((flags & MF_ACTION_REQUIRED ) && (t == current ))
@@ -270,7 +273,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
270
273
ret = send_sig_mceerr (BUS_MCEERR_AO , (void __user * )tk -> addr ,
271
274
addr_lsb , t ); /* synchronous? */
272
275
if (ret < 0 )
273
- pr_info ("Memory failure: Error sending signal to %s:%d: %d\n" ,
276
+ pr_info ("Error sending signal to %s:%d: %d\n" ,
274
277
t -> comm , t -> pid , ret );
275
278
return ret ;
276
279
}
@@ -352,7 +355,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
352
355
353
356
tk = kmalloc (sizeof (struct to_kill ), GFP_ATOMIC );
354
357
if (!tk ) {
355
- pr_err ("Memory failure: Out of memory while machine check handling\n" );
358
+ pr_err ("Out of memory while machine check handling\n" );
356
359
return ;
357
360
}
358
361
@@ -379,7 +382,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
379
382
* has a mapping for the page.
380
383
*/
381
384
if (tk -> addr == - EFAULT ) {
382
- pr_info ("Memory failure: Unable to find user space address %lx in %s\n" ,
385
+ pr_info ("Unable to find user space address %lx in %s\n" ,
383
386
page_to_pfn (p ), tsk -> comm );
384
387
} else if (tk -> size_shift == 0 ) {
385
388
kfree (tk );
@@ -412,7 +415,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
412
415
* signal and then access the memory. Just kill it.
413
416
*/
414
417
if (fail || tk -> addr == - EFAULT ) {
415
- pr_err ("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n" ,
418
+ pr_err ("%#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n" ,
416
419
pfn , tk -> tsk -> comm , tk -> tsk -> pid );
417
420
do_send_sig_info (SIGKILL , SEND_SIG_PRIV ,
418
421
tk -> tsk , PIDTYPE_PID );
@@ -425,7 +428,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
425
428
* process anyways.
426
429
*/
427
430
else if (kill_proc (tk , pfn , flags ) < 0 )
428
- pr_err ("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n" ,
431
+ pr_err ("%#lx: Cannot send advisory machine check signal to %s:%d\n" ,
429
432
pfn , tk -> tsk -> comm , tk -> tsk -> pid );
430
433
}
431
434
put_task_struct (tk -> tsk );
@@ -816,12 +819,10 @@ static int truncate_error_page(struct page *p, unsigned long pfn,
816
819
int err = mapping -> a_ops -> error_remove_page (mapping , p );
817
820
818
821
if (err != 0 ) {
819
- pr_info ("Memory failure: %#lx: Failed to punch page: %d\n" ,
820
- pfn , err );
822
+ pr_info ("%#lx: Failed to punch page: %d\n" , pfn , err );
821
823
} else if (page_has_private (p ) &&
822
824
!try_to_release_page (p , GFP_NOIO )) {
823
- pr_info ("Memory failure: %#lx: failed to release buffers\n" ,
824
- pfn );
825
+ pr_info ("%#lx: failed to release buffers\n" , pfn );
825
826
} else {
826
827
ret = MF_RECOVERED ;
827
828
}
@@ -833,8 +834,7 @@ static int truncate_error_page(struct page *p, unsigned long pfn,
833
834
if (invalidate_inode_page (p ))
834
835
ret = MF_RECOVERED ;
835
836
else
836
- pr_info ("Memory failure: %#lx: Failed to invalidate\n" ,
837
- pfn );
837
+ pr_info ("%#lx: Failed to invalidate\n" , pfn );
838
838
}
839
839
840
840
return ret ;
@@ -864,7 +864,7 @@ static bool has_extra_refcount(struct page_state *ps, struct page *p,
864
864
count -= 1 ;
865
865
866
866
if (count > 0 ) {
867
- pr_err ("Memory failure: %#lx: %s still referenced by %d users\n" ,
867
+ pr_err ("%#lx: %s still referenced by %d users\n" ,
868
868
page_to_pfn (p ), action_page_types [ps -> type ], count );
869
869
return true;
870
870
}
@@ -888,7 +888,7 @@ static int me_kernel(struct page_state *ps, struct page *p)
888
888
*/
889
889
static int me_unknown (struct page_state * ps , struct page * p )
890
890
{
891
- pr_err ("Memory failure: %#lx: Unknown page state\n" , page_to_pfn (p ));
891
+ pr_err ("%#lx: Unknown page state\n" , page_to_pfn (p ));
892
892
unlock_page (p );
893
893
return MF_FAILED ;
894
894
}
@@ -1173,7 +1173,7 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type,
1173
1173
trace_memory_failure_event (pfn , type , result );
1174
1174
1175
1175
num_poisoned_pages_inc ();
1176
- pr_err ("Memory failure: %#lx: recovery action for %s: %s\n" ,
1176
+ pr_err ("%#lx: recovery action for %s: %s\n" ,
1177
1177
pfn , action_page_types [type ], action_name [result ]);
1178
1178
}
1179
1179
@@ -1248,8 +1248,7 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags)
1248
1248
if (head == compound_head (page ))
1249
1249
return 1 ;
1250
1250
1251
- pr_info ("Memory failure: %#lx cannot catch tail\n" ,
1252
- page_to_pfn (page ));
1251
+ pr_info ("%#lx cannot catch tail\n" , page_to_pfn (page ));
1253
1252
put_page (head );
1254
1253
}
1255
1254
@@ -1312,7 +1311,7 @@ static int get_any_page(struct page *p, unsigned long flags)
1312
1311
}
1313
1312
out :
1314
1313
if (ret == - EIO )
1315
- pr_err ("Memory failure: %#lx: unhandlable page.\n" , page_to_pfn (p ));
1314
+ pr_err ("%#lx: unhandlable page.\n" , page_to_pfn (p ));
1316
1315
1317
1316
return ret ;
1318
1317
}
@@ -1411,13 +1410,12 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
1411
1410
return true;
1412
1411
1413
1412
if (PageKsm (p )) {
1414
- pr_err ("Memory failure: %#lx: can't handle KSM pages.\n" , pfn );
1413
+ pr_err ("%#lx: can't handle KSM pages.\n" , pfn );
1415
1414
return false;
1416
1415
}
1417
1416
1418
1417
if (PageSwapCache (p )) {
1419
- pr_err ("Memory failure: %#lx: keeping poisoned page in swap cache\n" ,
1420
- pfn );
1418
+ pr_err ("%#lx: keeping poisoned page in swap cache\n" , pfn );
1421
1419
ttu |= TTU_IGNORE_HWPOISON ;
1422
1420
}
1423
1421
@@ -1435,7 +1433,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
1435
1433
} else {
1436
1434
kill = 0 ;
1437
1435
ttu |= TTU_IGNORE_HWPOISON ;
1438
- pr_info ("Memory failure: %#lx: corrupted page was clean: dropped without side effects\n" ,
1436
+ pr_info ("%#lx: corrupted page was clean: dropped without side effects\n" ,
1439
1437
pfn );
1440
1438
}
1441
1439
}
@@ -1464,14 +1462,14 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
1464
1462
try_to_unmap (folio , ttu |TTU_RMAP_LOCKED );
1465
1463
i_mmap_unlock_write (mapping );
1466
1464
} else
1467
- pr_info ("Memory failure: %#lx: could not lock mapping for mapped huge page\n" , pfn );
1465
+ pr_info ("%#lx: could not lock mapping for mapped huge page\n" , pfn );
1468
1466
} else {
1469
1467
try_to_unmap (folio , ttu );
1470
1468
}
1471
1469
1472
1470
unmap_success = !page_mapped (hpage );
1473
1471
if (!unmap_success )
1474
- pr_err ("Memory failure: %#lx: failed to unmap page (mapcount=%d)\n" ,
1472
+ pr_err ("%#lx: failed to unmap page (mapcount=%d)\n" ,
1475
1473
pfn , page_mapcount (hpage ));
1476
1474
1477
1475
/*
@@ -1732,7 +1730,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
1732
1730
* hugetlb = 0 ;
1733
1731
return 0 ;
1734
1732
} else if (res == - EHWPOISON ) {
1735
- pr_err ("Memory failure: %#lx: already hardware poisoned\n" , pfn );
1733
+ pr_err ("%#lx: already hardware poisoned\n" , pfn );
1736
1734
if (flags & MF_ACTION_REQUIRED ) {
1737
1735
head = compound_head (p );
1738
1736
res = kill_accessing_process (current , page_to_pfn (head ), flags );
@@ -1901,8 +1899,7 @@ int memory_failure(unsigned long pfn, int flags)
1901
1899
goto unlock_mutex ;
1902
1900
}
1903
1901
}
1904
- pr_err ("Memory failure: %#lx: memory outside kernel control\n" ,
1905
- pfn );
1902
+ pr_err ("%#lx: memory outside kernel control\n" , pfn );
1906
1903
res = - ENXIO ;
1907
1904
goto unlock_mutex ;
1908
1905
}
@@ -1913,8 +1910,7 @@ int memory_failure(unsigned long pfn, int flags)
1913
1910
goto unlock_mutex ;
1914
1911
1915
1912
if (TestSetPageHWPoison (p )) {
1916
- pr_err ("Memory failure: %#lx: already hardware poisoned\n" ,
1917
- pfn );
1913
+ pr_err ("%#lx: already hardware poisoned\n" , pfn );
1918
1914
res = - EHWPOISON ;
1919
1915
if (flags & MF_ACTION_REQUIRED )
1920
1916
res = kill_accessing_process (current , pfn , flags );
@@ -2130,7 +2126,7 @@ void memory_failure_queue(unsigned long pfn, int flags)
2130
2126
if (kfifo_put (& mf_cpu -> fifo , entry ))
2131
2127
schedule_work_on (smp_processor_id (), & mf_cpu -> work );
2132
2128
else
2133
- pr_err ("Memory failure: buffer overflow when queuing memory failure at %#lx\n" ,
2129
+ pr_err ("buffer overflow when queuing memory failure at %#lx\n" ,
2134
2130
pfn );
2135
2131
spin_unlock_irqrestore (& mf_cpu -> lock , proc_flags );
2136
2132
put_cpu_var (memory_failure_cpu );
@@ -2187,6 +2183,8 @@ static int __init memory_failure_init(void)
2187
2183
}
2188
2184
core_initcall (memory_failure_init );
2189
2185
2186
+ #undef pr_fmt
2187
+ #define pr_fmt (fmt ) "" fmt
2190
2188
#define unpoison_pr_info (fmt , pfn , rs ) \
2191
2189
({ \
2192
2190
if (__ratelimit(rs)) \
0 commit comments