From nobody Fri Dec 19 21:16:08 2025 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D43151400C; Wed, 3 Dec 2025 13:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764766989; cv=none; b=DOqsZCKw3E5DHxlI1SQ3/EL0DJ53gbFyjOhXYAAhMWE+QeZmmsi+Yb9TsXZDmBQHjfplC5Soa2gsojV/yQUQAKwMC5FMReg4xM/uvSs2e2t6ejfQSQaB0GFZzVBIUqgk3KCXMKFVOHrFxZKT3wrBF5Eh+il/AmDN6sM5OWyA7gg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764766989; c=relaxed/simple; bh=6GXNAeSSEc4GCh9cMHewwTavh+3o9vRhyorUGZefgoQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lZTlKlSoQBk45vy+qHbLgN9fFq+R98MOHZT29eo/HLdmwqzwlXFx3c5w41cg0FlMX1fJ1iGbq7stjLD2zsjYcapm45YvNqhEsYMNKBZlQvPDDIgrZ+GJufHqd7T2FV46LLcQvvnTKJFGE0aLDksHKHUK4SquyJfwqSea8Xi+InU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=eL4bDkXd; arc=none smtp.client-ip=115.124.30.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="eL4bDkXd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1764766977; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=hsxTelzbs2PdzIFuC0Pu+EdtPiKcRxUu5a6o+gsfS+A=; b=eL4bDkXd+iR+J0sbSMfDVD1BJMP76DOo5Ziqs361Gmz92d/GVEgaQaSMm0w8eChodq4YUWFvgyDZ+HJjoBCn++KId+RAewzX+g71IfnaajkPh+L++CvQ1nipzy69sKZUP5B9/arj6HjMntg+kNSbOO9h+5pD5ePbeZOGyMknw74= Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Wu.aDuA_1764766975 cluster:ay36) by smtp.aliyun-inc.com; Wed, 03 Dec 2025 21:02:56 +0800 From: Shuai Xue To: tony.luck@intel.com, guohanjun@huawei.com, mchehab@kernel.org, yazen.ghannam@amd.com Cc: dave.jiang@intel.com, Smita.KoralahalliChannabasappa@amd.com, leitao@debian.org, pengdonglin@xiaomi.com, xueshuai@linux.alibaba.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: [PATCH 1/3] ACPI: APEI: GHES: Improve ghes_notify_nmi() status check Date: Wed, 3 Dec 2025 21:02:51 +0800 Message-Id: <20251203130253.73888-2-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20251203130253.73888-1-xueshuai@linux.alibaba.com> References: <20251203130253.73888-1-xueshuai@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Tony Luck 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 phys= ical address of the acpi_hest_generic_status block. It then checks the "block_s= tatus" 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 a= round 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 unregi= stered). 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 cyc= les. Reported-by: Andi Kleen Signed-off-by: Tony Luck Reviewed-by: Tony Luck Tested-by: Tony Luck --- 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 =3D false; int ret =3D 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 =3D true; + break; + } + } + rcu_read_unlock(); + + if (!active_error) + return ret; =20 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; } =20 -static void ghes_nmi_add(struct ghes *ghes) +static int ghes_nmi_add(struct ghes *ghes) { + struct acpi_hest_generic *g =3D ghes->generic; + u64 paddr; + int rc; + + rc =3D apei_read(&paddr, &g->error_status_address); + if (rc) + return rc; + ghes->error_status_vaddr =3D acpi_os_ioremap(paddr, sizeof(ghes->estatus-= >block_status)); + if (!ghes->error_status_vaddr) + return AE_BAD_ADDRESS; + mutex_lock(&ghes_list_mutex); if (list_empty(&ghes_nmi)) register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, "ghes"); list_add_rcu(&ghes->list, &ghes_nmi); mutex_unlock(&ghes_list_mutex); + + return 0; } =20 static void ghes_nmi_remove(struct ghes *ghes) @@ -1455,6 +1482,10 @@ static void ghes_nmi_remove(struct ghes *ghes) if (list_empty(&ghes_nmi)) unregister_nmi_handler(NMI_LOCAL, "ghes"); mutex_unlock(&ghes_list_mutex); + + if (ghes->error_status_vaddr) + iounmap(ghes->error_status_vaddr); + /* * To synchronize with NMI handler, ghes can only be * freed after NMI handler finishes. @@ -1462,7 +1493,7 @@ static void ghes_nmi_remove(struct ghes *ghes) synchronize_rcu(); } #else /* CONFIG_HAVE_ACPI_APEI_NMI */ -static inline void ghes_nmi_add(struct ghes *ghes) { } +static inline int ghes_nmi_add(struct ghes *ghes) { return -EINVAL; } static inline void ghes_nmi_remove(struct ghes *ghes) { } #endif /* CONFIG_HAVE_ACPI_APEI_NMI */ =20 @@ -1630,7 +1661,9 @@ static int ghes_probe(struct platform_device *ghes_de= v) ghes_sea_add(ghes); break; case ACPI_HEST_NOTIFY_NMI: - ghes_nmi_add(ghes); + rc =3D ghes_nmi_add(ghes); + if (rc) + goto err; break; case ACPI_HEST_NOTIFY_SOFTWARE_DELEGATED: rc =3D apei_sdei_register_ghes(ghes); diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index ebd21b05fe6e..58655d313a1f 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -29,6 +29,7 @@ struct ghes { }; struct device *dev; struct list_head elist; + void __iomem *error_status_vaddr; }; =20 struct ghes_estatus_node { --=20 2.39.3 From nobody Fri Dec 19 21:16:08 2025 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 780391F4613; Wed, 3 Dec 2025 13:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764766991; cv=none; b=rt+fvTnb6ovjxmxAEo5zFSvMckk0pDu01Rt3F78FVkT/L5CRGu0xxnhjg909rr/RflRs3ZGxUZy3FcXvXMSiF3HiFAePs9D4VvJFd9l7tGhuPyQq1dGbVDbw3xYm9vrZM+OihV56lDMvRHPHOy2DuaP6EDXmVf5tqtsppbUwJyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764766991; c=relaxed/simple; bh=HekPj9ZJ+aTnXZNv7KcXz1bFRAFUei6fj0c1849WF1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ns0R72pO9vrQ+E1ZlyVShgUyhzcuBJMUjOraBubg+DMHn/6xhxlGQtDiklNnj+5i0WvCQtsr1GDDy2poDt6infDwMn89hu+UlVCiSOlUOY68q7DeEj4Sh5qTrsFt77ZTvkiS1xriKcR8wA5H7TP1OebfVziWqmKZbHcnk6aUOFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ysRdGBc+; arc=none smtp.client-ip=115.124.30.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ysRdGBc+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1764766978; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=54TNbmxJfXXrbNXvt+UsT4z8DDtKwln1bVNlOrDWgRw=; b=ysRdGBc+A8NCNsN5zOewG/tJifYM0so9jTRwZ7rM+ex3YipAE1KxbB4vwaJ/qO1cJcELw7E1fqdM7LD3IrsfR6egF51u6AF2+L0ccNy//WZ43k1rPJzihqMpTL4TeaqdAaWKu26oy4tihz8Xmq6Fhc7UnD+cdI76L68q1sboH78= Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Wu.aDv-_1764766977 cluster:ay36) by smtp.aliyun-inc.com; Wed, 03 Dec 2025 21:02:57 +0800 From: Shuai Xue To: tony.luck@intel.com, guohanjun@huawei.com, mchehab@kernel.org, yazen.ghannam@amd.com Cc: dave.jiang@intel.com, Smita.KoralahalliChannabasappa@amd.com, leitao@debian.org, pengdonglin@xiaomi.com, xueshuai@linux.alibaba.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: [PATCH 2/3] ACPI: APEI: GHES: Extract helper functions for error status handling Date: Wed, 3 Dec 2025 21:02:52 +0800 Message-Id: <20251203130253.73888-3-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20251203130253.73888-1-xueshuai@linux.alibaba.com> References: <20251203130253.73888-1-xueshuai@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactors the GHES driver by extracting common functionality into reusable helper functions: 1. ghes_has_active_errors() - Checks if any error sources in a given list have active errors 2. ghes_map_error_status() - Maps error status address to virtual address 3. ghes_unmap_error_status() - Unmaps error status virtual address These helpers eliminate code duplication in the NMI path and prepare for similar usage in the SEA path in a subsequent patch. No functional change intended. Signed-off-by: Shuai Xue Reviewed-by: Tony Luck Tested-by: Tony Luck --- drivers/acpi/apei/ghes.c | 92 +++++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 20 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 62713b612865..2c7f3ca6ce50 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -1375,6 +1375,74 @@ static int ghes_in_nmi_spool_from_list(struct list_h= ead *rcu_list, return ret; } =20 +/** + * ghes_has_active_errors - Check if there are active errors in error sour= ces + * @ghes_list: List of GHES entries to check for active errors + * + * This function iterates through all GHES entries in the given list and + * checks if any of them has active error status by reading the error + * status register. + * + * Return: true if at least one source has active error, false otherwise. + */ +static bool __maybe_unused ghes_has_active_errors(struct list_head *ghes_l= ist) +{ + bool active_error =3D false; + struct ghes *ghes; + + rcu_read_lock(); + list_for_each_entry_rcu(ghes, ghes_list, list) { + if (ghes->error_status_vaddr && + readl(ghes->error_status_vaddr)) { + active_error =3D true; + break; + } + } + rcu_read_unlock(); + + return active_error; +} + +/** + * ghes_map_error_status - Map error status address to virtual address + * @ghes: pointer to GHES structure + * + * Reads the error status address from ACPI HEST table and maps it to a vi= rtual + * address that can be accessed by the kernel. + * + * Return: 0 on success, error code on failure. + */ +static int __maybe_unused ghes_map_error_status(struct ghes *ghes) +{ + struct acpi_hest_generic *g =3D ghes->generic; + u64 paddr; + int rc; + + rc =3D apei_read(&paddr, &g->error_status_address); + if (rc) + return rc; + ghes->error_status_vaddr =3D + acpi_os_ioremap(paddr, sizeof(ghes->estatus->block_status)); + if (!ghes->error_status_vaddr) + return AE_BAD_ADDRESS; + + return 0; +} + +/** + * ghes_unmap_error_status - Unmap error status virtual address + * @ghes: pointer to GHES structure + * + * Unmaps the error status address if it was previously mapped. + */ +static void __maybe_unused ghes_unmap_error_status(struct ghes *ghes) +{ + if (ghes->error_status_vaddr) { + iounmap(ghes->error_status_vaddr); + ghes->error_status_vaddr =3D NULL; + } +} + #ifdef CONFIG_ACPI_APEI_SEA static LIST_HEAD(ghes_sea); =20 @@ -1425,20 +1493,9 @@ 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 =3D false; int ret =3D NMI_DONE; - struct ghes *ghes; =20 - rcu_read_lock(); - list_for_each_entry_rcu(ghes, &ghes_nmi, list) { - if (ghes->error_status_vaddr && readl(ghes->error_status_vaddr)) { - active_error =3D true; - break; - } - } - rcu_read_unlock(); - - if (!active_error) + if (!ghes_has_active_errors(&ghes_nmi)) return ret; =20 if (!atomic_add_unless(&ghes_in_nmi, 1, 1)) @@ -1455,16 +1512,11 @@ static int ghes_notify_nmi(unsigned int cmd, struct= pt_regs *regs) =20 static int ghes_nmi_add(struct ghes *ghes) { - struct acpi_hest_generic *g =3D ghes->generic; - u64 paddr; int rc; =20 - rc =3D apei_read(&paddr, &g->error_status_address); + rc =3D ghes_map_error_status(ghes); if (rc) return rc; - ghes->error_status_vaddr =3D acpi_os_ioremap(paddr, sizeof(ghes->estatus-= >block_status)); - if (!ghes->error_status_vaddr) - return AE_BAD_ADDRESS; =20 mutex_lock(&ghes_list_mutex); if (list_empty(&ghes_nmi)) @@ -1483,8 +1535,7 @@ static void ghes_nmi_remove(struct ghes *ghes) unregister_nmi_handler(NMI_LOCAL, "ghes"); mutex_unlock(&ghes_list_mutex); =20 - if (ghes->error_status_vaddr) - iounmap(ghes->error_status_vaddr); + ghes_unmap_error_status(ghes); =20 /* * To synchronize with NMI handler, ghes can only be @@ -1492,6 +1543,7 @@ static void ghes_nmi_remove(struct ghes *ghes) */ synchronize_rcu(); } + #else /* CONFIG_HAVE_ACPI_APEI_NMI */ static inline int ghes_nmi_add(struct ghes *ghes) { return -EINVAL; } static inline void ghes_nmi_remove(struct ghes *ghes) { } --=20 2.39.3 From nobody Fri Dec 19 21:16:08 2025 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A4B42DAFAE; Wed, 3 Dec 2025 13:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764766992; cv=none; b=Hn7WmjjWhTs2nosCVG3uyZ2wi2RlElKurILMwnlMDuZPbzWO+dP6pRS+4bjVHCi4nMQ3cCq1aJ0qGMb/Mj3uzjcUnPSMCYytGXJPsGcCixAX1Ge/dq4pS7rlYrS78Jnikd7GCwf4Vh9lG/n3+D6l+n2rNftUL+gSkcmtzKl1MlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764766992; c=relaxed/simple; bh=niRAa2D8g84O610u9+Z+A11OvECu7j1aWrMp4Ngezus=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OyWStYtcc4DZmJ6oKN4h7OWoQX8K1IBK6I9Zl3wKS7nFMWowJHAJShsB1TG2K3HT7sT8ltrgwT9VtNnucDEfjZFviZffRLn4IxMKPNdSQGX8W9eMjQwB1j/PtekyDWZivfJQ9Y5xZBFCN/7Resqtx/9cYD7TNP7KmOQCRMy2Kps= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=b1kEgj3x; arc=none smtp.client-ip=115.124.30.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="b1kEgj3x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1764766979; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=1MvtZ5ab+ryK10NzwLqSh+RbaAmADfpIYi1fbjQ+wyM=; b=b1kEgj3xVOE4W7aYwuz66esniVL0oMqQEbdiuWrILXRkd0LSeHcJfrv7JXQ2zuTAye5tOL2GH54qLKw3glKn4s+APPpdw5ZbgYEcK1UoD2XGzw9AupgqDcZ6cQKBGzs2qvWbuQvtWDqjKyn9s6OOq79hJgOVos9pfr1FuJJfTYw= Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0Wu.aDva_1764766978 cluster:ay36) by smtp.aliyun-inc.com; Wed, 03 Dec 2025 21:02:58 +0800 From: Shuai Xue To: tony.luck@intel.com, guohanjun@huawei.com, mchehab@kernel.org, yazen.ghannam@amd.com Cc: dave.jiang@intel.com, Smita.KoralahalliChannabasappa@amd.com, leitao@debian.org, pengdonglin@xiaomi.com, xueshuai@linux.alibaba.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: [PATCH 3/3] ACPI: APEI: GHES: Improve ghes_notify_sea() status check Date: Wed, 3 Dec 2025 21:02:53 +0800 Message-Id: <20251203130253.73888-4-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20251203130253.73888-1-xueshuai@linux.alibaba.com> References: <20251203130253.73888-1-xueshuai@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Performance testing on ARMv8 systems shows significant overhead in error status handling in SEA error handling. - ghes_peek_estatus(): 8,138.3 ns (21,160 cycles). - ghes_clear_estatus(): 2,038.3 ns (5,300 cycles). Apply the same optimization used in ghes_notify_nmi() to ghes_notify_sea() by checking for active errors before processing, Signed-off-by: Shuai Xue Reviewed-by: Tony Luck Tested-by: Tony Luck --- drivers/acpi/apei/ghes.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 2c7f3ca6ce50..0be46d63db53 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -1455,6 +1455,9 @@ int ghes_notify_sea(void) static DEFINE_RAW_SPINLOCK(ghes_notify_lock_sea); int rv; =20 + if (!ghes_has_active_errors(&ghes_sea)) + return -ENOENT; + raw_spin_lock(&ghes_notify_lock_sea); rv =3D ghes_in_nmi_spool_from_list(&ghes_sea, FIX_APEI_GHES_SEA); raw_spin_unlock(&ghes_notify_lock_sea); @@ -1462,11 +1465,19 @@ int ghes_notify_sea(void) return rv; } =20 -static void ghes_sea_add(struct ghes *ghes) +static int ghes_sea_add(struct ghes *ghes) { + int rc; + + rc =3D ghes_map_error_status(ghes); + if (rc) + return rc; + mutex_lock(&ghes_list_mutex); list_add_rcu(&ghes->list, &ghes_sea); mutex_unlock(&ghes_list_mutex); + + return 0; } =20 static void ghes_sea_remove(struct ghes *ghes) @@ -1474,10 +1485,11 @@ static void ghes_sea_remove(struct ghes *ghes) mutex_lock(&ghes_list_mutex); list_del_rcu(&ghes->list); mutex_unlock(&ghes_list_mutex); + ghes_unmap_error_status(ghes); synchronize_rcu(); } #else /* CONFIG_ACPI_APEI_SEA */ -static inline void ghes_sea_add(struct ghes *ghes) { } +static inline int ghes_sea_add(struct ghes *ghes) { return -EINVAL; } static inline void ghes_sea_remove(struct ghes *ghes) { } #endif /* CONFIG_ACPI_APEI_SEA */ =20 @@ -1710,7 +1722,9 @@ static int ghes_probe(struct platform_device *ghes_de= v) break; =20 case ACPI_HEST_NOTIFY_SEA: - ghes_sea_add(ghes); + rc =3D ghes_sea_add(ghes); + if (rc) + goto err; break; case ACPI_HEST_NOTIFY_NMI: rc =3D ghes_nmi_add(ghes); --=20 2.39.3