aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2019-07-12 05:06:33 -0400
committerDavid S. Miller <davem@davemloft.net>2019-07-12 18:36:14 -0400
commit752c2ea2d8e7c23b0f64e2e7d4337f3604d44c9f (patch)
tree51b466cf24f9aff768aaf8aad976da0adc9723e5
parentd12cffe9329fd278555d0f9bb89af1259a2fd933 (diff)
cxgb4: reduce kernel stack usage in cudbg_collect_mem_region()
The cudbg_collect_mem_region() and cudbg_read_fw_mem() both use several hundred kilobytes of kernel stack space. One gets inlined into the other, which causes the stack usage to be combined beyond the warning limit when building with clang: drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c:1057:12: error: stack frame size of 1244 bytes in function 'cudbg_collect_mem_region' [-Werror,-Wframe-larger-than=] Restructuring cudbg_collect_mem_region() lets clang do the same optimization that gcc does and reuse the stack slots as it can see that the large variables are never used together. A better fix might be to avoid using cudbg_meminfo on the stack altogether, but that requires a larger rewrite. Fixes: a1c69520f785 ("cxgb4: collect MC memory dump") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
index a76529a7662d..c2e92786608b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c
@@ -1054,14 +1054,12 @@ static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init,
1054 } 1054 }
1055} 1055}
1056 1056
1057static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init, 1057static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init,
1058 struct cudbg_buffer *dbg_buff, 1058 struct cudbg_error *cudbg_err,
1059 struct cudbg_error *cudbg_err, 1059 u8 mem_type)
1060 u8 mem_type)
1061{ 1060{
1062 struct adapter *padap = pdbg_init->adap; 1061 struct adapter *padap = pdbg_init->adap;
1063 struct cudbg_meminfo mem_info; 1062 struct cudbg_meminfo mem_info;
1064 unsigned long size;
1065 u8 mc_idx; 1063 u8 mc_idx;
1066 int rc; 1064 int rc;
1067 1065
@@ -1075,7 +1073,16 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
1075 if (rc) 1073 if (rc)
1076 return rc; 1074 return rc;
1077 1075
1078 size = mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base; 1076 return mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base;
1077}
1078
1079static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
1080 struct cudbg_buffer *dbg_buff,
1081 struct cudbg_error *cudbg_err,
1082 u8 mem_type)
1083{
1084 unsigned long size = cudbg_mem_region_size(pdbg_init, cudbg_err, mem_type);
1085
1079 return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size, 1086 return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size,
1080 cudbg_err); 1087 cudbg_err);
1081} 1088}