From: John Hubbard <jhubbard@nvidia.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
"Christoph Hellwig" <hch@infradead.org>,
"Dan Williams" <dan.j.williams@intel.com>,
"Dave Chinner" <david@fromorbit.com>, "Jan Kara" <jack@suse.cz>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Jérôme Glisse" <jglisse@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
linux-rdma@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] mm/gup: introduce vaddr_pin_pages_remote()
Date: Mon, 12 Aug 2019 15:21:49 -0700 [thread overview]
Message-ID: <0b66c1f8-c694-7971-b2d3-e1dd53a0f103@nvidia.com> (raw)
In-Reply-To: <20190812220340.GA26305@iweiny-DESK2.sc.intel.com>
On 8/12/19 3:03 PM, Ira Weiny wrote:
> On Sun, Aug 11, 2019 at 06:50:44PM -0700, john.hubbard@gmail.com wrote:
>> From: John Hubbard <jhubbard@nvidia.com>
...
>> +/**
>> + * vaddr_pin_pages pin pages by virtual address and return the pages to the
>
> vaddr_pin_pages_remote
>
> Fixed in my tree.
thanks. :)
>
>> + * user.
>> + *
>> + * @tsk: the task_struct to use for page fault accounting, or
>> + * NULL if faults are not to be recorded.
>> + * @mm: mm_struct of target mm
>> + * @addr: start address
>> + * @nr_pages: number of pages to pin
>> + * @gup_flags: flags to use for the pin
>> + * @pages: array of pages returned
>> + * @vaddr_pin: initialized meta information this pin is to be associated
>> + * with.
>> + *
>> + * This is the "vaddr_pin_pages" corresponding variant to
>> + * get_user_pages_remote(), but with FOLL_PIN semantics: the implementation sets
>> + * FOLL_PIN. That, in turn, means that the pages must ultimately be released
>> + * by put_user_page().
>> + */
>> +long vaddr_pin_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
>> + unsigned long start, unsigned long nr_pages,
>> + unsigned int gup_flags, struct page **pages,
>> + struct vm_area_struct **vmas, int *locked,
>> + struct vaddr_pin *vaddr_pin)
>> +{
>> + gup_flags |= FOLL_TOUCH | FOLL_REMOTE | FOLL_PIN;
>> +
>> + return __get_user_pages_locked(tsk, mm, start, nr_pages, pages, vmas,
>> + locked, gup_flags, vaddr_pin);
>> +}
>> +EXPORT_SYMBOL(vaddr_pin_pages_remote);
>> +
>> /**
>> * vaddr_unpin_pages_dirty_lock - counterpart to vaddr_pin_pages
>> *
>> @@ -2536,3 +2568,21 @@ void vaddr_unpin_pages_dirty_lock(struct page **pages, unsigned long nr_pages,
>> __put_user_pages_dirty_lock(vaddr_pin, pages, nr_pages, make_dirty);
>> }
>> EXPORT_SYMBOL(vaddr_unpin_pages_dirty_lock);
>> +
>> +/**
>> + * vaddr_unpin_pages - simple, non-dirtying counterpart to vaddr_pin_pages
>> + *
>> + * @pages: array of pages returned
>> + * @nr_pages: number of pages in pages
>> + * @vaddr_pin: same information passed to vaddr_pin_pages
>> + *
>> + * Like vaddr_unpin_pages_dirty_lock, but for non-dirty pages. Useful in putting
>> + * back pages in an error case: they were never made dirty.
>> + */
>> +void vaddr_unpin_pages(struct page **pages, unsigned long nr_pages,
>> + struct vaddr_pin *vaddr_pin)
>> +{
>> + __put_user_pages_dirty_lock(vaddr_pin, pages, nr_pages, false);
>> +}
>> +EXPORT_SYMBOL(vaddr_unpin_pages);
>
> Rather than have another wrapping call why don't we just do this? Would it be
> so bad to just have to specify false for make_dirty?
Sure, passing in false for make_dirty is fine, and in fact, there may even be
error cases I've forgotten about that *want* to dirty the page.
I thought about these variants, and realized that we don't generally need to
say "lock" anymore, because we're going to forcibly use set_page_dirty_lock
(rather than set_page_dirty) in this part of the code. And a shorter name
is nice. Since you've dropped both "_dirty" and "_lock" from the function
name, it's still nice and short even though we pass in make_dirty as an arg.
So that's a long-winded, "the API below looks good to me". :)
>
>
> diff --git a/mm/gup.c b/mm/gup.c
> index e77b250c1307..ca660a5e8206 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2540,7 +2540,7 @@ long vaddr_pin_pages_remote(struct task_struct *tsk, struct mm_struct *mm,
> EXPORT_SYMBOL(vaddr_pin_pages_remote);
>
> /**
> - * vaddr_unpin_pages_dirty_lock - counterpart to vaddr_pin_pages
> + * vaddr_unpin_pages - counterpart to vaddr_pin_pages
> *
> * @pages: array of pages returned
> * @nr_pages: number of pages in pages
> @@ -2551,26 +2551,9 @@ EXPORT_SYMBOL(vaddr_pin_pages_remote);
> * in vaddr_pin_pages should be passed back into this call for proper
> * tracking.
> */
> -void vaddr_unpin_pages_dirty_lock(struct page **pages, unsigned long nr_pages,
> - struct vaddr_pin *vaddr_pin, bool make_dirty)
> +void vaddr_unpin_pages(struct page **pages, unsigned long nr_pages,
> + struct vaddr_pin *vaddr_pin, bool make_dirty)
> {
> __put_user_pages_dirty_lock(vaddr_pin, pages, nr_pages, make_dirty);
> }
> EXPORT_SYMBOL(vaddr_unpin_pages_dirty_lock);
> -
> -/**
> - * vaddr_unpin_pages - simple, non-dirtying counterpart to vaddr_pin_pages
> - *
> - * @pages: array of pages returned
> - * @nr_pages: number of pages in pages
> - * @vaddr_pin: same information passed to vaddr_pin_pages
> - *
> - * Like vaddr_unpin_pages_dirty_lock, but for non-dirty pages. Useful in putting
> - * back pages in an error case: they were never made dirty.
> - */
> -void vaddr_unpin_pages(struct page **pages, unsigned long nr_pages,
> - struct vaddr_pin *vaddr_pin)
> -{
> - __put_user_pages_dirty_lock(vaddr_pin, pages, nr_pages, false);
> -}
> -EXPORT_SYMBOL(vaddr_unpin_pages);
>
thanks,
--
John Hubbard
NVIDIA
next prev parent reply other threads:[~2019-08-12 22:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 1:50 [RFC PATCH 0/2] mm/gup: introduce vaddr_pin_pages_remote(), FOLL_PIN john.hubbard
2019-08-12 1:50 ` [RFC PATCH 1/2] mm/gup: introduce FOLL_PIN flag for get_user_pages() john.hubbard
2019-08-12 1:50 ` [RFC PATCH 2/2] mm/gup: introduce vaddr_pin_pages_remote() john.hubbard
2019-08-12 22:03 ` Ira Weiny
2019-08-12 22:21 ` John Hubbard [this message]
2019-08-12 23:49 ` Ira Weiny
2019-08-13 0:07 ` John Hubbard
2019-08-13 21:08 ` Ira Weiny
2019-08-14 0:51 ` John Hubbard
2019-08-14 0:56 ` John Hubbard
2019-08-14 23:50 ` Ira Weiny
2019-08-15 0:02 ` John Hubbard
2019-08-15 3:01 ` John Hubbard
2019-08-15 13:26 ` Jan Kara
2019-08-15 13:35 ` Jan Kara
2019-08-15 14:51 ` Jason Gunthorpe
2019-08-15 17:32 ` Ira Weiny
2019-08-15 17:41 ` John Hubbard
2019-08-16 2:14 ` John Hubbard
2019-08-16 15:41 ` Jan Kara
2019-08-16 18:33 ` Ira Weiny
2019-08-16 18:50 ` John Hubbard
2019-08-16 21:59 ` Ira Weiny
2019-08-16 22:36 ` John Hubbard
2019-08-16 8:47 ` Vlastimil Babka
2019-08-16 15:44 ` Jan Kara
2019-08-16 15:52 ` Jerome Glisse
2019-08-16 16:13 ` Jan Kara
2019-08-16 16:31 ` Jason Gunthorpe
2019-08-16 16:54 ` Jerome Glisse
2019-08-16 17:04 ` Jason Gunthorpe
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=0b66c1f8-c694-7971-b2d3-e1dd53a0f103@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=jgg@ziepe.ca \
--cc=jglisse@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).