Re: [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry
From: Pierre Gondois
Date: Wed Nov 18 2026 - 10:10:58 EST
Hello Lukas,
On 11/17/26 12:44, Lukas Wunner wrote:
On Tue, Nov 17, 2026 at 12:10:15PM +0100, Pierre Gondois wrote:
commit e2abc47a5a1a ("ACPI: APEI: Fix AER info corruption when errorSince commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"),
status data has multiple sections") passed to aer_recover_queue() a
newly allocated copy of pcie_err->aer_info instead of providing a
pointer to the ghes struct. This prevented corruptions of the ghes
record (in case the ghes record was re-used for a new error before
the previous error was logged).
aer_regs is modified for a recursive invocation of __pci_print_aer().
The copy is necessary because we don't want to modify a buffer owned by
platform firmware.
+++ b/drivers/pci/pcie/aer.cThis increases stack usage significantly in aer_recover_queue(),
@@ -1352,7 +1352,7 @@ struct aer_recover_entry {
u8 devfn;
u16 domain;
int severity;
- struct aer_capability_regs *regs;
+ struct aer_capability_regs regs;
};
which is not good. A kzalloc() allocation may be better suited
for such a large struct, instead of relying on the stack.
@@ -1374,24 +1374,14 @@ static void aer_recover_work_func(struct work_struct *work)So you're removing the call to ghes_estatus_pool_region_free() from the
PCI_SLOT(entry.devfn),
PCI_FUNC(entry.devfn));
else
- pci_print_aer(pdev, entry.severity, entry.regs);
+ pci_print_aer(pdev, entry.severity, &entry.regs);
- regs = entry.regs;
+ regs = &entry.regs;
if (entry.severity == AER_CORRECTABLE)
err = regs->cor_status & ~regs->cor_mask;
else
err = regs->uncor_status & ~regs->uncor_mask;
- /*
- * Memory for aer_capability_regs(entry.regs) is being
- * allocated from the ghes_estatus_pool to protect it from
- * overwriting when multiple sections are present in the
- * error status. Thus free the same after processing the
- * data.
- */
- ghes_estatus_pool_region_free((unsigned long)entry.regs,
- sizeof(struct aer_capability_regs));
-
worker...
@@ -1441,17 +1431,18 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,... and instead call it earlier, before even launching the worker.
.devfn = devfn,
.domain = domain,
.severity = severity,
- .regs = aer_regs,
+ .regs = *aer_regs,
};
+ ghes_estatus_pool_region_free((unsigned long)aer_regs,
+ sizeof(struct aer_capability_regs));
+
So where's the benefit? You've traded less memory usage in the
pool for higher stack usage. How is that useful?
This patch is an intermediate step toward:
[PATCH v1 06/19] ACPI: APEI: Remove aer allocation in ghes_handle_aer()
The final goal of these 2 patches being to remove the dependency
of ghes_handle_aer() over the ghes_estatus_pool. Just using kzallac() should
work aswell I think.