mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shuai Xue <xueshuai@linux.alibaba.com>
To: Hanjun Guo <guohanjun@huawei.com>,
	tony.luck@intel.com, mchehab@kernel.org, yazen.ghannam@amd.com
Cc: dave.jiang@intel.com, Smita.KoralahalliChannabasappa@amd.com,
	leitao@debian.org, pengdonglin@xiaomi.com,
	baolin.wang@linux.alibaba.com, benjamin.cheatham@amd.com,
	bp@alien8.de, dan.j.williams@intel.com, james.morse@arm.com,
	lenb@kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org, rafael@kernel.org,
	zhuo.song@linux.alibaba.com
Subject: Re: [PATCH 1/3] ACPI: APEI: GHES: Improve ghes_notify_nmi() status check
Date: Thu, 18 Dec 2025 14:01:47 +0800	[thread overview]
Message-ID: <9838f123-2628-440c-afe5-6e50b8dc85e8@linux.alibaba.com> (raw)
In-Reply-To: <f40cff8b-56b5-58e5-5652-457e681c0964@huawei.com>

Hi, Hanjun

On 12/17/25 9:13 AM, Hanjun Guo wrote:
> Hi Shuai,
> 
> Some minor comments inline.
> 
> On 2025/12/3 21:02, Shuai Xue wrote:
>> From: Tony Luck <tony.luck@intel.com>
>>
>> ghes_notify_nmi() is called for every NMI and must check whether the NMI was
>> generated because an error was signalled by platform firmware.
>>
>> This check is very expensive as for each registered GHES NMI source it reads
>> from the acpi generic address attached to this error source to get the physical
>> address of the acpi_hest_generic_status block.  It then checks the "block_status"
>> to see if an error was logged.
>>
>> The ACPI/APEI code must create virtual mappings for each of those physical
>> addresses, and tear them down afterwards. On an Icelake system this takes around
>> 15,000 TSC cycles. Enough to disturb efforts to profile system performance.
>>
>> If that were not bad enough, there are some atomic accesses in the code path
>> that will cause cache line bounces between CPUs. A problem that gets worse as
>> the core count increases.
>>
>> But BIOS changes neither the acpi generic address nor the physical address of
>> the acpi_hest_generic_status block. So this walk can be done once when the NMI is
>> registered to save the virtual address (unmapping if the NMI is ever unregistered).
>> The "block_status" can be checked directly in the NMI handler. This can be done
>> without any atomic accesses.
>>
>> Resulting time to check that there is not an error record is around 900 cycles.
>>
>> Reported-by: Andi Kleen <andi.kleen@intel.com>
>> Signed-off-by: Tony Luck <tony.luck@intel.com>
>> ---
>>   drivers/acpi/apei/ghes.c | 39 ++++++++++++++++++++++++++++++++++++---
>>   include/acpi/ghes.h      |  1 +
>>   2 files changed, 37 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
>> index 97ee19f2cae0..62713b612865 100644
>> --- a/drivers/acpi/apei/ghes.c
>> +++ b/drivers/acpi/apei/ghes.c
>> @@ -1425,7 +1425,21 @@ static LIST_HEAD(ghes_nmi);
>>   static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
>>   {
>>       static DEFINE_RAW_SPINLOCK(ghes_notify_lock_nmi);
>> +    bool active_error = false;
>>       int ret = NMI_DONE;
>> +    struct ghes *ghes;
>> +
>> +    rcu_read_lock();
>> +    list_for_each_entry_rcu(ghes, &ghes_nmi, list) {
>> +        if (ghes->error_status_vaddr && readl(ghes->error_status_vaddr)) {
>> +            active_error = true;
>> +            break;
>> +        }
>> +    }
>> +    rcu_read_unlock();
>> +
>> +    if (!active_error)
>> +        return ret;
>>       if (!atomic_add_unless(&ghes_in_nmi, 1, 1))
>>           return ret;
>> @@ -1439,13 +1453,26 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs)
>>       return ret;
>>   }
>> -static void ghes_nmi_add(struct ghes *ghes)
>> +static int ghes_nmi_add(struct ghes *ghes)
>>   {
>> +    struct acpi_hest_generic *g = ghes->generic;
>> +    u64 paddr;
>> +    int rc;
>> +
>> +    rc = apei_read(&paddr, &g->error_status_address);
>> +    if (rc)
>> +        return rc;
> 
> It will be good to add a empty line here.

Sure, will fix it.

> 
>> +    ghes->error_status_vaddr = acpi_os_ioremap(paddr, sizeof(ghes->estatus->block_status));
>> +    if (!ghes->error_status_vaddr)
>> +        return AE_BAD_ADDRESS;
> 
> It's static int for ghes_nmi_add(), and AE_BAD_ADDRESS is the type of
> acpi_status, it's better to return -EINVAL here.

Thanks for pointing it out, will fix it.

> 
> Thanks
> Hanjun

Thanks.
Shuai


  reply	other threads:[~2025-12-18  6:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03 13:02 [PATCH 0/3] ACPI: APEI: GHES: Performance improvements for error notification handlers Shuai Xue
2025-12-03 13:02 ` [PATCH 1/3] ACPI: APEI: GHES: Improve ghes_notify_nmi() status check Shuai Xue
2025-12-17  1:13   ` Hanjun Guo
2025-12-18  6:01     ` Shuai Xue [this message]
2025-12-03 13:02 ` [PATCH 2/3] ACPI: APEI: GHES: Extract helper functions for error status handling Shuai Xue
2025-12-17  1:25   ` Hanjun Guo
2025-12-18  6:03     ` Shuai Xue
2025-12-03 13:02 ` [PATCH 3/3] ACPI: APEI: GHES: Improve ghes_notify_sea() status check Shuai Xue
2025-12-11 18:44 ` [PATCH 0/3] ACPI: APEI: GHES: Performance improvements for error notification handlers Luck, Tony

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9838f123-2628-440c-afe5-6e50b8dc85e8@linux.alibaba.com \
    --to=xueshuai@linux.alibaba.com \
    --cc=Smita.KoralahalliChannabasappa@amd.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=benjamin.cheatham@amd.com \
    --cc=bp@alien8.de \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=guohanjun@huawei.com \
    --cc=james.morse@arm.com \
    --cc=leitao@debian.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=pengdonglin@xiaomi.com \
    --cc=rafael@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=yazen.ghannam@amd.com \
    --cc=zhuo.song@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®