|
|
97e186 |
From 0a31d938cf29e065e96de1206a7d35042962e02a Mon Sep 17 00:00:00 2001
|
|
|
97e186 |
From: Mauro Carvalho Chehab <mchehab@redhat.com>
|
|
|
97e186 |
Date: Fri, 31 May 2013 14:18:24 -0300
|
|
|
97e186 |
Subject: [PATCH 07/32] Add support to store MCE events at the database
|
|
|
97e186 |
|
|
|
97e186 |
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
|
|
|
97e186 |
---
|
|
|
97e186 |
ras-mce-handler.c | 5 +++
|
|
|
97e186 |
ras-record.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
97e186 |
ras-record.h | 9 +++++
|
|
|
97e186 |
3 files changed, 116 insertions(+), 2 deletions(-)
|
|
|
97e186 |
|
|
|
97e186 |
diff --git a/ras-mce-handler.c b/ras-mce-handler.c
|
|
|
97e186 |
index 614a0eb..59e8d05 100644
|
|
|
97e186 |
--- a/ras-mce-handler.c
|
|
|
97e186 |
+++ b/ras-mce-handler.c
|
|
|
97e186 |
@@ -396,5 +396,10 @@ int ras_mce_event_handler(struct trace_seq *s,
|
|
|
97e186 |
return rc;
|
|
|
97e186 |
|
|
|
97e186 |
report_mce_event(ras, record, s, &e);
|
|
|
97e186 |
+
|
|
|
97e186 |
+#ifdef HAVE_SQLITE3
|
|
|
97e186 |
+ ras_store_mce_record(ras, &e);
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
}
|
|
|
97e186 |
diff --git a/ras-record.c b/ras-record.c
|
|
|
97e186 |
index cb302ce..daa3cb1 100644
|
|
|
97e186 |
--- a/ras-record.c
|
|
|
97e186 |
+++ b/ras-record.c
|
|
|
97e186 |
@@ -27,6 +27,7 @@
|
|
|
97e186 |
#include "ras-events.h"
|
|
|
97e186 |
#include "ras-mc-handler.h"
|
|
|
97e186 |
#include "ras-aer-handler.h"
|
|
|
97e186 |
+#include "ras-mce-handler.h"
|
|
|
97e186 |
#include "ras-logger.h"
|
|
|
97e186 |
|
|
|
97e186 |
/* #define DEBUG_SQL 1 */
|
|
|
97e186 |
@@ -135,7 +136,7 @@ int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
|
|
|
97e186 |
|
|
|
97e186 |
if (!priv || !priv->stmt_aer_event)
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
- log(TERM, LOG_INFO, "mc_event store: %p\n", priv->stmt_aer_event);
|
|
|
97e186 |
+ log(TERM, LOG_INFO, "aer_event store: %p\n", priv->stmt_aer_event);
|
|
|
97e186 |
|
|
|
97e186 |
sqlite3_bind_text(priv->stmt_aer_event, 1, ev->timestamp, -1, NULL);
|
|
|
97e186 |
sqlite3_bind_text(priv->stmt_aer_event, 3, ev->error_type, -1, NULL);
|
|
|
97e186 |
@@ -156,6 +157,98 @@ int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev)
|
|
|
97e186 |
}
|
|
|
97e186 |
#endif
|
|
|
97e186 |
|
|
|
97e186 |
+
|
|
|
97e186 |
+/*
|
|
|
97e186 |
+ * Table and functions to handle mce:mce_record
|
|
|
97e186 |
+ */
|
|
|
97e186 |
+
|
|
|
97e186 |
+#ifdef HAVE_MCE
|
|
|
97e186 |
+static const struct db_fields mce_record_fields[] = {
|
|
|
97e186 |
+ { .name="id", .type="INTEGER PRIMARY KEY" },
|
|
|
97e186 |
+ { .name="timestamp", .type="TEXT" },
|
|
|
97e186 |
+
|
|
|
97e186 |
+ /* MCE registers */
|
|
|
97e186 |
+ { .name="mcgcap", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="mcgstatus", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="status", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="addr", .type="INTEGER" }, // 5
|
|
|
97e186 |
+ { .name="misc", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="ip", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="tsc", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="walltime", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="cpu", .type="INTEGER" }, // 10
|
|
|
97e186 |
+ { .name="cpuid", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="apicid", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="socketid", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="cs", .type="INTEGER" },
|
|
|
97e186 |
+ { .name="bank", .type="INTEGER" }, //15
|
|
|
97e186 |
+ { .name="cpuvendor", .type="INTEGER" },
|
|
|
97e186 |
+
|
|
|
97e186 |
+ /* Parsed data - will likely change */
|
|
|
97e186 |
+ { .name="bank_name", .type="TEXT" },
|
|
|
97e186 |
+ { .name="error_msg", .type="TEXT" },
|
|
|
97e186 |
+ { .name="mcgstatus_msg", .type="TEXT" },
|
|
|
97e186 |
+ { .name="mcistatus_msg", .type="TEXT" }, // 20
|
|
|
97e186 |
+ { .name="user_action", .type="TEXT" },
|
|
|
97e186 |
+ { .name="mc_location", .type="TEXT" },
|
|
|
97e186 |
+};
|
|
|
97e186 |
+
|
|
|
97e186 |
+static const struct db_table_descriptor mce_record_tab = {
|
|
|
97e186 |
+ .name = "mce_record",
|
|
|
97e186 |
+ .fields = mce_record_fields,
|
|
|
97e186 |
+ .num_fields = ARRAY_SIZE(mce_record_fields),
|
|
|
97e186 |
+};
|
|
|
97e186 |
+
|
|
|
97e186 |
+int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev)
|
|
|
97e186 |
+{
|
|
|
97e186 |
+ int rc;
|
|
|
97e186 |
+ struct sqlite3_priv *priv = ras->db_priv;
|
|
|
97e186 |
+
|
|
|
97e186 |
+ if (!priv || !priv->stmt_mce_record)
|
|
|
97e186 |
+ return 0;
|
|
|
97e186 |
+ log(TERM, LOG_INFO, "mce_record store: %p\n", priv->stmt_mce_record);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 1, ev->timestamp, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 2, ev->mcgcap);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 3, ev->mcgstatus);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 4, ev->status);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 5, ev->addr);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 6, ev->misc);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 7, ev->ip);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 8, ev->tsc);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 9, ev->walltime);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 10, ev->cpu);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 11, ev->cpuid);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 12, ev->apicid);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 13, ev->socketid);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 14, ev->cs);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 15, ev->bank);
|
|
|
97e186 |
+ sqlite3_bind_int (priv->stmt_mce_record, 16, ev->cpuvendor);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 17, ev->bank_name, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 18, ev->error_msg, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 19, ev->mcgstatus_msg, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 20, ev->mcistatus_msg, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 21, ev->mcastatus_msg, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 22, ev->user_action, -1, NULL);
|
|
|
97e186 |
+ sqlite3_bind_text(priv->stmt_mce_record, 23, ev->mc_location, -1, NULL);
|
|
|
97e186 |
+
|
|
|
97e186 |
+ rc = sqlite3_step(priv->stmt_mce_record);
|
|
|
97e186 |
+ if (rc != SQLITE_OK && rc != SQLITE_DONE)
|
|
|
97e186 |
+ log(TERM, LOG_ERR,
|
|
|
97e186 |
+ "Failed to do mce_record step on sqlite: error = %d\n", rc);
|
|
|
97e186 |
+ rc = sqlite3_reset(priv->stmt_mce_record);
|
|
|
97e186 |
+ if (rc != SQLITE_OK && rc != SQLITE_DONE)
|
|
|
97e186 |
+ log(TERM, LOG_ERR,
|
|
|
97e186 |
+ "Failed reset mce_record on sqlite: error = %d\n",
|
|
|
97e186 |
+ rc);
|
|
|
97e186 |
+ log(TERM, LOG_INFO, "register inserted at db\n");
|
|
|
97e186 |
+
|
|
|
97e186 |
+ return rc;
|
|
|
97e186 |
+}
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
+
|
|
|
97e186 |
/*
|
|
|
97e186 |
* Generic code
|
|
|
97e186 |
*/
|
|
|
97e186 |
@@ -291,6 +384,13 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras)
|
|
|
97e186 |
&aer_event_tab);
|
|
|
97e186 |
#endif
|
|
|
97e186 |
|
|
|
97e186 |
- ras->db_priv = priv;
|
|
|
97e186 |
+#ifdef HAVE_MCE
|
|
|
97e186 |
+ rc = ras_mc_create_table(priv, &mce_record_tab);
|
|
|
97e186 |
+ if (rc == SQLITE_OK)
|
|
|
97e186 |
+ rc = ras_mc_prepare_stmt(priv, &priv->stmt_mce_record,
|
|
|
97e186 |
+ &mce_record_tab);
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
+
|
|
|
97e186 |
+ ras->db_priv = priv;
|
|
|
97e186 |
return 0;
|
|
|
97e186 |
}
|
|
|
97e186 |
diff --git a/ras-record.h b/ras-record.h
|
|
|
97e186 |
index 5008906..6f146a8 100644
|
|
|
97e186 |
--- a/ras-record.h
|
|
|
97e186 |
+++ b/ras-record.h
|
|
|
97e186 |
@@ -40,6 +40,10 @@ struct ras_aer_event {
|
|
|
97e186 |
const char *msg;
|
|
|
97e186 |
};
|
|
|
97e186 |
|
|
|
97e186 |
+struct ras_mc_event;
|
|
|
97e186 |
+struct ras_aer_event;
|
|
|
97e186 |
+struct mce_event;
|
|
|
97e186 |
+
|
|
|
97e186 |
#ifdef HAVE_SQLITE3
|
|
|
97e186 |
|
|
|
97e186 |
#include <sqlite3.h>
|
|
|
97e186 |
@@ -50,16 +54,21 @@ struct sqlite3_priv {
|
|
|
97e186 |
#ifdef HAVE_AER
|
|
|
97e186 |
sqlite3_stmt *stmt_aer_event;
|
|
|
97e186 |
#endif
|
|
|
97e186 |
+#ifdef HAVE_MCE
|
|
|
97e186 |
+ sqlite3_stmt *stmt_mce_record;
|
|
|
97e186 |
+#endif
|
|
|
97e186 |
};
|
|
|
97e186 |
|
|
|
97e186 |
int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras);
|
|
|
97e186 |
int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev);
|
|
|
97e186 |
int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev);
|
|
|
97e186 |
+int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev);
|
|
|
97e186 |
|
|
|
97e186 |
#else
|
|
|
97e186 |
static inline int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras) { return 0; };
|
|
|
97e186 |
static inline int ras_store_mc_event(struct ras_events *ras, struct ras_mc_event *ev) { return 0; };
|
|
|
97e186 |
static inline int ras_store_aer_event(struct ras_events *ras, struct ras_aer_event *ev) { return 0; };
|
|
|
97e186 |
+static inline int ras_store_mce_record(struct ras_events *ras, struct mce_event *ev) { return 0; };
|
|
|
97e186 |
|
|
|
97e186 |
#endif
|
|
|
97e186 |
|
|
|
97e186 |
--
|
|
|
97e186 |
1.7.1
|
|
|
97e186 |
|