[PATCH v3 0/3] ACPI: APEI: GHES: Performance improvements for error notification handlers

Shuai Xue posted 3 patches 3 weeks, 6 days ago
drivers/acpi/apei/ghes.c | 107 ++++++++++++++++++++++++++++++++++++---
include/acpi/ghes.h      |   1 +
2 files changed, 102 insertions(+), 6 deletions(-)
[PATCH v3 0/3] ACPI: APEI: GHES: Performance improvements for error notification handlers
Posted by Shuai Xue 3 weeks, 6 days ago
changes since v2:
- Use `guard(rcu)()` instead of explicit `rcu_read_lock()`/`rcu_read_unlock()` per Donglin Peng

changes since v1:
- add Tested-by and Reviewed-by tags from Tony
- change return value from AE_BAD_ADDRESS to -EINVAL ghes_map_error_status per Hanjun
- remove unnecessary blank lines per Hanjun

This patch series improves the performance of GHES error notification handlers
(NMI and SEA) by optimizing how they check for active error conditions.

Currently, both ghes_notify_nmi() and ghes_notify_sea() perform expensive
operations on each invocation to determine if there are actual error records
to process. This includes mapping/unmapping physical addresses and accessing
hardware registers, which causes significant overhead especially on systems
with many cores.

The optimizations introduced in this series:
1. Pre-map error status registers during initialization
2. Directly check for active errors using mapped virtual addresses
3. Extract common functionality into reusable helper functions
4. Apply the same optimization to both NMI and SEA handlers

These changes significantly reduce the overhead of error checking:
- NMI handler: From ~15,000 TSC cycles to ~900 cycles
- SEA handler: From 8,138.3 ns to a much faster check

The initial idea for this optimization came from Tony Luck [1], who identified
and implemented the approach for the NMI handler. This series extends the
same concept to the SEA handler and refactors common code into shared helpers.

Patch 1 (Tony Luck): Improves ghes_notify_nmi() status check by pre-mapping
                     error status registers and avoiding repeated mappings.

Patch 2 (Shuai Xue): Extracts common helper functions for error status handling
                     to eliminate code duplication.

Patch 3 (Shuai Xue): Applies the same optimization to ghes_notify_sea() to improve
                     ARMv8 system performance.

https://lore.kernel.org/lkml/20251103230547.8715-1-tony.luck@intel.com/

Shuai Xue (2):
  ACPI: APEI: GHES: Extract helper functions for error status handling
  ACPI: APEI: GHES: Improve ghes_notify_sea() status check

Tony Luck (1):
  ACPI: APEI: GHES: Improve ghes_notify_nmi() status check

 drivers/acpi/apei/ghes.c | 107 ++++++++++++++++++++++++++++++++++++---
 include/acpi/ghes.h      |   1 +
 2 files changed, 102 insertions(+), 6 deletions(-)

-- 
2.39.3
Re: [PATCH v3 0/3] ACPI: APEI: GHES: Performance improvements for error notification handlers
Posted by Hanjun Guo 3 weeks, 5 days ago
On 2026/1/12 11:22, Shuai Xue wrote:
> changes since v2:
> - Use `guard(rcu)()` instead of explicit `rcu_read_lock()`/`rcu_read_unlock()` per Donglin Peng
> 
> changes since v1:
> - add Tested-by and Reviewed-by tags from Tony
> - change return value from AE_BAD_ADDRESS to -EINVAL ghes_map_error_status per Hanjun
> - remove unnecessary blank lines per Hanjun
> 
> This patch series improves the performance of GHES error notification handlers
> (NMI and SEA) by optimizing how they check for active error conditions.
> 
> Currently, both ghes_notify_nmi() and ghes_notify_sea() perform expensive
> operations on each invocation to determine if there are actual error records
> to process. This includes mapping/unmapping physical addresses and accessing
> hardware registers, which causes significant overhead especially on systems
> with many cores.
> 
> The optimizations introduced in this series:
> 1. Pre-map error status registers during initialization
> 2. Directly check for active errors using mapped virtual addresses
> 3. Extract common functionality into reusable helper functions
> 4. Apply the same optimization to both NMI and SEA handlers
> 
> These changes significantly reduce the overhead of error checking:
> - NMI handler: From ~15,000 TSC cycles to ~900 cycles
> - SEA handler: From 8,138.3 ns to a much faster check
> 
> The initial idea for this optimization came from Tony Luck [1], who identified
> and implemented the approach for the NMI handler. This series extends the
> same concept to the SEA handler and refactors common code into shared helpers.
> 
> Patch 1 (Tony Luck): Improves ghes_notify_nmi() status check by pre-mapping
>                       error status registers and avoiding repeated mappings.
> 
> Patch 2 (Shuai Xue): Extracts common helper functions for error status handling
>                       to eliminate code duplication.
> 
> Patch 3 (Shuai Xue): Applies the same optimization to ghes_notify_sea() to improve
>                       ARMv8 system performance.

Looks good to me, and did a simple compile test on both x86 and arm64
machine,

Reviewed-by: Hanjun Guo <guohanjun@huawei.com>

Thanks
Hanjun
Re: [PATCH v3 0/3] ACPI: APEI: GHES: Performance improvements for error notification handlers
Posted by Rafael J. Wysocki 3 weeks, 3 days ago
On Mon, Jan 12, 2026 at 12:12 PM Hanjun Guo <guohanjun@huawei.com> wrote:
>
> On 2026/1/12 11:22, Shuai Xue wrote:
> > changes since v2:
> > - Use `guard(rcu)()` instead of explicit `rcu_read_lock()`/`rcu_read_unlock()` per Donglin Peng
> >
> > changes since v1:
> > - add Tested-by and Reviewed-by tags from Tony
> > - change return value from AE_BAD_ADDRESS to -EINVAL ghes_map_error_status per Hanjun
> > - remove unnecessary blank lines per Hanjun
> >
> > This patch series improves the performance of GHES error notification handlers
> > (NMI and SEA) by optimizing how they check for active error conditions.
> >
> > Currently, both ghes_notify_nmi() and ghes_notify_sea() perform expensive
> > operations on each invocation to determine if there are actual error records
> > to process. This includes mapping/unmapping physical addresses and accessing
> > hardware registers, which causes significant overhead especially on systems
> > with many cores.
> >
> > The optimizations introduced in this series:
> > 1. Pre-map error status registers during initialization
> > 2. Directly check for active errors using mapped virtual addresses
> > 3. Extract common functionality into reusable helper functions
> > 4. Apply the same optimization to both NMI and SEA handlers
> >
> > These changes significantly reduce the overhead of error checking:
> > - NMI handler: From ~15,000 TSC cycles to ~900 cycles
> > - SEA handler: From 8,138.3 ns to a much faster check
> >
> > The initial idea for this optimization came from Tony Luck [1], who identified
> > and implemented the approach for the NMI handler. This series extends the
> > same concept to the SEA handler and refactors common code into shared helpers.
> >
> > Patch 1 (Tony Luck): Improves ghes_notify_nmi() status check by pre-mapping
> >                       error status registers and avoiding repeated mappings.
> >
> > Patch 2 (Shuai Xue): Extracts common helper functions for error status handling
> >                       to eliminate code duplication.
> >
> > Patch 3 (Shuai Xue): Applies the same optimization to ghes_notify_sea() to improve
> >                       ARMv8 system performance.
>
> Looks good to me, and did a simple compile test on both x86 and arm64
> machine,
>
> Reviewed-by: Hanjun Guo <guohanjun@huawei.com>

Applied as 6.20 material, thanks!