diff --git a/mm/readahead.c b/mm/readahead.c index 794d8ddc069720..e0bef7c0d7afe1 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -599,7 +599,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; }