3333 * are rare we hope to get away with this. This avoids impacting the core
3434 * VM.
3535 */
36+
37+ #define pr_fmt (fmt ) "Memory failure: " fmt
38+
3639#include <linux/kernel.h>
3740#include <linux/mm.h>
3841#include <linux/page-flags.h>
@@ -252,7 +255,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
252255 short addr_lsb = tk -> size_shift ;
253256 int ret = 0 ;
254257
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" ,
256259 pfn , t -> comm , t -> pid );
257260
258261 if ((flags & MF_ACTION_REQUIRED ) && (t == current ))
@@ -270,7 +273,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
270273 ret = send_sig_mceerr (BUS_MCEERR_AO , (void __user * )tk -> addr ,
271274 addr_lsb , t ); /* synchronous? */
272275 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" ,
274277 t -> comm , t -> pid , ret );
275278 return ret ;
276279}
@@ -352,7 +355,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
352355
353356 tk = kmalloc (sizeof (struct to_kill ), GFP_ATOMIC );
354357 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" );
356359 return ;
357360 }
358361
@@ -379,7 +382,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
379382 * has a mapping for the page.
380383 */
381384 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" ,
383386 page_to_pfn (p ), tsk -> comm );
384387 } else if (tk -> size_shift == 0 ) {
385388 kfree (tk );
@@ -412,7 +415,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
412415 * signal and then access the memory. Just kill it.
413416 */
414417 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" ,
416419 pfn , tk -> tsk -> comm , tk -> tsk -> pid );
417420 do_send_sig_info (SIGKILL , SEND_SIG_PRIV ,
418421 tk -> tsk , PIDTYPE_PID );
@@ -425,7 +428,7 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
425428 * process anyways.
426429 */
427430 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" ,
429432 pfn , tk -> tsk -> comm , tk -> tsk -> pid );
430433 }
431434 put_task_struct (tk -> tsk );
@@ -816,12 +819,10 @@ static int truncate_error_page(struct page *p, unsigned long pfn,
816819 int err = mapping -> a_ops -> error_remove_page (mapping , p );
817820
818821 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 );
821823 } else if (page_has_private (p ) &&
822824 !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 );
825826 } else {
826827 ret = MF_RECOVERED ;
827828 }
@@ -833,8 +834,7 @@ static int truncate_error_page(struct page *p, unsigned long pfn,
833834 if (invalidate_inode_page (p ))
834835 ret = MF_RECOVERED ;
835836 else
836- pr_info ("Memory failure: %#lx: Failed to invalidate\n" ,
837- pfn );
837+ pr_info ("%#lx: Failed to invalidate\n" , pfn );
838838 }
839839
840840 return ret ;
@@ -864,7 +864,7 @@ static bool has_extra_refcount(struct page_state *ps, struct page *p,
864864 count -= 1 ;
865865
866866 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" ,
868868 page_to_pfn (p ), action_page_types [ps -> type ], count );
869869 return true;
870870 }
@@ -888,7 +888,7 @@ static int me_kernel(struct page_state *ps, struct page *p)
888888 */
889889static int me_unknown (struct page_state * ps , struct page * p )
890890{
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 ));
892892 unlock_page (p );
893893 return MF_FAILED ;
894894}
@@ -1173,7 +1173,7 @@ static void action_result(unsigned long pfn, enum mf_action_page_type type,
11731173 trace_memory_failure_event (pfn , type , result );
11741174
11751175 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" ,
11771177 pfn , action_page_types [type ], action_name [result ]);
11781178}
11791179
@@ -1248,8 +1248,7 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags)
12481248 if (head == compound_head (page ))
12491249 return 1 ;
12501250
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 ));
12531252 put_page (head );
12541253 }
12551254
@@ -1312,7 +1311,7 @@ static int get_any_page(struct page *p, unsigned long flags)
13121311 }
13131312out :
13141313 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 ));
13161315
13171316 return ret ;
13181317}
@@ -1411,13 +1410,12 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
14111410 return true;
14121411
14131412 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 );
14151414 return false;
14161415 }
14171416
14181417 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 );
14211419 ttu |= TTU_IGNORE_HWPOISON ;
14221420 }
14231421
@@ -1435,7 +1433,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
14351433 } else {
14361434 kill = 0 ;
14371435 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" ,
14391437 pfn );
14401438 }
14411439 }
@@ -1464,14 +1462,14 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
14641462 try_to_unmap (folio , ttu |TTU_RMAP_LOCKED );
14651463 i_mmap_unlock_write (mapping );
14661464 } 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 );
14681466 } else {
14691467 try_to_unmap (folio , ttu );
14701468 }
14711469
14721470 unmap_success = !page_mapped (hpage );
14731471 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" ,
14751473 pfn , page_mapcount (hpage ));
14761474
14771475 /*
@@ -1732,7 +1730,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
17321730 * hugetlb = 0 ;
17331731 return 0 ;
17341732 } else if (res == - EHWPOISON ) {
1735- pr_err ("Memory failure: %#lx: already hardware poisoned\n" , pfn );
1733+ pr_err ("%#lx: already hardware poisoned\n" , pfn );
17361734 if (flags & MF_ACTION_REQUIRED ) {
17371735 head = compound_head (p );
17381736 res = kill_accessing_process (current , page_to_pfn (head ), flags );
@@ -1901,8 +1899,7 @@ int memory_failure(unsigned long pfn, int flags)
19011899 goto unlock_mutex ;
19021900 }
19031901 }
1904- pr_err ("Memory failure: %#lx: memory outside kernel control\n" ,
1905- pfn );
1902+ pr_err ("%#lx: memory outside kernel control\n" , pfn );
19061903 res = - ENXIO ;
19071904 goto unlock_mutex ;
19081905 }
@@ -1913,8 +1910,7 @@ int memory_failure(unsigned long pfn, int flags)
19131910 goto unlock_mutex ;
19141911
19151912 if (TestSetPageHWPoison (p )) {
1916- pr_err ("Memory failure: %#lx: already hardware poisoned\n" ,
1917- pfn );
1913+ pr_err ("%#lx: already hardware poisoned\n" , pfn );
19181914 res = - EHWPOISON ;
19191915 if (flags & MF_ACTION_REQUIRED )
19201916 res = kill_accessing_process (current , pfn , flags );
@@ -2130,7 +2126,7 @@ void memory_failure_queue(unsigned long pfn, int flags)
21302126 if (kfifo_put (& mf_cpu -> fifo , entry ))
21312127 schedule_work_on (smp_processor_id (), & mf_cpu -> work );
21322128 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" ,
21342130 pfn );
21352131 spin_unlock_irqrestore (& mf_cpu -> lock , proc_flags );
21362132 put_cpu_var (memory_failure_cpu );
@@ -2187,6 +2183,8 @@ static int __init memory_failure_init(void)
21872183}
21882184core_initcall (memory_failure_init );
21892185
2186+ #undef pr_fmt
2187+ #define pr_fmt (fmt ) "" fmt
21902188#define unpoison_pr_info (fmt , pfn , rs ) \
21912189({ \
21922190 if (__ratelimit(rs)) \
0 commit comments