diff mbox series

[SUBMITTED,20200529] drm/selftests/mm: reduce per-function stack usage

Message ID 20211019191815.3159266-1-arnd@kernel.org
State New
Headers show
Series [SUBMITTED,20200529] drm/selftests/mm: reduce per-function stack usage | expand

Commit Message

Arnd Bergmann Oct. 19, 2021, 7:18 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>


The check_reserve_boundaries() function has a large array on the stack,
over 500 bytes. It gets inlined into __igt_reserve, which has multiple
other large structures as well but stayed just under the stack size
warning limit of 1024 bytes until one more member got added to struct
drm_mm_node, causing a warning:

drivers/gpu/drm/selftests/test-drm_mm.c:371:12: error:
stack frame size of 1032 bytes in function '__igt_reserve' [-Werror,-Wframe-larger-than=]

As far as I can tell, this is not nice but will not be called from
a context that is already low for the kernel stack, so just annotate
the inner function as noinline_for_stack to ensure that each function
by itself stays under the warning limit.

Fixes: 0cdea4455acd ("drm/mm: optimize rb_hole_addr rbtree search")
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Link: https://lore.kernel.org/all/20200529201534.474853-1-arnd@arndb.de/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
This happens rather rarely, I just ran into it again and found my
old patch.
---
 drivers/gpu/drm/selftests/test-drm_mm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

-- 
2.29.2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index b768b53c4aee..76973c72855e 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -324,9 +324,8 @@  static bool expect_reserve_fail(struct drm_mm *mm, struct drm_mm_node *node)
 	return false;
 }
 
-static bool check_reserve_boundaries(struct drm_mm *mm,
-				     unsigned int count,
-				     u64 size)
+static noinline_for_stack bool
+check_reserve_boundaries(struct drm_mm *mm, unsigned int count, u64 size)
 {
 	const struct boundary {
 		u64 start, size;