diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-07-24 23:37:13 -0400 |
---|---|---|
committer | Matthew Wilcox (Oracle) <willy@infradead.org> | 2022-03-21 13:01:36 -0400 |
commit | 4687fdbb805a92ce5a9f23042c436dc64fef8b77 (patch) | |
tree | 0aafd7008b80d2328f28e0b4832f698c901acec4 /mm/filemap.c | |
parent | 56a4d67c264e37014b8392cba9869c7fe904ed1e (diff) | |
download | linux-starfive-4687fdbb805a92ce5a9f23042c436dc64fef8b77.tar.gz linux-starfive-4687fdbb805a92ce5a9f23042c436dc64fef8b77.tar.bz2 linux-starfive-4687fdbb805a92ce5a9f23042c436dc64fef8b77.zip |
mm/filemap: Support VM_HUGEPAGE for file mappings
If the VM_HUGEPAGE flag is set, attempt to allocate PMD-sized folios
during readahead, even if we have no history of readahead being
successful.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index fe764225ae99..7608ee030662 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2995,6 +2995,24 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf) struct file *fpin = NULL; unsigned int mmap_miss; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + /* Use the readahead code, even if readahead is disabled */ + if (vmf->vma->vm_flags & VM_HUGEPAGE) { + fpin = maybe_unlock_mmap_for_io(vmf, fpin); + ractl._index &= ~((unsigned long)HPAGE_PMD_NR - 1); + ra->size = HPAGE_PMD_NR; + /* + * Fetch two PMD folios, so we get the chance to actually + * readahead, unless we've been told not to. + */ + if (!(vmf->vma->vm_flags & VM_RAND_READ)) + ra->size *= 2; + ra->async_size = HPAGE_PMD_NR; + page_cache_ra_order(&ractl, ra, HPAGE_PMD_ORDER); + return fpin; + } +#endif + /* If we don't want any read-ahead, don't bother */ if (vmf->vma->vm_flags & VM_RAND_READ) return fpin; |