diff --git a/mm/readahead.c b/mm/readahead.c index e5d0a56218de..4d33be2af009 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -578,7 +578,11 @@ static void ondemand_readahead(struct readahead_control *ractl, 1UL << order); if (index == expected || index == (ra->start + ra->size)) { ra->start += ra->size; - ra->size = get_next_ra_size(ra, max_pages); + /* + * In the case of MADV_HUGEPAGE, the actual size might exceed + * the readahead window. + */ + ra->size = max(ra->size, get_next_ra_size(ra, max_pages)); ra->async_size = ra->size; goto readit; }