Re: [PATCH] hns3: work around stack size warning

From: Andrew Lunn
Date: Tue Jun 10 2025 - 12:09:28 EST


On Tue, Jun 10, 2025 at 11:21:08AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> The hns3 debugfs functions all use an extra on-stack buffer to store
> temporary text output before copying that to the debugfs file.
>
> In some configurations with clang, this can trigger the warning limit
> for the total stack size:
>
> drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c:788:12: error: stack frame size (1456) exceeds limit (1280) in 'hns3_dbg_tx_queue_info' [-Werror,-Wframe-larger-than]
>
> The problem here is that both hns3_dbg_tx_spare_info() and
> hns3_dbg_tx_queue_info() have a large on-stack buffer, and clang decides
> to inline them into a single function.
>
> Annotate hns3_dbg_tx_spare_info() as noinline_for_stack to force the
> behavior that gcc has, regardless of the compiler.

This warning is about the potential to exceed the stack space. That
potential still exists because of the tail call from
hns3_dbg_tx_queue_info() to hns3_dbg_tx_spare_info(), preventing the
compile from inlining does nothing against that.

> Ideally all the functions in here would be changed to avoid on-stack
> output buffers.

That would be my preference as well. Lets give Huawei a bit of time to
rewrite this code.

Andrew