All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lstoakes@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Matthew Wilcox <willy@infradead.org>,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH v3 4/7] mm/gup: introduce the FOLL_SAME_FILE GUP flag
Date: Mon, 17 Apr 2023 12:27:22 +0100	[thread overview]
Message-ID: <e614a3c1-d933-40aa-9cee-a4175b5d0cec@lucifer.local> (raw)
In-Reply-To: <e4087551-c5d3-e82d-3c4e-dcfa476a971e@redhat.com>

On Mon, Apr 17, 2023 at 01:13:58PM +0200, David Hildenbrand wrote:
> On 15.04.23 14:09, Lorenzo Stoakes wrote:
> > This flag causes GUP to assert that all VMAs within the input range possess
> > the same vma->vm_file. If not, the operation fails.
> >
> > This is part of a patch series which eliminates the vmas parameter from the
> > GUP API, implementing the one remaining assertion within the entire kernel
> > that requires access to the VMAs associated with a GUP range.
> >
> > Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
>
> [...]
>
> > ---
> >   						&start, &nr_pages, i,
> > @@ -1595,7 +1603,7 @@ long faultin_vma_page_range(struct vm_area_struct *vma, unsigned long start,
> >   	 * We want to report -EINVAL instead of -EFAULT for any permission
> >   	 * problems or incompatible mappings.
> >   	 */
> > -	if (check_vma_flags(vma, gup_flags))
> > +	if (check_vma_flags(vma, vma->vm_file, gup_flags))
> >   		return -EINVAL;
>
> FOLL_SAME_FILE is never set here, just pass NULL instead of vma->vm_file.
>
>
> As we're not allowing to drop the mmap lock, why can't io_uring simply go
> over all VMAs once, after pinning succeeded, and make sure that the files
> match (or even before pinning)?
>
> In most cases, we're dealing with a single VMA only, it's not like the
> common case is that io_uring pins accross 100s of VMAs.
>
> So I really wonder if the GUP complexity is justified by something.

This is one that needs some input from Jens I think (added to cc, for some
reason I didn't include him on this one but I did on the one updating uring
to use it).

I agree it'd be better not to introduce this flag if we can avoid it,
intent was to avoid having to add complexity to the uring code when we're
already iterating through VMAs in the GUP code, but as you say it's highly
likely most cases will consist of a single VMA anyway.

If Jens is OK with us iterating here I'm more than happy to respin without
adding the flag!

> (removing the VMAs is certainly a welcome surprise -- as it doesn't make any
> sense when used with FOLL_UNLOCKABLE).

This is a product of reading the GUP code when writing the GUP bit for the
book and wishing it were more sane :) I suspect I'll have some more patches
in this area aimed at marrying the disparate APIs where sensible to do so.

>
> --
> Thanks,
>
> David / dhildenb
>
>

  reply	other threads:[~2023-04-17 11:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 12:09 [PATCH v3 0/7] remove the vmas parameter from GUP APIs Lorenzo Stoakes
2023-04-15 12:09 ` [PATCH v3 1/7] mm/gup: remove unused vmas parameter from get_user_pages() Lorenzo Stoakes
2023-04-15 12:09   ` Lorenzo Stoakes
2023-04-15 12:09   ` Lorenzo Stoakes
2023-04-17 10:55   ` David Hildenbrand
2023-04-17 10:55     ` David Hildenbrand
2023-04-17 10:55     ` David Hildenbrand
2023-04-15 12:09 ` [PATCH v3 2/7] mm/gup: remove unused vmas parameter from pin_user_pages_remote() Lorenzo Stoakes
2023-04-17 10:55   ` David Hildenbrand
2023-04-15 12:09 ` [PATCH v3 3/7] mm/gup: remove vmas parameter from get_user_pages_remote() Lorenzo Stoakes
2023-04-15 12:09   ` Lorenzo Stoakes
2023-04-17 10:52   ` Catalin Marinas
2023-04-17 10:52     ` Catalin Marinas
2023-04-17 11:01   ` David Hildenbrand
2023-04-17 11:01     ` David Hildenbrand
2023-04-15 12:09 ` [PATCH v3 4/7] mm/gup: introduce the FOLL_SAME_FILE GUP flag Lorenzo Stoakes
2023-04-17 11:13   ` David Hildenbrand
2023-04-17 11:27     ` Lorenzo Stoakes [this message]
2023-04-15 12:09 ` [PATCH v3 5/7] io_uring: rsrc: use FOLL_SAME_FILE on pin_user_pages() Lorenzo Stoakes
2023-04-15 12:09 ` [PATCH v3 6/7] mm/gup: remove vmas parameter from pin_user_pages() Lorenzo Stoakes
2023-04-15 12:09   ` Lorenzo Stoakes
2023-04-17 11:14   ` David Hildenbrand
2023-04-17 11:14     ` David Hildenbrand
2023-04-17 11:14     ` David Hildenbrand
2023-04-17 11:59   ` Dennis Dalessandro
2023-04-17 11:59     ` Dennis Dalessandro
2023-04-15 12:09 ` [PATCH v3 7/7] mm/gup: remove vmas array from internal GUP functions Lorenzo Stoakes
2023-04-17 11:15   ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e614a3c1-d933-40aa-9cee-a4175b5d0cec@lucifer.local \
    --to=lstoakes@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.