linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hns3: work around stack size warning
@ 2025-06-10  9:21 Arnd Bergmann
  2025-06-10 16:08 ` Andrew Lunn
  2025-06-11  2:10 ` Jijie Shao
  0 siblings, 2 replies; 14+ messages in thread
From: Arnd Bergmann @ 2025-06-10  9:21 UTC (permalink / raw)
  To: Jian Shen, Salil Mehta, Jijie Shao, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Nathan Chancellor
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Hao Lan, Guangwei Zhang, netdev, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

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.

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

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 4e5d8bc39a1b..97dc47eeb44c 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -580,8 +580,9 @@ static const struct hns3_dbg_item tx_spare_info_items[] = {
 	{ "DMA", 17 },
 };
 
-static void hns3_dbg_tx_spare_info(struct hns3_enet_ring *ring, char *buf,
-				   int len, u32 ring_num, int *pos)
+static noinline_for_stack void
+hns3_dbg_tx_spare_info(struct hns3_enet_ring *ring, char *buf,
+			int len, u32 ring_num, int *pos)
 {
 	char data_str[ARRAY_SIZE(tx_spare_info_items)][HNS3_DBG_DATA_STR_LEN];
 	struct hns3_tx_spare *tx_spare = ring->tx_spare;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-06-23  7:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10  9:21 [PATCH] hns3: work around stack size warning Arnd Bergmann
2025-06-10 16:08 ` Andrew Lunn
2025-06-11  2:10 ` Jijie Shao
2025-06-11 16:36   ` Arnd Bergmann
2025-06-12 13:09     ` Jijie Shao
2025-06-12 14:32       ` Jakub Kicinski
2025-06-12 15:27         ` Arnd Bergmann
2025-06-12 15:33       ` Jakub Kicinski
2025-06-13  5:59         ` Jijie Shao
2025-06-23  2:30           ` Jijie Shao
2025-06-23  3:19           ` Jijie Shao
2025-06-23  5:56             ` Arnd Bergmann
2025-06-23  6:21               ` Jijie Shao
2025-06-23  7:12                 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).