Re: [PATCH 02/13] mm/filemap: convert fault and readahead logic to use vma_flags_t

From
Barry Song <baohua@kernel.org>
Date
2026-11-08 07:20:37
Also in
damon, kvm, linux-mm, linux-perf-users, linux-security-module, sashiko-reviews, selinux
Reply to
Lorenzo Stoakes (ARM), 2026-11-06
On Fri, Nov 6, 2026 at 7:53 PM Lorenzo Stoakes (ARM) [off-list ref] wrote:
[...]
quoted
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-late-2026-vma-flags-v1-0-0d3cd15ab75f@kernel.org?part=2
It seems these are valid, oops!

Andrew suggested a fix off-list, and I agreed to this as an in-place fixup to
avoid respin.

I have also updated the series locally to reflect this change:
Seems like a reasonable fix. maybe_unlock_mmap_for_io()
could have released mmap_lock, leaving the VMA
unprotected. but  ra->size *= 2 is still going there no matter
if the vma has disappeared

For the original patch combined with the fix,

Reviewed-by: Barry Song <baohua@kernel.org>
quoted hunk ↗ jump to hunk

----8<----
 mm/filemap.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
--- a/mm/filemap.c~mm-filemap-convert-fault-and-readahead-logic-to-use-vma_flags_t-fix
+++ a/mm/filemap.c
@@ -3410,6 +3410,7 @@ static struct file *do_sync_mmap_readahe

        if (force_thp_readahead) {
                unsigned long folio_nr_pages = 1UL << thp_order;
+               const bool random_read = vma_test(vma, VMA_RAND_READ_BIT);

                fpin = maybe_unlock_mmap_for_io(vmf, fpin);
                ractl._index &= ~(folio_nr_pages - 1);
@@ -3418,7 +3419,7 @@ static struct file *do_sync_mmap_readahe
                 * Fetch two folios so we get the chance to actually
                 * readahead, unless we've been told not to.
                 */
-               if (!vma_test(vma, VMA_RAND_READ_BIT))
+               if (!random_read)
                        ra->size *= 2;
                ra->async_size = folio_nr_pages;
                ra->order = thp_order;
@@ -3438,7 +3439,6 @@ static struct file *do_sync_mmap_readahe
                 * pad that might exist between sections, which would be a waste
                 * of memory.
                 */
-               struct vm_area_struct *vma = vmf->vma;
                const unsigned long start = vma_start_pgoff(vma);
                const unsigned long end = vma_end_pgoff(vma);
                unsigned long ra_end;
_
Thanks,
Barry
Thread (65 messages) 65 messages, 11 authors, last reply 16h ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help