ublk: reduce stack usage in __ublk_shmem_remove_ranges
Subsystems (2)
PATCH 1/1 ublk: reduce stack usage in __ublk_shmem_remove_ranges
From: Arnd Bergmann <[email protected]>
The array in __ublk_shmem_remove_ranges() is one kilobyte long, which is really too much for an on-stack allocation, as can be seen with a frame warning limit of 1.25kb that otherwise produces a clean build on my test system:
drivers/block/ublk_drv.c: In function '__ublk_shmem_remove_ranges':drivers/block/ublk_drv.c:5573:1: error: the frame size of 1392 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]
Maybe half the size is good enough here, so try 32 entries. If 64 entries are really required, the array could be dynamically allocated, but that would risk an allocation failure.
---
I have really no idea if the 64 number was significant or just chosen to fit within usual stack frames.
--- drivers/block/ublk_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/ublk_drv.c +1 -1
@@ -5531,7 +5531,7 @@ static void ublk_unpin_range_pages(unsigned long base_pfn,* * Returns true if the tree walk completed, false if more ranges remain. */ -#define UBLK_REMOVE_BATCH 64 +#define UBLK_REMOVE_BATCH 32struct ublk_unpin_range {unsigned long base_pfn;
Signature · 1 line
2.53.0
Quoted 29 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The array in
__ublk_shmem_remove_ranges()is one kilobyte long, which is really too much for an on-stack allocation, as can be seen with a frame warning limit of 1.25kb that otherwise produces a clean build on my test system:
drivers/block/ublk_drv.c: In function '__ublk_shmem_remove_ranges':drivers/block/ublk_drv.c:5573:1: error: the frame size of 1392 bytes is larger than 1280 bytes [-Werror=frame-larger-than=]Maybe half the size is good enough here, so try 32 entries. If 64 entries are really required, the array could be dynamically allocated, but that would risk an allocation failure.
Fixes 309e02dccf64 ("ublk: avoid unpinning pages under maple tree spinlock")Signed-off-by Arnd Bergmann <[email protected]>---
I have really no idea if the 64 number was significant or just chosen to fit within usual stack frames.--- drivers/block/ublk_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/block/ublk_drv.c +0
-0
drivers/block/ublk_drv.c static void ublk_unpin_range_pages(unsigned long base_pfn, · line 5534
Quoted 5 lines
drivers/block/ublk_drv.c +1
-1@@ -5531,7 +5531,7 @@ static void ublk_unpin_range_pages(unsigned long base_pfn,* * Returns true if the tree walk completed, false if more ranges remain. */ -#define UBLK_REMOVE_BATCH 64 +#define UBLK_REMOVE_BATCH 32
Thanks,
Ming Lei