krishnanadh / rpms / rasdaemon

Forked from rpms/rasdaemon a year ago
Clone

Blame SOURCES/b497a3d6a39d402c41065e9284d49114b97e3bfe.patch

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