diff mbox

[1/2] mm: introduce put_user_page(), placeholder version

Message ID 20180709080554.21931-2-jhubbard@nvidia.com (mailing list archive)
State New, archived
Headers show

Commit Message

john.hubbard@gmail.com July 9, 2018, 8:05 a.m. UTC
From: John Hubbard <jhubbard@nvidia.com>

Introduces put_user_page(), which simply calls put_page().
This provides a safe way to update all get_user_pages*() callers,
so that they call put_user_page(), instead of put_page().

Also adds release_user_pages(), a drop-in replacement for
release_pages(). This is intended to be easily grep-able,
for later performance improvements, since release_user_pages
is not batched like release_pages is, and is significantly
slower.

Subsequent patches will add functionality to put_user_page().

Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 include/linux/mm.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

kernel test robot July 9, 2018, 10:08 a.m. UTC | #1
Hi John,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.18-rc4 next-20180709]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/john-hubbard-gmail-com/mm-fs-put_user_page-proposal/20180709-173653
config: x86_64-randconfig-x015-201827 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/john-hubbard-gmail-com/mm-fs-put_user_page-proposal/20180709-173653 HEAD 3f7da023c5e08e49489e39be9cde820b0d1ab4d6 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

>> drivers/platform//goldfish/goldfish_pipe.c:334:13: error: conflicting types for 'release_user_pages'
    static void release_user_pages(struct page **pages, int pages_count,
                ^~~~~~~~~~~~~~~~~~
   In file included from include/linux/scatterlist.h:8:0,
                    from include/linux/dma-mapping.h:11,
                    from drivers/platform//goldfish/goldfish_pipe.c:62:
   include/linux/mm.h:933:20: note: previous definition of 'release_user_pages' was here
    static inline void release_user_pages(struct page **pages,
                       ^~~~~~~~~~~~~~~~~~

vim +/release_user_pages +334 drivers/platform//goldfish/goldfish_pipe.c

726ea1a8 Jin Qian             2017-04-20  333  
726ea1a8 Jin Qian             2017-04-20 @334  static void release_user_pages(struct page **pages, int pages_count,
726ea1a8 Jin Qian             2017-04-20  335  	int is_write, s32 consumed_size)
c89f2750 David 'Digit' Turner 2013-01-21  336  {
726ea1a8 Jin Qian             2017-04-20  337  	int i;
c89f2750 David 'Digit' Turner 2013-01-21  338  
726ea1a8 Jin Qian             2017-04-20  339  	for (i = 0; i < pages_count; i++) {
726ea1a8 Jin Qian             2017-04-20  340  		if (!is_write && consumed_size > 0)
726ea1a8 Jin Qian             2017-04-20  341  			set_page_dirty(pages[i]);
726ea1a8 Jin Qian             2017-04-20  342  		put_page(pages[i]);
726ea1a8 Jin Qian             2017-04-20  343  	}
726ea1a8 Jin Qian             2017-04-20  344  }
726ea1a8 Jin Qian             2017-04-20  345  

:::::: The code at line 334 was first introduced by commit
:::::: 726ea1a8ea96b2bba34ee2073b58f0770800701c goldfish_pipe: An implementation of more parallel pipe

:::::: TO: Jin Qian <jinqian@android.com>
:::::: CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Jason Gunthorpe July 9, 2018, 3:53 p.m. UTC | #2
On Mon, Jul 09, 2018 at 01:05:53AM -0700, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
> 
> Introduces put_user_page(), which simply calls put_page().
> This provides a safe way to update all get_user_pages*() callers,
> so that they call put_user_page(), instead of put_page().
> 
> Also adds release_user_pages(), a drop-in replacement for
> release_pages(). This is intended to be easily grep-able,
> for later performance improvements, since release_user_pages
> is not batched like release_pages is, and is significantly
> slower.
> 
> Subsequent patches will add functionality to put_user_page().
> 
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
>  include/linux/mm.h | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index a0fbb9ffe380..db4a211aad79 100644
> +++ b/include/linux/mm.h
> @@ -923,6 +923,20 @@ static inline void put_page(struct page *page)
>  		__put_page(page);
>  }
>  
> +/* Placeholder version, until all get_user_pages*() callers are updated. */
> +static inline void put_user_page(struct page *page)
> +{
> +	put_page(page);
> +}
> +
> +/* A drop-in replacement for release_pages(): */
> +static inline void release_user_pages(struct page **pages,
> +				      unsigned long npages)
> +{
> +	while (npages)
> +		put_user_page(pages[--npages]);
> +}
> +
>  #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
>  #define SECTION_IN_PAGE_FLAGS
>  #endif

Just as question: Do you think it is worthwhile to have a
release_user_page_dirtied() helper as well?

Ie to indicate that a pages that were grabbed under GUP FOLL_WRITE
were actually written too?

Keeps more of these unimportant details out of the drivers..

Jason
Jan Kara July 9, 2018, 4:11 p.m. UTC | #3
On Mon 09-07-18 09:53:57, Jason Gunthorpe wrote:
> On Mon, Jul 09, 2018 at 01:05:53AM -0700, john.hubbard@gmail.com wrote:
> > From: John Hubbard <jhubbard@nvidia.com>
> > 
> > Introduces put_user_page(), which simply calls put_page().
> > This provides a safe way to update all get_user_pages*() callers,
> > so that they call put_user_page(), instead of put_page().
> > 
> > Also adds release_user_pages(), a drop-in replacement for
> > release_pages(). This is intended to be easily grep-able,
> > for later performance improvements, since release_user_pages
> > is not batched like release_pages is, and is significantly
> > slower.
> > 
> > Subsequent patches will add functionality to put_user_page().
> > 
> > Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> >  include/linux/mm.h | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> > 
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index a0fbb9ffe380..db4a211aad79 100644
> > +++ b/include/linux/mm.h
> > @@ -923,6 +923,20 @@ static inline void put_page(struct page *page)
> >  		__put_page(page);
> >  }
> >  
> > +/* Placeholder version, until all get_user_pages*() callers are updated. */
> > +static inline void put_user_page(struct page *page)
> > +{
> > +	put_page(page);
> > +}
> > +
> > +/* A drop-in replacement for release_pages(): */
> > +static inline void release_user_pages(struct page **pages,
> > +				      unsigned long npages)
> > +{
> > +	while (npages)
> > +		put_user_page(pages[--npages]);
> > +}
> > +
> >  #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
> >  #define SECTION_IN_PAGE_FLAGS
> >  #endif
> 
> Just as question: Do you think it is worthwhile to have a
> release_user_page_dirtied() helper as well?
> 
> Ie to indicate that a pages that were grabbed under GUP FOLL_WRITE
> were actually written too?
> 
> Keeps more of these unimportant details out of the drivers..

Yeah, I think that would be nice as well.

								Honza
John Hubbard July 9, 2018, 6:48 p.m. UTC | #4
On 07/09/2018 03:08 AM, kbuild test robot wrote:
> Hi John,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on linus/master]
...
> 
>>> drivers/platform//goldfish/goldfish_pipe.c:334:13: error: conflicting types for 'release_user_pages'
>     static void release_user_pages(struct page **pages, int pages_count,
>                 ^~~~~~~~~~~~~~~~~~

Yes. Patches #1 and #2 need to be combined here. I'll do that in the next version, which will probably include several of the easier put_user_page() conversions, as well.

thanks,
diff mbox

Patch

diff --git a/include/linux/mm.h b/include/linux/mm.h
index a0fbb9ffe380..db4a211aad79 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -923,6 +923,20 @@  static inline void put_page(struct page *page)
 		__put_page(page);
 }
 
+/* Placeholder version, until all get_user_pages*() callers are updated. */
+static inline void put_user_page(struct page *page)
+{
+	put_page(page);
+}
+
+/* A drop-in replacement for release_pages(): */
+static inline void release_user_pages(struct page **pages,
+				      unsigned long npages)
+{
+	while (npages)
+		put_user_page(pages[--npages]);
+}
+
 #if defined(CONFIG_SPARSEMEM) && !defined(CONFIG_SPARSEMEM_VMEMMAP)
 #define SECTION_IN_PAGE_FLAGS
 #endif