On Mon, Nov 18, 2024 at 07:44:57PM +0800, Ye Bin wrote: > From: Ye Bin <yebin10@xxxxxxxxxx> > > As commit 04646aebd30b ("fs: avoid softlockups in s_inodes iterators") > introduces the retry logic. In the problem environment, the 'i_count' > of millions of files is not zero. As a result, the time slice for each > traversal to the matching inode process is almost used up, and then the > traversal is started from scratch. The worst-case scenario is that only > one inode can be processed after each wakeup. Because this process holds > a lock, other processes will be stuck for a long time, causing a series > of problems. > To solve the problem of repeated traversal from the beginning, each time > the CPU needs to be freed, a cursor is inserted into the linked list, and > the traversal continues from the cursor next time. > I'm surprised this was not sorted out eons ago. My non-maintainer $0,03 is as follows: Insertion of a marker is indeed the idiomatic way to fix this, but I disagree with the specific implementation. All cond_resched() handling should be moved into the magic iteration machinery, instead of random consumers open-coding it.