Message ID | 20250220204033.284730-1-kent.overstreet@linux.dev (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | filemap: check for folio order < mapping min order | expand |
On Thu, Feb 20, 2025 at 03:40:33PM -0500, Kent Overstreet wrote: > accidentally inserting a folio < mapping min order causes the readahead > code to go into an infinite loop, which is unpleasant. We already have: VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_folio_order(mapping), folio); If you're not enabling CONFIG_DEBUG_VM in your testing, I think that's an oversight on your part.
diff --git a/mm/filemap.c b/mm/filemap.c index 804d7365680c..b88bed922fff 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -973,6 +973,11 @@ int filemap_add_folio(struct address_space *mapping, struct folio *folio, void *shadow = NULL; int ret; + if (WARN(folio_order(folio) < mapping_min_folio_order(mapping), + "folio order %u < mapping min order %u\n", + folio_order(folio), mapping_min_folio_order(mapping))) + return -EINVAL; + ret = mem_cgroup_charge(folio, NULL, gfp); if (ret) return ret;
accidentally inserting a folio < mapping min order causes the readahead code to go into an infinite loop, which is unpleasant. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev> --- mm/filemap.c | 5 +++++ 1 file changed, 5 insertions(+)