krishnanadh / rpms / rasdaemon

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