Skip to content

Commit

Permalink
mm/readahead: limit page cache size in page_cache_ra_order()
Browse files Browse the repository at this point in the history
In page_cache_ra_order(), the maximal order of the page cache to be
allocated shouldn't be larger than MAX_PAGECACHE_ORDER.  Otherwise, it's
possible the large page cache can't be supported by xarray when the
corresponding xarray entry is split.

For example, HPAGE_PMD_ORDER is 13 on ARM64 when the base page size is
64KB.  The PMD-sized page cache can't be supported by xarray.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: 793917d ("mm/readahead: Add large folio readahead")
Signed-off-by: Gavin Shan <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Cc: Darrick J. Wong <[email protected]>
Cc: Don Dutile <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Ryan Roberts <[email protected]>
Cc: William Kucharski <[email protected]>
Cc: Zhenyu Zhang <[email protected]>
Cc: <[email protected]>	[5.18+]
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
Gavin Shan authored and akpm00 committed Jul 4, 2024
1 parent 099d906 commit 1f789a4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mm/readahead.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,11 @@ void page_cache_ra_order(struct readahead_control *ractl,

limit = min(limit, index + ra->size - 1);

if (new_order < MAX_PAGECACHE_ORDER) {
if (new_order < MAX_PAGECACHE_ORDER)
new_order += 2;
new_order = min_t(unsigned int, MAX_PAGECACHE_ORDER, new_order);
new_order = min_t(unsigned int, new_order, ilog2(ra->size));
}

new_order = min_t(unsigned int, MAX_PAGECACHE_ORDER, new_order);
new_order = min_t(unsigned int, new_order, ilog2(ra->size));

/* See comment in page_cache_ra_unbounded() */
nofs = memalloc_nofs_save();
Expand Down

0 comments on commit 1f789a4

Please sign in to comment.