[PATCH v1 10/19] ACPI: extlog: Simplify fatal record printing
From: Pierre Gondois
Date: Tue Nov 17 2026 - 06:19:36 EST
Only fatal CPER records reach print_extlog_rcd().
Merge the two helpers, remove the unused prefix argument
and return value, and keep a single rate limiter.
Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx>
---
drivers/acpi/acpi_extlog.c | 39 ++++++++------------------------------
1 file changed, 8 insertions(+), 31 deletions(-)
diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index 16a16b12d8ccf..1782a19eb474b 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -95,46 +95,23 @@ static struct acpi_hest_generic_status *extlog_elog_entry_check(int cpu, int ban
return estatus;
}
-static void __print_extlog_rcd(const char *pfx,
- struct acpi_hest_generic_status *estatus, int cpu)
+static void print_extlog_rcd(struct acpi_hest_generic_status *estatus, int cpu)
{
+ /* Not more than 2 messages every 5 seconds */
+ static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 2);
static atomic_t seqno;
unsigned int curr_seqno;
char pfx_seq[64];
- if (!pfx) {
- if (estatus->error_severity <= CPER_SEV_CORRECTED)
- pfx = KERN_INFO;
- else
- pfx = KERN_ERR;
- }
+ if (!__ratelimit(&ratelimit))
+ return;
+
curr_seqno = atomic_inc_return(&seqno);
- snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}", pfx, curr_seqno);
+ snprintf(pfx_seq, sizeof(pfx_seq), KERN_ERR "{%u}", curr_seqno);
printk("%s""Hardware error detected on CPU%d\n", pfx_seq, cpu);
cper_estatus_print(pfx_seq, estatus);
}
-static int print_extlog_rcd(const char *pfx,
- struct acpi_hest_generic_status *estatus, int cpu)
-{
- /* Not more than 2 messages every 5 seconds */
- static DEFINE_RATELIMIT_STATE(ratelimit_corrected, 5*HZ, 2);
- static DEFINE_RATELIMIT_STATE(ratelimit_uncorrected, 5*HZ, 2);
- struct ratelimit_state *ratelimit;
-
- if (estatus->error_severity == CPER_SEV_CORRECTED ||
- (estatus->error_severity == CPER_SEV_INFORMATIONAL))
- ratelimit = &ratelimit_corrected;
- else
- ratelimit = &ratelimit_uncorrected;
- if (__ratelimit(ratelimit)) {
- __print_extlog_rcd(pfx, estatus, cpu);
- return 0;
- }
-
- return 1;
-}
-
static void extlog_print_pcie(struct acpi_hest_generic_data *gdata)
{
#ifdef CONFIG_ACPI_APEI_PCIEAER
@@ -210,7 +187,7 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,
/* Print fatal records regardless of RAS consumer registration. */
if (tmp->error_severity == CPER_SEV_FATAL)
- print_extlog_rcd(NULL, tmp, cpu);
+ print_extlog_rcd(tmp, cpu);
/* log event via trace */
err_seq++;
--
2.43.0