linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
       [not found] <1566157135-9423-1-git-send-email-linux.bhar@gmail.com>
@ 2019-08-18 19:38 ` Bharath Vedartham
  2019-08-18 19:51   ` Bharath Vedartham
  2019-08-19 12:56   ` Dimitri Sivanich
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE Bharath Vedartham
  2019-08-18 19:50 ` [Linux-kernel-mentees][PATCH v6 0/2] get_user_pages changes Bharath Vedartham
  2 siblings, 2 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-18 19:38 UTC (permalink / raw)
  To: sivanich, jhubbard
  Cc: jglisse, ira.weiny, gregkh, arnd, william.kucharski, hch,
	inux-kernel, linux-mm, linux-kernel-mentees, Bharath Vedartham,
	linux-kernel

For pages that were retained via get_user_pages*(), release those pages
via the new put_user_page*() routines, instead of via put_page() or
release_pages().

This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
("mm: introduce put_user_page*(), placeholder versions").

Cc: Ira Weiny <ira.weiny@intel.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
---
 drivers/misc/sgi-gru/grufault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
index 4b713a8..61b3447 100644
--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -188,7 +188,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
 	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
 		return -EFAULT;
 	*paddr = page_to_phys(page);
-	put_page(page);
+	put_user_page(page);
 	return 0;
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE
       [not found] <1566157135-9423-1-git-send-email-linux.bhar@gmail.com>
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*() Bharath Vedartham
@ 2019-08-18 19:38 ` Bharath Vedartham
  2019-08-18 19:51   ` Bharath Vedartham
  2019-08-19 13:00   ` Dimitri Sivanich
  2019-08-18 19:50 ` [Linux-kernel-mentees][PATCH v6 0/2] get_user_pages changes Bharath Vedartham
  2 siblings, 2 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-18 19:38 UTC (permalink / raw)
  To: sivanich, jhubbard
  Cc: jglisse, ira.weiny, gregkh, arnd, william.kucharski, hch,
	inux-kernel, linux-mm, linux-kernel-mentees, Bharath Vedartham,
	linux-kernel

is_vm_hugetlb_page will always return false if CONFIG_HUGETLB_PAGE is
not set.

Cc: Ira Weiny <ira.weiny@intel.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
---
 drivers/misc/sgi-gru/grufault.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
index 61b3447..bce47af 100644
--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -180,11 +180,11 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
 {
 	struct page *page;
 
-#ifdef CONFIG_HUGETLB_PAGE
-	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
-#else
-	*pageshift = PAGE_SHIFT;
-#endif
+	if (unlikely(is_vm_hugetlb_page(vma)))
+		*pageshift = HPAGE_SHIFT;
+	else
+		*pageshift = PAGE_SHIFT;
+
 	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
 		return -EFAULT;
 	*paddr = page_to_phys(page);
@@ -238,11 +238,12 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
 		return 1;
 
 	*paddr = pte_pfn(pte) << PAGE_SHIFT;
-#ifdef CONFIG_HUGETLB_PAGE
-	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
-#else
-	*pageshift = PAGE_SHIFT;
-#endif
+
+	if (unlikely(is_vm_hugetlb_page(vma)))
+		*pageshift = HPAGE_SHIFT;
+	else
+		*pageshift = PAGE_SHIFT;
+
 	return 0;
 
 err:
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 0/2] get_user_pages changes
       [not found] <1566157135-9423-1-git-send-email-linux.bhar@gmail.com>
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*() Bharath Vedartham
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE Bharath Vedartham
@ 2019-08-18 19:50 ` Bharath Vedartham
  2 siblings, 0 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-18 19:50 UTC (permalink / raw)
  To: sivanich, jhubbard; +Cc: linux-kernel

On Mon, Aug 19, 2019 at 01:08:53AM +0530, Bharath Vedartham wrote:
CC'ing lkml, the mail id was wrong.

> This version only converts put_page to put_user_page and removes
> an unecessary ifdef. 
> 
> It does not convert atomic_pte_lookup to __get_user_pages as
> gru_vtop could run in an interrupt context in which we can't assume
> current as __get_user_pages does.
> 
> Bharath Vedartham (2):
>   sgi-gru: Convert put_page() to put_user_page*()
>   sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE
> 
>  drivers/misc/sgi-gru/grufault.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*() Bharath Vedartham
@ 2019-08-18 19:51   ` Bharath Vedartham
  2019-08-19 12:56   ` Dimitri Sivanich
  1 sibling, 0 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-18 19:51 UTC (permalink / raw)
  To: sivanich, jhubbard
  Cc: jglisse, ira.weiny, gregkh, arnd, william.kucharski, hch,
	linux-kernel, linux-mm, linux-kernel-mentees

CC'ing lkml.

On Mon, Aug 19, 2019 at 01:08:54AM +0530, Bharath Vedartham wrote:
> For pages that were retained via get_user_pages*(), release those pages
> via the new put_user_page*() routines, instead of via put_page() or
> release_pages().
> 
> This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> ("mm: introduce put_user_page*(), placeholder versions").
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Dimitri Sivanich <sivanich@sgi.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: William Kucharski <william.kucharski@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel-mentees@lists.linuxfoundation.org
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> ---
>  drivers/misc/sgi-gru/grufault.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> index 4b713a8..61b3447 100644
> --- a/drivers/misc/sgi-gru/grufault.c
> +++ b/drivers/misc/sgi-gru/grufault.c
> @@ -188,7 +188,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
>  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
>  		return -EFAULT;
>  	*paddr = page_to_phys(page);
> -	put_page(page);
> +	put_user_page(page);
>  	return 0;
>  }
>  
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE Bharath Vedartham
@ 2019-08-18 19:51   ` Bharath Vedartham
  2019-08-19 13:00   ` Dimitri Sivanich
  1 sibling, 0 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-18 19:51 UTC (permalink / raw)
  To: sivanich, jhubbard
  Cc: jglisse, ira.weiny, gregkh, arnd, william.kucharski, hch,
	linux-kernel, linux-mm, linux-kernel-mentees

CC'ing lkml.

On Mon, Aug 19, 2019 at 01:08:55AM +0530, Bharath Vedartham wrote:
> is_vm_hugetlb_page will always return false if CONFIG_HUGETLB_PAGE is
> not set.
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Dimitri Sivanich <sivanich@sgi.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: William Kucharski <william.kucharski@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel-mentees@lists.linuxfoundation.org
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> ---
>  drivers/misc/sgi-gru/grufault.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> index 61b3447..bce47af 100644
> --- a/drivers/misc/sgi-gru/grufault.c
> +++ b/drivers/misc/sgi-gru/grufault.c
> @@ -180,11 +180,11 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
>  {
>  	struct page *page;
>  
> -#ifdef CONFIG_HUGETLB_PAGE
> -	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
> -#else
> -	*pageshift = PAGE_SHIFT;
> -#endif
> +	if (unlikely(is_vm_hugetlb_page(vma)))
> +		*pageshift = HPAGE_SHIFT;
> +	else
> +		*pageshift = PAGE_SHIFT;
> +
>  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
>  		return -EFAULT;
>  	*paddr = page_to_phys(page);
> @@ -238,11 +238,12 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
>  		return 1;
>  
>  	*paddr = pte_pfn(pte) << PAGE_SHIFT;
> -#ifdef CONFIG_HUGETLB_PAGE
> -	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
> -#else
> -	*pageshift = PAGE_SHIFT;
> -#endif
> +
> +	if (unlikely(is_vm_hugetlb_page(vma)))
> +		*pageshift = HPAGE_SHIFT;
> +	else
> +		*pageshift = PAGE_SHIFT;
> +
>  	return 0;
>  
>  err:
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*() Bharath Vedartham
  2019-08-18 19:51   ` Bharath Vedartham
@ 2019-08-19 12:56   ` Dimitri Sivanich
  2019-08-19 12:56     ` Dimitri Sivanich
  2019-08-19 19:06     ` Bharath Vedartham
  1 sibling, 2 replies; 14+ messages in thread
From: Dimitri Sivanich @ 2019-08-19 12:56 UTC (permalink / raw)
  To: Bharath Vedartham
  Cc: sivanich, jhubbard, jglisse, ira.weiny, gregkh, arnd,
	william.kucharski, hch, inux-kernel, linux-mm,
	linux-kernel-mentees, linux-kernel

Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>

On Mon, Aug 19, 2019 at 01:08:54AM +0530, Bharath Vedartham wrote:
> For pages that were retained via get_user_pages*(), release those pages
> via the new put_user_page*() routines, instead of via put_page() or
> release_pages().
> 
> This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> ("mm: introduce put_user_page*(), placeholder versions").
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Dimitri Sivanich <sivanich@sgi.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: William Kucharski <william.kucharski@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel-mentees@lists.linuxfoundation.org
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> ---
>  drivers/misc/sgi-gru/grufault.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> index 4b713a8..61b3447 100644
> --- a/drivers/misc/sgi-gru/grufault.c
> +++ b/drivers/misc/sgi-gru/grufault.c
> @@ -188,7 +188,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
>  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
>  		return -EFAULT;
>  	*paddr = page_to_phys(page);
> -	put_page(page);
> +	put_user_page(page);
>  	return 0;
>  }
>  
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-19 12:56   ` Dimitri Sivanich
@ 2019-08-19 12:56     ` Dimitri Sivanich
  2019-08-19 19:06     ` Bharath Vedartham
  1 sibling, 0 replies; 14+ messages in thread
From: Dimitri Sivanich @ 2019-08-19 12:56 UTC (permalink / raw)
  To: Bharath Vedartham
  Cc: sivanich, jhubbard, jglisse, ira.weiny, gregkh, arnd,
	william.kucharski, hch, inux-kernel, linux-mm,
	linux-kernel-mentees, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 1688 bytes --]

Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>

On Mon, Aug 19, 2019 at 01:08:54AM +0530, Bharath Vedartham wrote:
> For pages that were retained via get_user_pages*(), release those pages
> via the new put_user_page*() routines, instead of via put_page() or
> release_pages().
> 
> This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> ("mm: introduce put_user_page*(), placeholder versions").
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Dimitri Sivanich <sivanich@sgi.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: William Kucharski <william.kucharski@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel-mentees@lists.linuxfoundation.org
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> ---
>  drivers/misc/sgi-gru/grufault.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> index 4b713a8..61b3447 100644
> --- a/drivers/misc/sgi-gru/grufault.c
> +++ b/drivers/misc/sgi-gru/grufault.c
> @@ -188,7 +188,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
>  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
>  		return -EFAULT;
>  	*paddr = page_to_phys(page);
> -	put_page(page);
> +	put_user_page(page);
>  	return 0;
>  }
>  
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE
  2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE Bharath Vedartham
  2019-08-18 19:51   ` Bharath Vedartham
@ 2019-08-19 13:00   ` Dimitri Sivanich
  2019-08-19 19:07     ` Bharath Vedartham
  1 sibling, 1 reply; 14+ messages in thread
From: Dimitri Sivanich @ 2019-08-19 13:00 UTC (permalink / raw)
  To: Bharath Vedartham
  Cc: sivanich, jhubbard, jglisse, ira.weiny, gregkh, arnd,
	william.kucharski, hch, linux-mm, linux-kernel-mentees,
	linux-kernel

Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>

On Mon, Aug 19, 2019 at 01:08:55AM +0530, Bharath Vedartham wrote:
> is_vm_hugetlb_page will always return false if CONFIG_HUGETLB_PAGE is
> not set.
> 
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Dimitri Sivanich <sivanich@sgi.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: William Kucharski <william.kucharski@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: linux-kernel-mentees@lists.linuxfoundation.org
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> ---
>  drivers/misc/sgi-gru/grufault.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> index 61b3447..bce47af 100644
> --- a/drivers/misc/sgi-gru/grufault.c
> +++ b/drivers/misc/sgi-gru/grufault.c
> @@ -180,11 +180,11 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
>  {
>  	struct page *page;
>  
> -#ifdef CONFIG_HUGETLB_PAGE
> -	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
> -#else
> -	*pageshift = PAGE_SHIFT;
> -#endif
> +	if (unlikely(is_vm_hugetlb_page(vma)))
> +		*pageshift = HPAGE_SHIFT;
> +	else
> +		*pageshift = PAGE_SHIFT;
> +
>  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
>  		return -EFAULT;
>  	*paddr = page_to_phys(page);
> @@ -238,11 +238,12 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
>  		return 1;
>  
>  	*paddr = pte_pfn(pte) << PAGE_SHIFT;
> -#ifdef CONFIG_HUGETLB_PAGE
> -	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
> -#else
> -	*pageshift = PAGE_SHIFT;
> -#endif
> +
> +	if (unlikely(is_vm_hugetlb_page(vma)))
> +		*pageshift = HPAGE_SHIFT;
> +	else
> +		*pageshift = PAGE_SHIFT;
> +
>  	return 0;
>  
>  err:
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-19 12:56   ` Dimitri Sivanich
  2019-08-19 12:56     ` Dimitri Sivanich
@ 2019-08-19 19:06     ` Bharath Vedartham
  2019-08-19 19:30       ` John Hubbard
  1 sibling, 1 reply; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-19 19:06 UTC (permalink / raw)
  To: Dimitri Sivanich
  Cc: jhubbard, jglisse, ira.weiny, gregkh, arnd, william.kucharski,
	hch, inux-kernel, linux-mm, linux-kernel-mentees, linux-kernel

On Mon, Aug 19, 2019 at 07:56:11AM -0500, Dimitri Sivanich wrote:
> Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>
Thanks!

John, would you like to take this patch into your miscellaneous
conversions patch set?

Thank you
Bharath
> On Mon, Aug 19, 2019 at 01:08:54AM +0530, Bharath Vedartham wrote:
> > For pages that were retained via get_user_pages*(), release those pages
> > via the new put_user_page*() routines, instead of via put_page() or
> > release_pages().
> > 
> > This is part a tree-wide conversion, as described in commit fc1d8e7cca2d
> > ("mm: introduce put_user_page*(), placeholder versions").
> > 
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: John Hubbard <jhubbard@nvidia.com>
> > Cc: Jérôme Glisse <jglisse@redhat.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Dimitri Sivanich <sivanich@sgi.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: William Kucharski <william.kucharski@oracle.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-mm@kvack.org
> > Cc: linux-kernel-mentees@lists.linuxfoundation.org
> > Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> > Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> > Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> > Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> > ---
> >  drivers/misc/sgi-gru/grufault.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> > index 4b713a8..61b3447 100644
> > --- a/drivers/misc/sgi-gru/grufault.c
> > +++ b/drivers/misc/sgi-gru/grufault.c
> > @@ -188,7 +188,7 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
> >  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
> >  		return -EFAULT;
> >  	*paddr = page_to_phys(page);
> > -	put_page(page);
> > +	put_user_page(page);
> >  	return 0;
> >  }
> >  
> > -- 
> > 2.7.4
> > 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE
  2019-08-19 13:00   ` Dimitri Sivanich
@ 2019-08-19 19:07     ` Bharath Vedartham
  0 siblings, 0 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-19 19:07 UTC (permalink / raw)
  To: Dimitri Sivanich
  Cc: jhubbard, jglisse, ira.weiny, gregkh, arnd, william.kucharski,
	hch, linux-mm, linux-kernel-mentees, linux-kernel

On Mon, Aug 19, 2019 at 08:00:57AM -0500, Dimitri Sivanich wrote:
> Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>
Thanks! 
> On Mon, Aug 19, 2019 at 01:08:55AM +0530, Bharath Vedartham wrote:
> > is_vm_hugetlb_page will always return false if CONFIG_HUGETLB_PAGE is
> > not set.
> > 
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: John Hubbard <jhubbard@nvidia.com>
> > Cc: Jérôme Glisse <jglisse@redhat.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: Dimitri Sivanich <sivanich@sgi.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: William Kucharski <william.kucharski@oracle.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-mm@kvack.org
> > Cc: linux-kernel-mentees@lists.linuxfoundation.org
> > Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> > Reviewed-by: John Hubbard <jhubbard@nvidia.com>
> > Reviewed-by: William Kucharski <william.kucharski@oracle.com>
> > Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
> > ---
> >  drivers/misc/sgi-gru/grufault.c | 21 +++++++++++----------
> >  1 file changed, 11 insertions(+), 10 deletions(-)
> > 
> > diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c
> > index 61b3447..bce47af 100644
> > --- a/drivers/misc/sgi-gru/grufault.c
> > +++ b/drivers/misc/sgi-gru/grufault.c
> > @@ -180,11 +180,11 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
> >  {
> >  	struct page *page;
> >  
> > -#ifdef CONFIG_HUGETLB_PAGE
> > -	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
> > -#else
> > -	*pageshift = PAGE_SHIFT;
> > -#endif
> > +	if (unlikely(is_vm_hugetlb_page(vma)))
> > +		*pageshift = HPAGE_SHIFT;
> > +	else
> > +		*pageshift = PAGE_SHIFT;
> > +
> >  	if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
> >  		return -EFAULT;
> >  	*paddr = page_to_phys(page);
> > @@ -238,11 +238,12 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr,
> >  		return 1;
> >  
> >  	*paddr = pte_pfn(pte) << PAGE_SHIFT;
> > -#ifdef CONFIG_HUGETLB_PAGE
> > -	*pageshift = is_vm_hugetlb_page(vma) ? HPAGE_SHIFT : PAGE_SHIFT;
> > -#else
> > -	*pageshift = PAGE_SHIFT;
> > -#endif
> > +
> > +	if (unlikely(is_vm_hugetlb_page(vma)))
> > +		*pageshift = HPAGE_SHIFT;
> > +	else
> > +		*pageshift = PAGE_SHIFT;
> > +
> >  	return 0;
> >  
> >  err:
> > -- 
> > 2.7.4
> > 

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-19 19:06     ` Bharath Vedartham
@ 2019-08-19 19:30       ` John Hubbard
  2019-08-20  8:18         ` Michal Hocko
  2019-08-20 16:24         ` Bharath Vedartham
  0 siblings, 2 replies; 14+ messages in thread
From: John Hubbard @ 2019-08-19 19:30 UTC (permalink / raw)
  To: Bharath Vedartham, Dimitri Sivanich, Andrew Morton
  Cc: jglisse, ira.weiny, gregkh, arnd, william.kucharski, hch,
	inux-kernel, linux-mm, linux-kernel-mentees, linux-kernel,
	Michal Hocko

On 8/19/19 12:06 PM, Bharath Vedartham wrote:
> On Mon, Aug 19, 2019 at 07:56:11AM -0500, Dimitri Sivanich wrote:
>> Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>
> Thanks!
> 
> John, would you like to take this patch into your miscellaneous
> conversions patch set?
> 

(+Andrew and Michal, so they know where all this is going.)

Sure, although that conversion series [1] is on a brief hold, because
there are additional conversions desired, and the API is still under
discussion. Also, reading between the lines of Michal's response [2]
about it, I think people would prefer that the next revision include
the following, for each conversion site:

Conversion of gup/put_page sites:

Before:

	get_user_pages(...);
	...
	for each page:
		put_page();

After:
	
	gup_flags |= FOLL_PIN; (maybe FOLL_LONGTERM in some cases)
	vaddr_pin_user_pages(...gup_flags...)
	...
	vaddr_unpin_user_pages(); /* which invokes put_user_page() */

Fortunately, it's not harmful for the simpler conversion from put_page()
to put_user_page() to happen first, and in fact those have usually led
to simplifications, paving the way to make it easier to call
vaddr_unpin_user_pages(), once it's ready. (And showing exactly what
to convert, too.)

So for now, I'm going to just build on top of Ira's tree, and once the
vaddr*() API settles down, I'll send out an updated series that attempts
to include the reviews and ACKs so far (I'll have to review them, but
make a note that review or ACK was done for part of the conversion),
and adds the additional gup(FOLL_PIN), and uses vaddr*() wrappers instead of
gup/pup.

[1] https://lore.kernel.org/r/20190807013340.9706-1-jhubbard@nvidia.com

[2] https://lore.kernel.org/r/20190809175210.GR18351@dhcp22.suse.cz


thanks,
-- 
John Hubbard
NVIDIA

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-19 19:30       ` John Hubbard
@ 2019-08-20  8:18         ` Michal Hocko
  2019-08-20 20:50           ` John Hubbard
  2019-08-20 16:24         ` Bharath Vedartham
  1 sibling, 1 reply; 14+ messages in thread
From: Michal Hocko @ 2019-08-20  8:18 UTC (permalink / raw)
  To: John Hubbard
  Cc: Bharath Vedartham, Dimitri Sivanich, Andrew Morton, jglisse,
	ira.weiny, gregkh, arnd, william.kucharski, hch, inux-kernel,
	linux-mm, linux-kernel-mentees, linux-kernel

On Mon 19-08-19 12:30:18, John Hubbard wrote:
> On 8/19/19 12:06 PM, Bharath Vedartham wrote:
> > On Mon, Aug 19, 2019 at 07:56:11AM -0500, Dimitri Sivanich wrote:
> > > Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>
> > Thanks!
> > 
> > John, would you like to take this patch into your miscellaneous
> > conversions patch set?
> > 
> 
> (+Andrew and Michal, so they know where all this is going.)
> 
> Sure, although that conversion series [1] is on a brief hold, because
> there are additional conversions desired, and the API is still under
> discussion. Also, reading between the lines of Michal's response [2]
> about it, I think people would prefer that the next revision include
> the following, for each conversion site:
> 
> Conversion of gup/put_page sites:
> 
> Before:
> 
> 	get_user_pages(...);
> 	...
> 	for each page:
> 		put_page();
> 
> After:
> 	
> 	gup_flags |= FOLL_PIN; (maybe FOLL_LONGTERM in some cases)
> 	vaddr_pin_user_pages(...gup_flags...)

I was hoping that FOLL_PIN would be handled by vaddr_pin_user_pages.

> 	...
> 	vaddr_unpin_user_pages(); /* which invokes put_user_page() */
> 
> Fortunately, it's not harmful for the simpler conversion from put_page()
> to put_user_page() to happen first, and in fact those have usually led
> to simplifications, paving the way to make it easier to call
> vaddr_unpin_user_pages(), once it's ready. (And showing exactly what
> to convert, too.)

If that makes the later conversion easier then no real objections from
me. Assuming that the current put_user_page conversions are correct of
course (I have the mlock one and potentials that falls into the same
category in mind).
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-19 19:30       ` John Hubbard
  2019-08-20  8:18         ` Michal Hocko
@ 2019-08-20 16:24         ` Bharath Vedartham
  1 sibling, 0 replies; 14+ messages in thread
From: Bharath Vedartham @ 2019-08-20 16:24 UTC (permalink / raw)
  To: John Hubbard
  Cc: Dimitri Sivanich, Andrew Morton, jglisse, ira.weiny, gregkh,
	arnd, william.kucharski, hch, linux-kernel, linux-mm,
	linux-kernel-mentees, Michal Hocko

On Mon, Aug 19, 2019 at 12:30:18PM -0700, John Hubbard wrote:
> On 8/19/19 12:06 PM, Bharath Vedartham wrote:
> >On Mon, Aug 19, 2019 at 07:56:11AM -0500, Dimitri Sivanich wrote:
> >>Reviewed-by: Dimitri Sivanich <sivanich@hpe.com>
> >Thanks!
> >
> >John, would you like to take this patch into your miscellaneous
> >conversions patch set?
> >
> 
> (+Andrew and Michal, so they know where all this is going.)
> 
> Sure, although that conversion series [1] is on a brief hold, because
> there are additional conversions desired, and the API is still under
> discussion. Also, reading between the lines of Michal's response [2]
> about it, I think people would prefer that the next revision include
> the following, for each conversion site:
> 
> Conversion of gup/put_page sites:
> 
> Before:
> 
> 	get_user_pages(...);
> 	...
> 	for each page:
> 		put_page();
> 
> After:
> 	
> 	gup_flags |= FOLL_PIN; (maybe FOLL_LONGTERM in some cases)
> 	vaddr_pin_user_pages(...gup_flags...)
> 	...
> 	vaddr_unpin_user_pages(); /* which invokes put_user_page() */
> 
> Fortunately, it's not harmful for the simpler conversion from put_page()
> to put_user_page() to happen first, and in fact those have usually led
> to simplifications, paving the way to make it easier to call
> vaddr_unpin_user_pages(), once it's ready. (And showing exactly what
> to convert, too.)
> 
> So for now, I'm going to just build on top of Ira's tree, and once the
> vaddr*() API settles down, I'll send out an updated series that attempts
> to include the reviews and ACKs so far (I'll have to review them, but
> make a note that review or ACK was done for part of the conversion),
> and adds the additional gup(FOLL_PIN), and uses vaddr*() wrappers instead of
> gup/pup.
> 
> [1] https://lore.kernel.org/r/20190807013340.9706-1-jhubbard@nvidia.com
> 
> [2] https://lore.kernel.org/r/20190809175210.GR18351@dhcp22.suse.cz
> 
Cc' lkml(I missed out the 'l' in this series). 

sounds good. It makes sense to keep the entire gup in the kernel rather
than to expose it outside. 

I ll make sure to checkout the emails on vaddr*() API and pace my work
on it accordingly.

Thank you
Bharath
> thanks,
> -- 
> John Hubbard
> NVIDIA

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*()
  2019-08-20  8:18         ` Michal Hocko
@ 2019-08-20 20:50           ` John Hubbard
  0 siblings, 0 replies; 14+ messages in thread
From: John Hubbard @ 2019-08-20 20:50 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Bharath Vedartham, Dimitri Sivanich, Andrew Morton, jglisse,
	ira.weiny, gregkh, arnd, william.kucharski, hch, inux-kernel,
	linux-mm, linux-kernel-mentees, linux-kernel

On 8/20/19 1:18 AM, Michal Hocko wrote:
> On Mon 19-08-19 12:30:18, John Hubbard wrote:
>> On 8/19/19 12:06 PM, Bharath Vedartham wrote:
>>> On Mon, Aug 19, 2019 at 07:56:11AM -0500, Dimitri Sivanich wrote:
...
>> Conversion of gup/put_page sites:
>>
>> Before:
>>
>> 	get_user_pages(...);
>> 	...
>> 	for each page:
>> 		put_page();
>>
>> After:
>> 	
>> 	gup_flags |= FOLL_PIN; (maybe FOLL_LONGTERM in some cases)
>> 	vaddr_pin_user_pages(...gup_flags...)
> 
> I was hoping that FOLL_PIN would be handled by vaddr_pin_user_pages.
> 

Good point: now that we've got the 4 cases summarized, it turns out
that either FOLL_PIN is required, or there is no need to call
vaddr_pin_user_pages() at all.  So we can go back to setting FOLL_PIN
inside it, which is of course much better for maintenance. Great!


>> 	...
>> 	vaddr_unpin_user_pages(); /* which invokes put_user_page() */
>>
>> Fortunately, it's not harmful for the simpler conversion from put_page()
>> to put_user_page() to happen first, and in fact those have usually led
>> to simplifications, paving the way to make it easier to call
>> vaddr_unpin_user_pages(), once it's ready. (And showing exactly what
>> to convert, too.)
> 
> If that makes the later conversion easier then no real objections from
> me. Assuming that the current put_user_page conversions are correct of
> course (I have the mlock one and potentials that falls into the same
> category in mind).
> 

Agreed: only correct conversions should be done. Not the incorrect
ones. ahem.  :)

thanks,
-- 
John Hubbard
NVIDIA

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-08-20 20:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1566157135-9423-1-git-send-email-linux.bhar@gmail.com>
2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH v6 1/2] sgi-gru: Convert put_page() to put_user_page*() Bharath Vedartham
2019-08-18 19:51   ` Bharath Vedartham
2019-08-19 12:56   ` Dimitri Sivanich
2019-08-19 12:56     ` Dimitri Sivanich
2019-08-19 19:06     ` Bharath Vedartham
2019-08-19 19:30       ` John Hubbard
2019-08-20  8:18         ` Michal Hocko
2019-08-20 20:50           ` John Hubbard
2019-08-20 16:24         ` Bharath Vedartham
2019-08-18 19:38 ` [Linux-kernel-mentees][PATCH 2/2] sgi-gru: Remove uneccessary ifdef for CONFIG_HUGETLB_PAGE Bharath Vedartham
2019-08-18 19:51   ` Bharath Vedartham
2019-08-19 13:00   ` Dimitri Sivanich
2019-08-19 19:07     ` Bharath Vedartham
2019-08-18 19:50 ` [Linux-kernel-mentees][PATCH v6 0/2] get_user_pages changes Bharath Vedartham

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).