From: Dominik Kaszewski <[email protected]>

[Why]
Use of compound literals to initialize heap objects may create stack
temporaries when compiling in debug mode. For large objects such
as dc_memory_pool which is 2 pages large to avoid cacheline sharing,
this causes function stackframe to exceed kernel limit.

[How]
Replace compound literal with field-by-field initialization.

Signed-off-by: Dominik Kaszewski <[email protected]>
Signed-off-by: Leo Li <[email protected]>
Reviewed-by: Nicholas Kazlauskas <[email protected]>
Reviewed-by: Aric Cyr <[email protected]>
---

Hi Mark,

This should fix the build error mentioned here:
https://lore.kernel.org/all/[email protected]/

It looks like our clang CI builds didn't have UBSAN enabled, which
expands the stack size. Enabling it will hopefully prevent repeats in
the future.

Thanks,
Leo

 drivers/gpu/drm/amd/display/dc/dc_memory_pool.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c 
b/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c
index 904f8c4a47833..087f04d314592 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_memory_pool.c
@@ -107,16 +107,14 @@ __must_check struct dc_memory_pool 
*dc_memory_pool_create(size_t size,
 
        struct dc_memory_pool *pool = page_align_up(unaligned_pool);
 
-       *pool = (struct dc_memory_pool){
-               .size = size,
-               .capacity = capacity,
-               .unaligned_pool = unaligned_pool,
-               .unaligned_memory = kcalloc(lines + 1, PAGE_SIZE, GFP_KERNEL),
-               .free_list = kcalloc((uint32_t)capacity, sizeof(atomic_t),
-                                    GFP_KERNEL),
-               .free_head = ATOMIC_INIT(0),
-       };
+       // Compound literals create temporary in debug driver, exceeding stack 
size
+       pool->size = size;
+       pool->capacity = capacity;
+       pool->unaligned_pool = unaligned_pool;
+       pool->unaligned_memory = kcalloc(lines + 1, PAGE_SIZE, GFP_KERNEL);
        pool->memory = page_align_up(pool->unaligned_memory);
+       pool->free_list = kcalloc((uint32_t)capacity, sizeof(atomic_t), 
GFP_KERNEL);
+       pool->free_head = (atomic64_t)ATOMIC_INIT(0);
 
        if (!pool->unaligned_memory || !pool->free_list) {
                dc_memory_pool_destroy(pool);
-- 
2.55.0

Reply via email to