Blame SOURCES/b497a3d6a39d402c41065e9284d49114b97e3bfe.patch

81d547
commit b497a3d6a39d402c41065e9284d49114b97e3bfe
81d547
Author: Shiju Jose <shiju.jose@huawei.com>
81d547
Date:   Mon Mar 8 16:57:28 2021 +0000
81d547
81d547
    rasdaemon: ras-mc-ctl: Add memory failure events
81d547
    
81d547
    Add supporting memory failure errors (memory_failure_event)
81d547
    to the ras-mc-ctl tool.
81d547
    
81d547
    Sample Log,
81d547
    ras-mc-ctl --summary
81d547
    ...
81d547
    Memory failure events summary:
81d547
            Delayed errors: 4
81d547
            Failed errors: 1
81d547
    ...
81d547
    
81d547
    ras-mc-ctl --errors
81d547
    ...
81d547
    Memory failure events:
81d547
    1 2020-10-28 23:20:41 -0800 error: pfn=0x204000000, page_type=free buddy page, action_result=Delayed
81d547
    2 2020-10-28 23:31:38 -0800 error: pfn=0x204000000, page_type=free buddy page, action_result=Delayed
81d547
    3 2020-10-28 23:54:54 -0800 error: pfn=0x205000000, page_type=free buddy page, action_result=Delayed
81d547
    4 2020-10-29 00:12:25 -0800 error: pfn=0x204000000, page_type=free buddy page, action_result=Delayed
81d547
    5 2020-10-29 00:26:36 -0800 error: pfn=0x204000000, page_type=free buddy page, action_result=Failed
81d547
    
81d547
    Signed-off-by: Shiju Jose <shiju.jose@huawei.com>
81d547
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
81d547
81d547
---
81d547
 configure.ac       |   11 +++++++++++
81d547
 util/ras-mc-ctl.in |   46 +++++++++++++++++++++++++++++++++++++++++++---
81d547
 2 files changed, 54 insertions(+), 3 deletions(-)
81d547
81d547
--- a/util/ras-mc-ctl.in	2021-10-13 13:51:00.887292563 -0400
81d547
+++ b/util/ras-mc-ctl.in	2021-10-13 13:51:27.536061894 -0400
81d547
@@ -44,11 +44,13 @@ my $modprobe    = find_prog ("modprobe")
81d547
 my $has_aer = 0;
81d547
 my $has_arm = 0;
81d547
 my $has_extlog = 0;
81d547
+my $has_mem_failure = 0;
81d547
 my $has_mce = 0;
81d547
 
81d547
 @WITH_AER_TRUE@$has_aer = 1;
81d547
 @WITH_ARM_TRUE@$has_arm = 1;
81d547
 @WITH_EXTLOG_TRUE@$has_extlog = 1;
81d547
+@WITH_MEMORY_FAILURE_TRUE@$has_mem_failure = 1;
81d547
 @WITH_MCE_TRUE@$has_mce = 1;
81d547
 
81d547
 my %conf        = ();
81d547
@@ -1132,7 +1134,7 @@ sub summary
81d547
 {
81d547
     require DBI;
81d547
     my ($query, $query_handle, $out);
81d547
-    my ($err_type, $label, $mc, $top, $mid, $low, $count, $msg);
81d547
+    my ($err_type, $label, $mc, $top, $mid, $low, $count, $msg, $action_result);
81d547
     my ($etype, $severity, $etype_string, $severity_string);
81d547
     my ($affinity, $mpidr);
81d547
 
81d547
@@ -1203,9 +1205,27 @@ sub summary
81d547
             $out .= "\t$count $etype_string $severity_string errors\n";
81d547
         }
81d547
         if ($out ne "") {
81d547
-            print "Extlog records summary:\n$out";
81d547
+            print "Extlog records summary:\n$out\n";
81d547
         } else {
81d547
-            print "No Extlog errors.\n";
81d547
+            print "No Extlog errors.\n\n";
81d547
+        }
81d547
+        $query_handle->finish;
81d547
+    }
81d547
+
81d547
+    # Memory failure errors
81d547
+    if ($has_mem_failure == 1) {
81d547
+        $query = "select action_result, count(*) from memory_failure_event group by action_result";
81d547
+        $query_handle = $dbh->prepare($query);
81d547
+        $query_handle->execute();
81d547
+        $query_handle->bind_columns(\($action_result, $count));
81d547
+        $out = "";
81d547
+        while($query_handle->fetch()) {
81d547
+            $out .= "\t$action_result errors: $count\n";
81d547
+        }
81d547
+        if ($out ne "") {
81d547
+            print "Memory failure events summary:\n$out\n";
81d547
+        } else {
81d547
+            print "No Memory failure errors.\n\n";
81d547
         }
81d547
         $query_handle->finish;
81d547
     }
81d547
@@ -1238,6 +1258,7 @@ sub errors
81d547
     my ($mcgcap,$mcgstatus, $status, $misc, $ip, $tsc, $walltime, $cpu, $cpuid, $apicid, $socketid, $cs, $bank, $cpuvendor, $bank_name, $mcgstatus_msg, $mcistatus_msg, $user_action, $mc_location);
81d547
     my ($timestamp, $etype, $severity, $etype_string, $severity_string, $fru_id, $fru_text, $cper_data);
81d547
     my ($error_count, $affinity, $mpidr, $r_state, $psci_state);
81d547
+    my ($pfn, $page_type, $action_result);
81d547
 
81d547
     my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "", {});
81d547
 
81d547
@@ -1329,6 +1350,25 @@ $out .= sprintf "address=0x%08x, ", $add
81d547
         }
81d547
         $query_handle->finish;
81d547
     }
81d547
+
81d547
+    # Memory failure errors
81d547
+    if ($has_mem_failure == 1) {
81d547
+        $query = "select id, timestamp, pfn, page_type, action_result from memory_failure_event order by id";
81d547
+        $query_handle = $dbh->prepare($query);
81d547
+        $query_handle->execute();
81d547
+        $query_handle->bind_columns(\($id, $timestamp, $pfn, $page_type, $action_result));
81d547
+        $out = "";
81d547
+        while($query_handle->fetch()) {
81d547
+            $out .= "$id $timestamp error: ";
81d547
+            $out .= "pfn=$pfn, page_type=$page_type, action_result=$action_result\n";
81d547
+        }
81d547
+        if ($out ne "") {
81d547
+            print "Memory failure events:\n$out\n";
81d547
+        } else {
81d547
+            print "No Memory failure errors.\n\n";
81d547
+        }
81d547
+        $query_handle->finish;
81d547
+    }
81d547
 
81d547
     # MCE mce_record errors
81d547
     if ($has_mce == 1) {
81d547
--- a/configure.ac	2018-04-25 06:28:51.000000000 -0400
81d547
+++ b/configure.ac	2021-10-13 13:51:00.916292312 -0400
81d547
@@ -80,6 +80,16 @@ AS_IF([test "x$enable_extlog" = "xyes"],
81d547
 ])
81d547
 AM_CONDITIONAL([WITH_EXTLOG], [test x$enable_extlog = xyes])
81d547
 
81d547
+AC_ARG_ENABLE([memory_failure],
81d547
+    AS_HELP_STRING([--enable-memory-failure], [enable memory failure events (currently experimental)]))
81d547
+
81d547
+AS_IF([test "x$enable_memory_failure" = "xyes" || test "x$enable_all" == "xyes"], [
81d547
+  AC_DEFINE(HAVE_MEMORY_FAILURE,1,"have memory failure events collect")
81d547
+  AC_SUBST([WITH_MEMORY_FAILURE])
81d547
+])
81d547
+AM_CONDITIONAL([WITH_MEMORY_FAILURE], [test x$enable_memory_failure = xyes || test x$enable_all == xyes])
81d547
+AM_COND_IF([WITH_MEMORY_FAILURE], [USE_MEMORY_FAILURE="yes"], [USE_MEMORY_FAILURE="no"])
81d547
+
81d547
 AC_ARG_ENABLE([abrt_report],
81d547
     AS_HELP_STRING([--enable-abrt-report], [enable report event to ABRT (currently experimental)]))
81d547
 
81d547
@@ -127,4 +137,5 @@ compile time options summary
81d547
     ABRT report         : $enable_abrt_report
81d547
     HIP07 SAS HW errors : $enable_hisi_ns_decode
81d547
     ARM events          : $enable_arm
81d547
+    Memory Failure      : $USE_MEMORY_FAILURE
81d547
 EOF