Skip to contentSkip to conversation

infiniband/hw/ocrdma: make function ocrdma_add_stat as noinline_for_stack

PATCH In review [email protected] 2 participants 2 messages Jul 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 infiniband/hw/ocrdma: make function ocrdma_add_stat as noinline_for_stack

From: Peng Hao <[email protected]>

clang report:
drivers/infiniband/hw/ocrdma/ocrdma_stats.c:686:16: error: stack frame size (20664) exceeds limit (2048) in 'ocrdma_dbgfs_ops_read' [-Werror,-Wframe-larger-than] static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,

               ^

A 128-byte array is defined in ocrdma_add_stat and is called multiple times by multiple functions (up to dozens of times), which results in a large amount of stack space being accumulated in ocrdma_dbgfs_ops_read. mark it as noinline_for_stack to prevent it from spreading to ocrdma_dbgfs_ops_read's stack size.

---
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/ocrdma/ocrdma_stats.c +1 -1
index 5f831e3bdbad..0b26c4e6de53 100644
@@ -46,7 +46,7 @@
 
 static struct dentry *ocrdma_dbgfs_dir;
 
-static int ocrdma_add_stat(char *start, char *pcur,
+static noinline_for_stack int ocrdma_add_stat(char *start, char *pcur,
 				char *name, u64 count)
 {
 	char buff[128] = {0};
Signature · 1 line
2.27.0
#1 lore raw
Quoted 12 lines · On Thu, Jul 11, 2024 at 04:56:47PM +0800, [email protected] wrote:

From: Peng Hao <[email protected]>

clang report:
drivers/infiniband/hw/ocrdma/ocrdma_stats.c:686:16: error: stack frame size (20664) exceeds limit (2048) in 'ocrdma_dbgfs_ops_read' [-Werror,-Wframe-larger-than] static ssize_t ocrdma_dbgfs_ops_read(struct file *filp, char __user *buffer,

               ^

A 128-byte array is defined in ocrdma_add_stat and is called multiple times by multiple functions (up to dozens of times), which results in a large amount of stack space being accumulated in ocrdma_dbgfs_ops_read. mark it as noinline_for_stack to prevent it from spreading to ocrdma_dbgfs_ops_read's stack size.

Quoted 4 lines
---
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I merged this patch with https://lore.kernel.org/r/[email protected]

Thanks

Quoted 18 lines
drivers/infiniband/hw/ocrdma/ocrdma_stats.c +1 -1
index 5f831e3bdbad..0b26c4e6de53 100644
@@ -46,7 +46,7 @@
 
 static struct dentry *ocrdma_dbgfs_dir;
 
-static int ocrdma_add_stat(char *start, char *pcur,
+static noinline_for_stack int ocrdma_add_stat(char *start, char *pcur,
 				char *name, u64 count)
 {
 	char buff[128] = {0};
Signature · 1 line
2.27.0