From 9ef3adc15b3027ca21c70684dd0d5faabf1b6ce0 Mon Sep 17 00:00:00 2001 From: Alexander Winkowski Date: Fri, 12 Jan 2024 04:59:40 +0000 Subject: [PATCH] Revert "BACKPORT: FROMLIST: mm: implement speculative handling in filemap_fault()" This reverts commit 5b5bd362f1c527e1844c3c57f54fcb0736f998f9. Change-Id: I3197cb64766cd5e102794d24c946bb88a8e73652 Signed-off-by: Alexander Winkowski --- mm/filemap.c | 45 +-------------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 623550f9a9d3..c8b28c6538a2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2634,9 +2634,7 @@ static struct file *do_async_mmap_readahead(struct vm_fault *vmf, * it in the page cache, and handles the special cases reasonably without * having a lot of duplicated code. * - * If FAULT_FLAG_SPECULATIVE is set, this function runs with elevated vma - * refcount and with mmap lock not held. - * Otherwise, vma->vm_mm->mmap_sem must be held on entry. + * vma->vm_mm->mmap_sem must be held on entry (except FAULT_FLAG_SPECULATIVE). * * If our return value has VM_FAULT_RETRY set, it's because the mmap_sem * may be dropped before doing I/O or by lock_page_maybe_drop_mmap(). @@ -2661,47 +2659,6 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) struct page *page; vm_fault_t ret = 0; - if (vmf->flags & FAULT_FLAG_SPECULATIVE) { - page = find_get_page(mapping, offset); - if (unlikely(!page) || unlikely(PageReadahead(page))) - return VM_FAULT_RETRY; - - if (!trylock_page(page)) - return VM_FAULT_RETRY; - - if (unlikely(compound_head(page)->mapping != mapping)) - goto page_unlock; - VM_BUG_ON_PAGE(page_to_pgoff(page) != offset, page); - if (unlikely(!PageUptodate(page))) - goto page_unlock; - - max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); - if (unlikely(offset >= max_off)) - goto page_unlock; - - /* - * Update readahead mmap_miss statistic. - * - * Note that we are not sure if finish_fault() will - * manage to complete the transaction. If it fails, - * we'll come back to filemap_fault() non-speculative - * case which will update mmap_miss a second time. - * This is not ideal, we would prefer to guarantee the - * update will happen exactly once. - */ - if (!(vmf->vma->vm_flags & VM_RAND_READ) && ra->ra_pages) { - unsigned int mmap_miss = READ_ONCE(ra->mmap_miss); - if (mmap_miss) - WRITE_ONCE(ra->mmap_miss, --mmap_miss); - } - - vmf->page = page; - return VM_FAULT_LOCKED; -page_unlock: - unlock_page(page); - return VM_FAULT_RETRY; - } - max_off = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); if (unlikely(offset >= max_off)) return VM_FAULT_SIGBUS;