shmem_undo_range() keeps a folio_batch and an array of FOLIO_BATCH_SIZE indices on its stack. Removing truncated folios from the page cache in batches added a second folio_batch to collect the folios to delete. That grows the stack frame by about 200 bytes, past the 1024 byte limit of mips eyeq6_defconfig built with clang. Pass fbatch itself to delete_from_page_cache_batch() once the swap entries are gone, as truncate_inode_pages_range() does. Undoing a failed fallocate() only removes the folios that are not uptodate, so remove those one at a time with truncate_inode_folio() as before. Stack frame of shmem_undo_range() built with clang 18: config before (bytes) after (bytes) change mips eyeq6_defconfig 928 720 -22% x86_64 920 712 -23% Fixes: b97fbd541ecba ("mm/shmem: remove truncated folios from the page cache in batches") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202611112032.TMyPU6Rm-lkp@intel.com/ Signed-off-by: Qiliang Yuan --- David, this applies on top of b97fbd541ecba in shmem-7.5.misc; please fold it in if you prefer. --- mm/shmem.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 156469423a866..5bcbdd6078a73 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1352,9 +1352,6 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, uoff_t lend, index = start; while (index < end && find_lock_entries(mapping, &index, end - 1, &fbatch, indices)) { - struct folio_batch remove; - - folio_batch_init(&remove); for (i = 0; i < folio_batch_count(&fbatch); i++) { folio = fbatch.folios[i]; @@ -1366,13 +1363,14 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, uoff_t lend, continue; } - if (!unfalloc || !folio_test_uptodate(folio)) { + if (!unfalloc) truncate_cleanup_folio(folio); - folio_batch_add(&remove, folio); - } + else if (!folio_test_uptodate(folio)) + truncate_inode_folio(mapping, folio); } - delete_from_page_cache_batch(mapping, &remove); folio_batch_remove_exceptionals(&fbatch); + if (!unfalloc) + delete_from_page_cache_batch(mapping, &fbatch); for (i = 0; i < folio_batch_count(&fbatch); i++) folio_unlock(fbatch.folios[i]); folio_batch_release(&fbatch); --- base-commit: b97fbd541ecba5d6640077618e9dfec6f5e71132 change-id: 20261111-bug-mm-shmem-undo-frame-66828e197ad5 Best regards, -- Qiliang Yuan