patch 地址:[PATCH 0/10] mm: Fix various readahead quirks - Jan Kara

[PATCH 01/10]readahead: Make sure sync readahead reads needed page

mm/readahead.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
diff --git a/mm/readahead.c b/mm/readahead.c
index c1b23989d9ca..af0fbd302a38 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -580,7 +580,7 @@ static void ondemand_readahead(struct readahead_control *ractl,
 	 */
 	expected = round_down(ra->start + ra->size - ra->async_size,
 			1UL << order);
-	if (index == expected || index == (ra->start + ra->size)) {
+	if (folio && index == expected) {
 		ra->start += ra->size;
 		ra->size = get_next_ra_size(ra, max_pages);
 		ra->async_size = ra->size;

从代码的角度,这个修改严格了 ra 变化的条件,原来只要满足 (index == expected || index == (ra->start + ra->size)) 那么都会增加预读窗口,然后从底层读数据。修改之后仅仅在异步预读(folio != NULL)且命中异步预读标记(index == expected)才会增加预读窗口。

为什么这个修改可以提高顺序读的性能

要弄清楚这个问题需要知道