[PATCH OLK-6.6] mpage: fix softlockup in mpage_readahead()

hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IBYXQD --------------------------- When using null_blk with a large readahead window, calling madvise to trigger readahead can lead to system softlocks. This occurs because the CPU can remain in the mpage_readahead loop for extended periods without rescheduling, preventing other processes from running. The issue manifests as follows: Call Trace: bio_add_page+0x7f/0x120 bio_add_folio+0x24/0x40 do_mpage_readpage+0x6de/0xbc0 xas_load+0x1e/0x240 xa_load+0x8f/0xf0 mpage_readahead+0xe7/0x230 __pfx_blkdev_get_block+0x10/0x10 blkdev_readahead+0x14/0x30 read_pages+0x71/0x460 folio_add_lru+0x6a/0x140 ? filemap_add_folio+0xb6/0x190 page_cache_ra_unbounded+0x197/0x2a0 do_page_cache_ra+0x42/0x70 page_cache_ra_order+0x360/0x610 filemap_fault+0x7d8/0x1200 __do_fault+0x3e/0x380 do_pte_missing+0x628/0x1cd0 ? __pte_offset_map+0x1a/0x200 __handle_mm_fault+0x7f2/0x19b0 ? __pte_offset_map+0x1a/0x200 ? __pte_offset_map_lock+0x78/0x170 handle_mm_fault+0x275/0x560 __get_user_pages+0x1f0/0xbd0 faultin_page_range+0xae/0x460 madvise_vma_behavior+0x62e/0xfa0 ? find_vma_prev+0x85/0xe0 do_madvise+0x1eb/0x5a0 __x64_sys_madvise+0x2b/0x40 x64_sys_call+0x23b3/0x4620 do_syscall_64+0x9e/0x1b0 ? irqentry_exit_to_user_mode+0x7d/0x300 entry_SYSCALL_64_after_hwframe+0x78/0xe2 Add a cond_resched() call at the beginning of each loop iteration to allow the CPU to schedule other tasks when necessary, avoiding potential softlocks during heavy readahead operations. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Zheng Qixing <zhengqixing@huawei.com> --- fs/mpage.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/mpage.c b/fs/mpage.c index 242e213ee064..73947fc8ff1e 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -376,6 +376,7 @@ void mpage_readahead(struct readahead_control *rac, get_block_t get_block) }; while ((folio = readahead_folio(rac))) { + cond_resched(); prefetchw(&folio->flags); args.folio = folio; args.nr_pages = readahead_count(rac); -- 2.39.2

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/16075 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/SM7... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/16075 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/SM7...
participants (2)
-
patchwork bot
-
Zheng Qixing