[PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused

Rui Qi posted 1 patch 3 weeks ago
drivers/acpi/apei/ghes.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Rui Qi 3 weeks ago
When CONFIG_ACPI_APEI_SEA and CONFIG_HAVE_ACPI_APEI_NMI are both
disabled, ghes_in_nmi_spool_from_list() becomes an unused static
function and triggers -Werror=unused-function in some configs (e.g.
riscv defconfig with APEI disabled).

Mark it as __maybe_unused to silence the warning while keeping the
code available for configurations that use SEA or APEI NMI.

Signed-off-by: Rui Qi <qirui.001@bytedance.com>
---
 drivers/acpi/apei/ghes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
index 8acd2742bb27..1fe45949749f 100644
--- a/drivers/acpi/apei/ghes.c
+++ b/drivers/acpi/apei/ghes.c
@@ -1379,8 +1379,8 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
 	return rc;
 }
 
-static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
-				       enum fixed_addresses fixmap_idx)
+static int __maybe_unused ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
+			       enum fixed_addresses fixmap_idx)
 {
 	int ret = -ENOENT;
 	struct ghes *ghes;
-- 
2.20.1
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Shuai Xue an hour ago

On 3/16/26 4:28 PM, Rui Qi wrote:
> When CONFIG_ACPI_APEI_SEA and CONFIG_HAVE_ACPI_APEI_NMI are both
> disabled, ghes_in_nmi_spool_from_list() becomes an unused static
> function and triggers -Werror=unused-function in some configs (e.g.
> riscv defconfig with APEI disabled).
> 
> Mark it as __maybe_unused to silence the warning while keeping the
> code available for configurations that use SEA or APEI NMI.
> 
> Signed-off-by: Rui Qi <qirui.001@bytedance.com>
> ---
>   drivers/acpi/apei/ghes.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 8acd2742bb27..1fe45949749f 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -1379,8 +1379,8 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
>   	return rc;
>   }
>   
> -static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
> -				       enum fixed_addresses fixmap_idx)
> +static int __maybe_unused ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
> +			       enum fixed_addresses fixmap_idx)
>   {
>   	int ret = -ENOENT;
>   	struct ghes *ghes;

This approach is consistent with the existing pattern in the file,
where several functions are already marked as __maybe_unused:

$cat drivers/acpi/apei/ghes.c | grep __maybe_unused
static bool __maybe_unused ghes_has_active_errors(struct list_head *ghes_list)
static int __maybe_unused ghes_map_error_status(struct ghes *ghes)
static void __maybe_unused ghes_unmap_error_status(struct ghes *ghes)

LGTM.

Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>

Thanks.
Shuai
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Hanjun Guo 2 weeks ago
On 2026/3/16 16:28, Rui Qi wrote:
> When CONFIG_ACPI_APEI_SEA and CONFIG_HAVE_ACPI_APEI_NMI are both
> disabled, ghes_in_nmi_spool_from_list() becomes an unused static
> function and triggers -Werror=unused-function in some configs (e.g.
> riscv defconfig with APEI disabled).
> 
> Mark it as __maybe_unused to silence the warning while keeping the
> code available for configurations that use SEA or APEI NMI.
> 
> Signed-off-by: Rui Qi <qirui.001@bytedance.com>
> ---
>   drivers/acpi/apei/ghes.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 8acd2742bb27..1fe45949749f 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -1379,8 +1379,8 @@ static int ghes_in_nmi_queue_one_entry(struct ghes *ghes,
>   	return rc;
>   }
>   
> -static int ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
> -				       enum fixed_addresses fixmap_idx)
> +static int __maybe_unused ghes_in_nmi_spool_from_list(struct list_head *rcu_list,
> +			       enum fixed_addresses fixmap_idx)
>   {
>   	int ret = -ENOENT;
>   	struct ghes *ghes;

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

Thanks
Hanjun
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Breno Leitao 2 weeks, 6 days ago
On Mon, Mar 16, 2026 at 04:28:42PM +0800, Rui Qi wrote:
> When CONFIG_ACPI_APEI_SEA and CONFIG_HAVE_ACPI_APEI_NMI are both
> disabled, ghes_in_nmi_spool_from_list() becomes an unused static
> function and triggers -Werror=unused-function in some configs (e.g.
> riscv defconfig with APEI disabled).
> 
> Mark it as __maybe_unused to silence the warning while keeping the
> code available for configurations that use SEA or APEI NMI.
> 
> Signed-off-by: Rui Qi <qirui.001@bytedance.com>

Reviewed-by: Breno Leitao <leitao@debian.org>
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Breno Leitao 3 weeks ago
On Mon, Mar 16, 2026 at 04:28:42PM +0800, Rui Qi wrote:
> When CONFIG_ACPI_APEI_SEA and CONFIG_HAVE_ACPI_APEI_NMI are both
> disabled, ghes_in_nmi_spool_from_list() becomes an unused static
> function and triggers -Werror=unused-function in some configs (e.g.
> riscv defconfig with APEI disabled).
> 
> Mark it as __maybe_unused to silence the warning while keeping the
> code available for configurations that use SEA or APEI NMI.

Isn't it better to move it to the "#ifdef CONFIG_ACPI_APEI_SEA" below?
Similarly to ghes_sea_add() and ghes_sea_remove()?
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Rui Qi 2 weeks, 6 days ago
On 3/16/26 5:03 PM, Breno Leitao wrote:
> On Mon, Mar 16, 2026 at 04:28:42PM +0800, Rui Qi wrote:
>> When CONFIG_ACPI_APEI_SEA and CONFIG_HAVE_ACPI_APEI_NMI are both
>> disabled, ghes_in_nmi_spool_from_list() becomes an unused static
>> function and triggers -Werror=unused-function in some configs (e.g.
>> riscv defconfig with APEI disabled).
>>
>> Mark it as __maybe_unused to silence the warning while keeping the
>> code available for configurations that use SEA or APEI NMI.
> 
> Isn't it better to move it to the "#ifdef CONFIG_ACPI_APEI_SEA" below?
> Similarly to ghes_sea_add() and ghes_sea_remove()?

Thanks for the suggestion.



  ghes_in_nmi_spool_from_list() is currently used by both the SEA and
NMI paths:


  • ghes_notify_sea() under #ifdef CONFIG_ACPI_APEI_SEA

  • ghes_notify_nmi() under #ifdef CONFIG_HAVE_ACPI_APEI_NMI



  These two Kconfig options can be enabled independently. If we moved
ghes_in_nmi_spool_from_list() into
  the #ifdef CONFIG_ACPI_APEI_SEA block, a configuration that enables
CONFIG_HAVE_ACPI_APEI_NMI but not
  CONFIG_ACPI_APEI_SEA would end up missing this symbol for the NMI
path.


  The __maybe_unused annotation in this patch is intended to be
consistent with the nearby helpers (such
  as ghes_has_active_errors(), ghes_map_error_status() and
ghes_unmap_error_status()): when both SEA and
  APEI NMI support are disabled, they may be unused, and this avoids
compiler warnings about unused
  static functions.



  If there is consensus that we should address this via conditional
compilation instead, I can follow up
  with another patch that wraps these helpers in something like #if
IS_ENABLED(CONFIG_ACPI_APEI_SEA) ||
  IS_ENABLED(CONFIG_HAVE_ACPI_APEI_NMI).
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Breno Leitao 2 weeks, 6 days ago
On Tue, Mar 17, 2026 at 11:55:52AM +0800, Rui Qi wrote:
> On 3/16/26 5:03 PM, Breno Leitao wrote:
>
>   If there is consensus that we should address this via conditional
> compilation instead, I can follow up
>   with another patch that wraps these helpers in something like #if
> IS_ENABLED(CONFIG_ACPI_APEI_SEA) ||
>   IS_ENABLED(CONFIG_HAVE_ACPI_APEI_NMI).

This approach would be worse, I would say. Your current approach seems
cleaner, IMO.

Thanks for explaining the reason here.
--breno
Re: [PATCH] ACPI: APEI: ghes: mark ghes_in_nmi_spool_from_list maybe unused
Posted by Hanjun Guo 2 weeks ago
On 2026/3/17 17:39, Breno Leitao wrote:
> On Tue, Mar 17, 2026 at 11:55:52AM +0800, Rui Qi wrote:
>> On 3/16/26 5:03 PM, Breno Leitao wrote:
>>
>>    If there is consensus that we should address this via conditional
>> compilation instead, I can follow up
>>    with another patch that wraps these helpers in something like #if
>> IS_ENABLED(CONFIG_ACPI_APEI_SEA) ||
>>    IS_ENABLED(CONFIG_HAVE_ACPI_APEI_NMI).
> 
> This approach would be worse, I would say. Your current approach seems
> cleaner, IMO.

Looks reasonable to me as well.

Thanks
Hanjun