aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memory-failure.c
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2015-11-05 21:47:26 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-11-05 22:34:48 -0500
commita5f65109026b35b654b94fdcd26a971185a53adc (patch)
tree8367ff9f1496ed3cbb8228a1266c5a924cb9b394 /mm/memory-failure.c
parentaa750fd71c242dba02ee2034e15fbd7d0cdb2461 (diff)
mm: hwpoison: ratelimit messages from unpoison_memory()
Currently kernel prints out results of every single unpoison event, which i= s not necessary because unpoison is purely a testing feature and testers can = get little or no information from lots of lines of unpoison log storm. So this patch ratelimits printk in unpoison_memory(). This patch introduces a file local ratelimit_state, which adds 64 bytes to memory-failure.o. If we apply pr_info_ratelimited() for 8 callsite below, 2= 56 bytes is added, so it's a win. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Wanpeng Li <wanpeng.li@hotmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory-failure.c')
-rw-r--r--mm/memory-failure.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 95882692e747..16a0ec385320 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -56,6 +56,7 @@
56#include <linux/memory_hotplug.h> 56#include <linux/memory_hotplug.h>
57#include <linux/mm_inline.h> 57#include <linux/mm_inline.h>
58#include <linux/kfifo.h> 58#include <linux/kfifo.h>
59#include <linux/ratelimit.h>
59#include "internal.h" 60#include "internal.h"
60#include "ras/ras_event.h" 61#include "ras/ras_event.h"
61 62
@@ -1403,6 +1404,12 @@ static int __init memory_failure_init(void)
1403} 1404}
1404core_initcall(memory_failure_init); 1405core_initcall(memory_failure_init);
1405 1406
1407#define unpoison_pr_info(fmt, pfn, rs) \
1408({ \
1409 if (__ratelimit(rs)) \
1410 pr_info(fmt, pfn); \
1411})
1412
1406/** 1413/**
1407 * unpoison_memory - Unpoison a previously poisoned page 1414 * unpoison_memory - Unpoison a previously poisoned page
1408 * @pfn: Page number of the to be unpoisoned page 1415 * @pfn: Page number of the to be unpoisoned page
@@ -1421,6 +1428,8 @@ int unpoison_memory(unsigned long pfn)
1421 struct page *p; 1428 struct page *p;
1422 int freeit = 0; 1429 int freeit = 0;
1423 unsigned int nr_pages; 1430 unsigned int nr_pages;
1431 static DEFINE_RATELIMIT_STATE(unpoison_rs, DEFAULT_RATELIMIT_INTERVAL,
1432 DEFAULT_RATELIMIT_BURST);
1424 1433
1425 if (!pfn_valid(pfn)) 1434 if (!pfn_valid(pfn))
1426 return -ENXIO; 1435 return -ENXIO;
@@ -1429,23 +1438,26 @@ int unpoison_memory(unsigned long pfn)
1429 page = compound_head(p); 1438 page = compound_head(p);
1430 1439
1431 if (!PageHWPoison(p)) { 1440 if (!PageHWPoison(p)) {
1432 pr_info("MCE: Page was already unpoisoned %#lx\n", pfn); 1441 unpoison_pr_info("MCE: Page was already unpoisoned %#lx\n",
1442 pfn, &unpoison_rs);
1433 return 0; 1443 return 0;
1434 } 1444 }
1435 1445
1436 if (page_count(page) > 1) { 1446 if (page_count(page) > 1) {
1437 pr_info("MCE: Someone grabs the hwpoison page %#lx\n", pfn); 1447 unpoison_pr_info("MCE: Someone grabs the hwpoison page %#lx\n",
1448 pfn, &unpoison_rs);
1438 return 0; 1449 return 0;
1439 } 1450 }
1440 1451
1441 if (page_mapped(page)) { 1452 if (page_mapped(page)) {
1442 pr_info("MCE: Someone maps the hwpoison page %#lx\n", pfn); 1453 unpoison_pr_info("MCE: Someone maps the hwpoison page %#lx\n",
1454 pfn, &unpoison_rs);
1443 return 0; 1455 return 0;
1444 } 1456 }
1445 1457
1446 if (page_mapping(page)) { 1458 if (page_mapping(page)) {
1447 pr_info("MCE: the hwpoison page has non-NULL mapping %#lx\n", 1459 unpoison_pr_info("MCE: the hwpoison page has non-NULL mapping %#lx\n",
1448 pfn); 1460 pfn, &unpoison_rs);
1449 return 0; 1461 return 0;
1450 } 1462 }
1451 1463
@@ -1455,7 +1467,8 @@ int unpoison_memory(unsigned long pfn)
1455 * In such case, we yield to memory_failure() and make unpoison fail. 1467 * In such case, we yield to memory_failure() and make unpoison fail.
1456 */ 1468 */
1457 if (!PageHuge(page) && PageTransHuge(page)) { 1469 if (!PageHuge(page) && PageTransHuge(page)) {
1458 pr_info("MCE: Memory failure is now running on %#lx\n", pfn); 1470 unpoison_pr_info("MCE: Memory failure is now running on %#lx\n",
1471 pfn, &unpoison_rs);
1459 return 0; 1472 return 0;
1460 } 1473 }
1461 1474
@@ -1469,12 +1482,14 @@ int unpoison_memory(unsigned long pfn)
1469 * to the end. 1482 * to the end.
1470 */ 1483 */
1471 if (PageHuge(page)) { 1484 if (PageHuge(page)) {
1472 pr_info("MCE: Memory failure is now running on free hugepage %#lx\n", pfn); 1485 unpoison_pr_info("MCE: Memory failure is now running on free hugepage %#lx\n",
1486 pfn, &unpoison_rs);
1473 return 0; 1487 return 0;
1474 } 1488 }
1475 if (TestClearPageHWPoison(p)) 1489 if (TestClearPageHWPoison(p))
1476 num_poisoned_pages_dec(); 1490 num_poisoned_pages_dec();
1477 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn); 1491 unpoison_pr_info("MCE: Software-unpoisoned free page %#lx\n",
1492 pfn, &unpoison_rs);
1478 return 0; 1493 return 0;
1479 } 1494 }
1480 1495
@@ -1486,7 +1501,8 @@ int unpoison_memory(unsigned long pfn)
1486 * the free buddy page pool. 1501 * the free buddy page pool.
1487 */ 1502 */
1488 if (TestClearPageHWPoison(page)) { 1503 if (TestClearPageHWPoison(page)) {
1489 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn); 1504 unpoison_pr_info("MCE: Software-unpoisoned page %#lx\n",
1505 pfn, &unpoison_rs);
1490 num_poisoned_pages_sub(nr_pages); 1506 num_poisoned_pages_sub(nr_pages);
1491 freeit = 1; 1507 freeit = 1;
1492 if (PageHuge(page)) 1508 if (PageHuge(page))