From: Mauro Carvalho Chehab Date: Sat, 18 May 2013 08:23:48 +0000 (-0300) Subject: mce-intel: simplify code and add an user_action field X-Git-Tag: v0.3.0~22 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e85d143053694e1fa0f788910c2ac3d1f6e227d8;p=users%2Fmchehab%2Frasdaemon.git mce-intel: simplify code and add an user_action field While for pure print messages, the user recommended action can be together with the error message, having it in a separate field helps to latter handle the error. So, split it. Signed-off-by: Mauro Carvalho Chehab --- diff --git a/mce-intel.c b/mce-intel.c index c5ab42c..fc03e8b 100644 --- a/mce-intel.c +++ b/mce-intel.c @@ -29,10 +29,12 @@ static decode_termal_bank(struct mce_event *e) { - if (e->status & 1) - sprintf(e->error_msg, "Processor %d heated above trip temperature. Throttling enabled. Please check your system cooling. Performance will be impacted", e->cpu); - else + if (e->status & 1) { + mce_snprintf(e->mcgstatus_msg, "Processor %d heated above trip temperature. Throttling enabled.", e->cpu); + mce_snprintf(e->user_action, "Please check your system cooling. Performance will be impacted"); + } else { sprintf(e->error_msg, "Processor %d below trip temperature. Throttling disabled", e->cpu); + } } static void decode_mcg(struct mce_event *e) @@ -41,23 +43,14 @@ static void decode_mcg(struct mce_event *e) uint64_t mcgstatus = e->mcgstatus; char *p = e->mcgstatus_msg; - n = snprintf(p, len, "mcgstatus= %d ", e->mcgstatus); + mce_snprintf(e->mcgstatus_msg, "mcgstatus= %d", e->mcgstatus); - if (mcgstatus & MCG_STATUS_RIPV) { - n = snprintf(p, len, " RIPV"); - p += n; - len -= n; - } - if (mcgstatus & MCG_STATUS_EIPV) { - n = snprintf(p, len, " EIPV"); - p += n; - len -= n; - } - if (mcgstatus & MCG_STATUS_MCIP) { - n = snprintf(p, len, " MCIP"); - p += n; - len -= n; - } + if (mcgstatus & MCG_STATUS_RIPV) + mce_snprintf(e->mcgstatus_msg, "RIPV"); + if (mcgstatus & MCG_STATUS_EIPV) + mce_snprintf(e->mcgstatus_msg, "EIPV"); + if (mcgstatus & MCG_STATUS_MCIP) + mce_snprintf(e->mcgstatus_msg, "MCIP"); } static void bank_name(struct mce_event *e) diff --git a/ras-mce-handler.c b/ras-mce-handler.c index 5b27034..a8b4379 100644 --- a/ras-mce-handler.c +++ b/ras-mce-handler.c @@ -272,6 +272,9 @@ static void report_mce_event(struct ras_events *ras, if (*e->error_msg) trace_seq_printf(s, ", %s", e->error_msg); + if (*e->user_action) + trace_seq_printf(s, " %s", e->user_action); + #if 0 /* * While the logic for decoding tsc is there at mcelog, why to diff --git a/ras-mce-handler.h b/ras-mce-handler.h index e1fc51d..2327a28 100644 --- a/ras-mce-handler.h +++ b/ras-mce-handler.h @@ -67,6 +67,7 @@ struct mce_event { char bank_name[64]; char error_msg[4096]; char mcgstatus_msg[256]; + char user_action[4096]; }; struct mce_priv {