Messages in this thread | | | From | Linus Torvalds <> | Date | Sat, 19 Dec 2020 12:34:17 -0800 | Subject | Re: [PATCH 1/2] mm: Allow architectures to request 'old' entries when prefaulting |
| |
On Sat, Dec 19, 2020 at 4:41 AM Kirill A. Shutemov <kirill@shutemov.name> wrote: > > @@ -2884,19 +2966,18 @@ void filemap_map_pages(struct vm_fault *vmf, > if (vmf->pte) > vmf->pte += xas.xa_index - last_pgoff; > last_pgoff = xas.xa_index; > - if (alloc_set_pte(vmf, page)) > - goto unlock; > + if (pte_none(*vmf->pte)) > + do_set_pte(vmf, page); > + /* no need to invalidate: a not-present page won't be cached */ > + update_mmu_cache(vma, vmf->address, vmf->pte); > unlock_page(head); > - goto next; > + continue;
This can't be right.
Look at what happens if "pte_none()" is not true.. It won't install the new pte, but it also won't drop the ref to the page.
So I think it needs to be
- if (alloc_set_pte(vmf, page)) + if (!pte_none(*vmf->pte)) goto unlock; + do_set_pte(vmf, page);
instead, so that the "if somebody else already filled the page table" case gets handled right.
Hmm?
Linus
| |