Re: [PATCH v3 2/8] binder: concurrent page installation
From: Carlos Llamas
Date: Tue Nov 12 2024 - 11:01:44 EST
On Tue, Nov 12, 2024 at 12:10:20PM +0100, David Hildenbrand wrote:
> On 08.11.24 20:10, Carlos Llamas wrote:
> > + ret = vm_insert_page(vma, addr, page);
> > + switch (ret) {
> > + case -EBUSY:
> > + /*
> > + * EBUSY is ok. Someone installed the pte first but the
> > + * lru_page->page_ptr has not been updated yet. Discard
> > + * our page and look up the one already installed.
> > + */
> > + ret = 0;
> > + __free_page(page);
> > + npages = get_user_pages_remote(alloc->mm, addr, 1, 0, &page, NULL);
>
> This will trigger a page fault if we don't find what we expect (are races
> with e.g., MADV_DONTNEED possible?), is that really desired or not a
> problem?
This is fine. As of now, binder blocks its page faults:
static vm_fault_t binder_vm_fault(struct vm_fault *vmf)
{
return VM_FAULT_SIGBUS;
}
If we race with something like MADV_DONTNEED then we would just
propagate the -EFAULT error. I could add FOLL_NOFAULT to the gup remote
call to make it evident we don't care though.
--
Carlos Llamas