
On 2025/4/29 10:13, Zheng Qixing wrote:
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IBYXQD
---------------------------
When using null_blk with a large readahead window, calling madvise to
这种不是应该去减少 readahead窗口? 这个madvise的大小有多少
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: xas_load+0x3c/0x90 xa_load+0x9f/0x290 page_cache_ra_unbounded+0x92/0x380 force_page_cache _ra+0xd5/0x1c0 generic_fadvise+0x255/0x3e0 vfs_fadvise+0x30/0x40 do_madvise+0xb1b/0x11d0 x64_sys_madvise+0x2b/0x40 x64_sys_call+0x1c0c/0x1e80 do_syscall_64+0x44/0x70 entry_SYScALL_64_after hwframe+0x66/0xd0
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 830e6cc2a9e7..f303c455b0e9 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -385,6 +385,7 @@ void mpage_readahead(struct readahead_control *rac, get_block_t get_block) };
while ((page = readahead_page(rac))) { + cond_resched(); prefetchw(&page->flags); args.page = page; args.nr_pages = readahead_count(rac);