net: kunit: move struct net_devmem_dmabuf_binding off stack
Subsystems (2)
PATCH 1/1 net: kunit: move struct net_devmem_dmabuf_binding off stack
From: Arnd Bergmann <[email protected]>
The net_devmem_dmabuf_binding structure is really way too big to live on the stack, and causes warnings on my randconfig build machine with a reasonable per-function limit:
net/core/net_test.c: In function 'netmem_ref_test_tcp_devmem_recv':net/core/net_test.c:1720:1: error: the frame size of 1744 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
1720 | }
| ^
net/core/net_test.c: In function 'netmem_ref_test_skb_segment':net/core/net_test.c:1477:1: error: the frame size of 1584 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
Since the binding object is never used concurrently in multiple tests, avoid this by just having a global copy of it and reinitializing it for every user.
---
I don't particularly like this workaround, as global variables are always hacky like this. If anyone has a better idea to avoid the last stack structure, let's do that instead.
Without the patch, I run into this every few randconfig builds, which did not happen on linux-next before the merge window.
--- net/core/net_test.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/core/net_test.c +7 -5
@@ -984,13 +984,14 @@ static void netmem_ref_test_pp_page(struct kunit *test)#endif #if defined(CONFIG_PAGE_POOL) && defined(CONFIG_NET_DEVMEM) +static struct net_devmem_dmabuf_binding binding; + static void dummy_percpu_ref_release(struct percpu_ref *ref) { } static void netmem_ref_test_net_iov(struct kunit *test) { - struct net_devmem_dmabuf_binding binding = {}; struct page_pool_params pp_params = { .order = 0, .pool_size = 4,
@@ -1003,6 +1004,7 @@ static void netmem_ref_test_net_iov(struct kunit *test)long base_ref;int err; +memset (&binding,0 ,sizeof (binding)); err =percpu_ref_init (&binding.ref, dummy_percpu_ref_release,PERCPU_REF_INIT_ATOMIC ,GFP_KERNEL );KUNIT_ASSERT_EQ (test, err,0 );
@@ -1145,7 +1147,6 @@ static void netmem_ref_test_release_data(struct kunit *test) .nid = NUMA_NO_NODE, };struct sk_buff *skb, *clone1, *clone2, *ext; -struct net_devmem_dmabuf_binding binding = {};struct net_iov niov = {};struct page_pool *pool;struct page *page;
@@ -1154,6 +1155,7 @@ static void netmem_ref_test_release_data(struct kunit *test)int base_ref;int i; +memset (&binding,0 ,sizeof (binding)); pool =page_pool_create (&pp_params);KUNIT_ASSERT_FALSE (test,IS_ERR (pool)); page =page_pool_dev_alloc_pages (pool);
@@ -1335,7 +1337,6 @@ static void netmem_ref_test_skb_segment(struct kunit *test) .flags = SKBFL_ZEROCOPY_ENABLE, };struct sk_buff *head, *list, *segs, *seg; -struct net_devmem_dmabuf_binding binding = {};struct net_iov niov = {};struct page *pp_page, *reg_page;netmem_ref pp_nm, niov_nm;
@@ -1343,6 +1344,7 @@ static void netmem_ref_test_skb_segment(struct kunit *test)long base_pp_ref, base_iov_ref;int base_pp_page_ref, base_reg_ref; +memset (&binding,0 ,sizeof (binding)); pool =page_pool_create (&pp_params);KUNIT_ASSERT_FALSE (test,IS_ERR (pool)); pp_page =page_pool_dev_alloc_pages (pool);
@@ -1634,7 +1636,6 @@ static void netmem_ref_test_try_coalesce(struct kunit *test) .nid = NUMA_NO_NODE, };struct sk_buff *to, *from, *clone; -struct net_devmem_dmabuf_binding binding = {};struct net_iov niov = {};struct page *pp_page, *reg_page;netmem_ref pp_nm, niov_nm;
@@ -1644,6 +1645,7 @@ static void netmem_ref_test_try_coalesce(struct kunit *test)bool fragstolen;int delta; +memset (&binding,0 ,sizeof (binding)); pool =page_pool_create (&pp_params);KUNIT_ASSERT_FALSE (test,IS_ERR (pool)); pp_page =page_pool_dev_alloc_pages (pool);
@@ -1766,7 +1768,6 @@ static void netmem_ref_test_tcp_devmem_recv(struct kunit *test) .pool_size = 4, .nid = NUMA_NO_NODE, }; -struct net_devmem_dmabuf_binding binding = {};struct msghdr msg = {};struct dmabuf_token token;struct dmabuf_cmsg *cmsg;
@@ -1780,6 +1781,7 @@ static void netmem_ref_test_tcp_devmem_recv(struct kunit *test)long base_iov_ref;int ret; +memset (&binding,0 ,sizeof (binding)); KUNIT_ASSERT_EQ(test, sock_create_kern(&init_net, AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock),
Signature · 1 line
2.53.0
Quoted 25 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The
net_devmem_dmabuf_bindingstructure is really way too big to live on the stack, and causes warnings on my randconfig build machine with a reasonable per-function limit:
net/core/net_test.c: In function 'netmem_ref_test_tcp_devmem_recv':net/core/net_test.c:1720:1: error: the frame size of 1744 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
1720 | }| ^
net/core/net_test.c: In function 'netmem_ref_test_skb_segment':net/core/net_test.c:1477:1: error: the frame size of 1584 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]Since the binding object is never used concurrently in multiple tests, avoid this by just having a global copy of it and reinitializing it for every user.
Fixes 2285346afc99 ("net: kunit: test netmem, page_pool, and skb frag refcounting")Signed-off-by Arnd Bergmann <[email protected]>---
I don't particularly like this workaround, as global variables are always hacky like this. If anyone has a better idea to avoid the last stack structure, let's do that instead.
Quoted 4 lines
Without the patch, I run into this every few randconfig builds, which did not happen on linux-next before the merge window.
Signed-off-by Arnd Bergmann <[email protected]>
kunit_kzalloc() may work, but it requires s/binding\./binding->/ across the test cases. Either way is fine by me, this minimal fix works well too:
Signature · 2 lines
Thanks, Mina
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Fri, 13 Nov 2026 11:11:00 +0100 you wrote:
From: Arnd Bergmann <[email protected]>
The
net_devmem_dmabuf_bindingstructure is really way too big to live on the stack, and causes warnings on my randconfig build machine with a reasonable per-function limit:
Quoted 8 lines
net/core/net_test.c: In function 'netmem_ref_test_tcp_devmem_recv':net/core/net_test.c:1720:1: error: the frame size of 1744 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
1720 | }| ^
net/core/net_test.c: In function 'netmem_ref_test_skb_segment':net/core/net_test.c:1477:1: error: the frame size of 1584 bytes is larger than 1536 bytes [-Werror=frame-larger-than=][...]
Here is the summary with links:
- net: kunit: move struct net_devmem_dmabuf_binding off stack
https://git.kernel.org/netdev/net/c/271884902742
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html