Skip to content

Commit 4687fdb

Browse files
author
Matthew Wilcox (Oracle)
committed
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) <[email protected]>
1 parent 56a4d67 commit 4687fdb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mm/filemap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,6 +2995,24 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
29952995
struct file *fpin = NULL;
29962996
unsigned int mmap_miss;
29972997

2998+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
2999+
/* Use the readahead code, even if readahead is disabled */
3000+
if (vmf->vma->vm_flags & VM_HUGEPAGE) {
3001+
fpin = maybe_unlock_mmap_for_io(vmf, fpin);
3002+
ractl._index &= ~((unsigned long)HPAGE_PMD_NR - 1);
3003+
ra->size = HPAGE_PMD_NR;
3004+
/*
3005+
* Fetch two PMD folios, so we get the chance to actually
3006+
* readahead, unless we've been told not to.
3007+
*/
3008+
if (!(vmf->vma->vm_flags & VM_RAND_READ))
3009+
ra->size *= 2;
3010+
ra->async_size = HPAGE_PMD_NR;
3011+
page_cache_ra_order(&ractl, ra, HPAGE_PMD_ORDER);
3012+
return fpin;
3013+
}
3014+
#endif
3015+
29983016
/* If we don't want any read-ahead, don't bother */
29993017
if (vmf->vma->vm_flags & VM_RAND_READ)
30003018
return fpin;

0 commit comments

Comments
 (0)