>> index 47afbca1d122..090b810ddeed 100644 >> --- a/mm/readahead.c >> +++ b/mm/readahead.c >> @@ -245,7 +245,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, >> continue; >> } >> - folio = filemap_alloc_folio(gfp_mask, 0); >> + folio = filemap_alloc_folio(gfp_mask, >> + mapping_min_folio_order(mapping)); >> if (!folio) >> break; >> if (filemap_add_folio(mapping, folio, index + i, >> @@ -259,7 +260,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, >> if (i == nr_to_read - lookahead_size) >> folio_set_readahead(folio); >> ractl->_workingset |= folio_test_workingset(folio); >> - ractl->_nr_pages++; >> + ractl->_nr_pages += folio_nr_pages(folio); >> + i += folio_nr_pages(folio) - 1; >> } >> /* > This is incomplete, as the loop above has some exit statements which blindly step backwards by one > page. > > I found it better to rework the 'for' into a 'while' loop; please check the attached patch. > Taken from your patch: @@ -240,8 +240,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, * not worth getting one just for that. */ read_pages(ractl); - ractl->_index++; - i = ractl->_index + ractl->_nr_pages - index - 1; + ractl->_index += folio_nr_pages(folio); + i = ractl->_index + ractl->_nr_pages - index; IIUC, we don't need to update the _index after read_pages() as it already modifies it. We just need to move ractl->_index by 1 to move to the next index. > Cheers, > > Hannes