All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-04 19:46 ` [PATCH v3] " john.hubbard
@ 2019-03-04 11:57   ` Ira Weiny
  2019-03-04 11:58   ` Ira Weiny
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Ira Weiny @ 2019-03-04 11:57 UTC (permalink / raw)
  To: john.hubbard
  Cc: linux-mm, Andrew Morton, LKML, John Hubbard, Leon Romanovsky,
	Jason Gunthorpe, Doug Ledford, linux-rdma

On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
> 
> 1. Bug fix: fix an off by one error in the code that
> cleans up if it fails to dma-map a page, after having
> done a get_user_pages_remote() on a range of pages.
> 
> 2. Refinement: for that same cleanup code, release_pages()
> is better than put_page() in a loop.
> 
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

> ---
>  drivers/infiniband/core/umem_odp.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
> index acb882f279cb..d45735b02e07 100644
> --- a/drivers/infiniband/core/umem_odp.c
> +++ b/drivers/infiniband/core/umem_odp.c
> @@ -40,6 +40,7 @@
>  #include <linux/vmalloc.h>
>  #include <linux/hugetlb.h>
>  #include <linux/interval_tree_generic.h>
> +#include <linux/pagemap.h>
>  
>  #include <rdma/ib_verbs.h>
>  #include <rdma/ib_umem.h>
> @@ -684,9 +685,11 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
>  		mutex_unlock(&umem_odp->umem_mutex);
>  
>  		if (ret < 0) {
> -			/* Release left over pages when handling errors. */
> -			for (++j; j < npages; ++j)
> -				put_page(local_page_list[j]);
> +			/*
> +			 * Release pages, starting at the the first page
> +			 * that experienced an error.
> +			 */
> +			release_pages(&local_page_list[j], npages - j);
>  			break;
>  		}
>  	}
> -- 
> 2.21.0
> 

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

* Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-04 19:46 ` [PATCH v3] " john.hubbard
  2019-03-04 11:57   ` Ira Weiny
@ 2019-03-04 11:58   ` Ira Weiny
  2019-03-05 15:04     ` Yuval Shaia
  2019-03-04 19:53   ` Leon Romanovsky
  2019-03-04 20:31   ` Jason Gunthorpe
  3 siblings, 1 reply; 8+ messages in thread
From: Ira Weiny @ 2019-03-04 11:58 UTC (permalink / raw)
  To: john.hubbard
  Cc: linux-mm, Andrew Morton, LKML, John Hubbard, Leon Romanovsky,
	Jason Gunthorpe, Doug Ledford, linux-rdma

On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
> 
> 1. Bug fix: fix an off by one error in the code that
> cleans up if it fails to dma-map a page, after having
> done a get_user_pages_remote() on a range of pages.
> 
> 2. Refinement: for that same cleanup code, release_pages()
> is better than put_page() in a loop.
> 
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>

I meant...

Reviewed-by: Ira Weiny <ira.weiny@intel.com>

<sigh>  just a bit too quick on the keyboard before lunch...  ;-)

Ira


> ---
>  drivers/infiniband/core/umem_odp.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
> index acb882f279cb..d45735b02e07 100644
> --- a/drivers/infiniband/core/umem_odp.c
> +++ b/drivers/infiniband/core/umem_odp.c
> @@ -40,6 +40,7 @@
>  #include <linux/vmalloc.h>
>  #include <linux/hugetlb.h>
>  #include <linux/interval_tree_generic.h>
> +#include <linux/pagemap.h>
>  
>  #include <rdma/ib_verbs.h>
>  #include <rdma/ib_umem.h>
> @@ -684,9 +685,11 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
>  		mutex_unlock(&umem_odp->umem_mutex);
>  
>  		if (ret < 0) {
> -			/* Release left over pages when handling errors. */
> -			for (++j; j < npages; ++j)
> -				put_page(local_page_list[j]);
> +			/*
> +			 * Release pages, starting at the the first page
> +			 * that experienced an error.
> +			 */
> +			release_pages(&local_page_list[j], npages - j);
>  			break;
>  		}
>  	}
> -- 
> 2.21.0
> 

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

* [PATCH v3 0/1] RDMA/umem: minor bug fix in error handling path
@ 2019-03-04 19:46 john.hubbard
  2019-03-04 19:46 ` [PATCH v3] " john.hubbard
  0 siblings, 1 reply; 8+ messages in thread
From: john.hubbard @ 2019-03-04 19:46 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, LKML, John Hubbard, Leon Romanovsky, Ira Weiny,
	Jason Gunthorpe, Doug Ledford, linux-rdma

From: John Hubbard <jhubbard@nvidia.com>

Hi,

Ira Weiny alerted me to a couple of places where I'd missed a change from
put_page() to put_user_page(), in my pending patchsets. But when I
attempted to dive more deeply into that code, I ran into a bug in the
cleanup code. Leon Romanovsky has confirmed that and requested this
simplified patch to fix it, so here it is.

Changes since v2:

1) Removed the part of the patch that tried to delete "dead code",
because that code was dealing with huge pages.

2) Reverted the pr_*() line shortening, so as to keep this to only
the minimal bug fix required.

3) Rebased to today's linux.git.

Cc: Leon Romanovsky <leon@kernel.org>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Doug Ledford <dledford@redhat.com>
Cc: linux-rdma@vger.kernel.org
Cc: linux-mm@kvack.org

John Hubbard (1):
  RDMA/umem: minor bug fix in error handling path

 drivers/infiniband/core/umem_odp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

-- 
2.21.0

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

* [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-04 19:46 [PATCH v3 0/1] RDMA/umem: minor bug fix in error handling path john.hubbard
@ 2019-03-04 19:46 ` john.hubbard
  2019-03-04 11:57   ` Ira Weiny
                     ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: john.hubbard @ 2019-03-04 19:46 UTC (permalink / raw)
  To: linux-mm
  Cc: Andrew Morton, LKML, John Hubbard, Leon Romanovsky, Ira Weiny,
	Jason Gunthorpe, Doug Ledford, linux-rdma

From: John Hubbard <jhubbard@nvidia.com>

1. Bug fix: fix an off by one error in the code that
cleans up if it fails to dma-map a page, after having
done a get_user_pages_remote() on a range of pages.

2. Refinement: for that same cleanup code, release_pages()
is better than put_page() in a loop.

Cc: Leon Romanovsky <leon@kernel.org>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Doug Ledford <dledford@redhat.com>
Cc: linux-rdma@vger.kernel.org
Cc: linux-mm@kvack.org
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
 drivers/infiniband/core/umem_odp.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
index acb882f279cb..d45735b02e07 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -40,6 +40,7 @@
 #include <linux/vmalloc.h>
 #include <linux/hugetlb.h>
 #include <linux/interval_tree_generic.h>
+#include <linux/pagemap.h>
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_umem.h>
@@ -684,9 +685,11 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
 		mutex_unlock(&umem_odp->umem_mutex);
 
 		if (ret < 0) {
-			/* Release left over pages when handling errors. */
-			for (++j; j < npages; ++j)
-				put_page(local_page_list[j]);
+			/*
+			 * Release pages, starting at the the first page
+			 * that experienced an error.
+			 */
+			release_pages(&local_page_list[j], npages - j);
 			break;
 		}
 	}
-- 
2.21.0

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

* Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-04 19:46 ` [PATCH v3] " john.hubbard
  2019-03-04 11:57   ` Ira Weiny
  2019-03-04 11:58   ` Ira Weiny
@ 2019-03-04 19:53   ` Leon Romanovsky
  2019-03-04 20:31   ` Jason Gunthorpe
  3 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2019-03-04 19:53 UTC (permalink / raw)
  To: john.hubbard
  Cc: linux-mm, Andrew Morton, LKML, John Hubbard, Ira Weiny,
	Jason Gunthorpe, Doug Ledford, linux-rdma

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
>
> 1. Bug fix: fix an off by one error in the code that
> cleans up if it fails to dma-map a page, after having
> done a get_user_pages_remote() on a range of pages.
>
> 2. Refinement: for that same cleanup code, release_pages()
> is better than put_page() in a loop.
>
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> ---
>  drivers/infiniband/core/umem_odp.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>

Thanks,
Acked-by: Leon Romanovsky <leonro@mellanox.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-04 19:46 ` [PATCH v3] " john.hubbard
                     ` (2 preceding siblings ...)
  2019-03-04 19:53   ` Leon Romanovsky
@ 2019-03-04 20:31   ` Jason Gunthorpe
  3 siblings, 0 replies; 8+ messages in thread
From: Jason Gunthorpe @ 2019-03-04 20:31 UTC (permalink / raw)
  To: john.hubbard
  Cc: linux-mm, Andrew Morton, LKML, John Hubbard, Leon Romanovsky,
	Ira Weiny, Doug Ledford, linux-rdma

On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote:
> From: John Hubbard <jhubbard@nvidia.com>
> 
> 1. Bug fix: fix an off by one error in the code that
> cleans up if it fails to dma-map a page, after having
> done a get_user_pages_remote() on a range of pages.
> 
> 2. Refinement: for that same cleanup code, release_pages()
> is better than put_page() in a loop.
> 
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Doug Ledford <dledford@redhat.com>
> Cc: linux-rdma@vger.kernel.org
> Cc: linux-mm@kvack.org
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Acked-by: Leon Romanovsky <leonro@mellanox.com>
> ---
>  drivers/infiniband/core/umem_odp.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)

Applied to for-next, thanks

Jason

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

* Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-04 11:58   ` Ira Weiny
@ 2019-03-05 15:04     ` Yuval Shaia
  2019-03-05 16:45       ` Leon Romanovsky
  0 siblings, 1 reply; 8+ messages in thread
From: Yuval Shaia @ 2019-03-05 15:04 UTC (permalink / raw)
  To: Ira Weiny
  Cc: john.hubbard, linux-mm, Andrew Morton, LKML, John Hubbard,
	Leon Romanovsky, Jason Gunthorpe, Doug Ledford, linux-rdma

On Mon, Mar 04, 2019 at 03:58:15AM -0800, Ira Weiny wrote:
> On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote:
> > From: John Hubbard <jhubbard@nvidia.com>
> > 
> > 1. Bug fix: fix an off by one error in the code that
> > cleans up if it fails to dma-map a page, after having
> > done a get_user_pages_remote() on a range of pages.
> > 
> > 2. Refinement: for that same cleanup code, release_pages()
> > is better than put_page() in a loop.
> > 
> > Cc: Leon Romanovsky <leon@kernel.org>
> > Cc: Ira Weiny <ira.weiny@intel.com>
> > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Doug Ledford <dledford@redhat.com>
> > Cc: linux-rdma@vger.kernel.org
> > Cc: linux-mm@kvack.org
> > Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> 
> I meant...
> 
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> 
> <sigh>  just a bit too quick on the keyboard before lunch...  ;-)
> 
> Ira

I have this mapping in vimrc so i just have to do shift+!

map ! o\rReviewed-by: Yuval Shaia <yuval.shaia@oracle.com>\r^[

> 
> 
> > ---
> >  drivers/infiniband/core/umem_odp.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
> > index acb882f279cb..d45735b02e07 100644
> > --- a/drivers/infiniband/core/umem_odp.c
> > +++ b/drivers/infiniband/core/umem_odp.c
> > @@ -40,6 +40,7 @@
> >  #include <linux/vmalloc.h>
> >  #include <linux/hugetlb.h>
> >  #include <linux/interval_tree_generic.h>
> > +#include <linux/pagemap.h>
> >  
> >  #include <rdma/ib_verbs.h>
> >  #include <rdma/ib_umem.h>
> > @@ -684,9 +685,11 @@ int ib_umem_odp_map_dma_pages(struct ib_umem_odp *umem_odp, u64 user_virt,
> >  		mutex_unlock(&umem_odp->umem_mutex);
> >  
> >  		if (ret < 0) {
> > -			/* Release left over pages when handling errors. */
> > -			for (++j; j < npages; ++j)
> > -				put_page(local_page_list[j]);
> > +			/*
> > +			 * Release pages, starting at the the first page
> > +			 * that experienced an error.
> > +			 */
> > +			release_pages(&local_page_list[j], npages - j);
> >  			break;
> >  		}
> >  	}
> > -- 
> > 2.21.0
> > 

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

* Re: [PATCH v3] RDMA/umem: minor bug fix in error handling path
  2019-03-05 15:04     ` Yuval Shaia
@ 2019-03-05 16:45       ` Leon Romanovsky
  0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2019-03-05 16:45 UTC (permalink / raw)
  To: Yuval Shaia
  Cc: Ira Weiny, john.hubbard, linux-mm, Andrew Morton, LKML,
	John Hubbard, Jason Gunthorpe, Doug Ledford, linux-rdma

[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]

On Tue, Mar 05, 2019 at 05:04:06PM +0200, Yuval Shaia wrote:
> On Mon, Mar 04, 2019 at 03:58:15AM -0800, Ira Weiny wrote:
> > On Mon, Mar 04, 2019 at 11:46:45AM -0800, john.hubbard@gmail.com wrote:
> > > From: John Hubbard <jhubbard@nvidia.com>
> > >
> > > 1. Bug fix: fix an off by one error in the code that
> > > cleans up if it fails to dma-map a page, after having
> > > done a get_user_pages_remote() on a range of pages.
> > >
> > > 2. Refinement: for that same cleanup code, release_pages()
> > > is better than put_page() in a loop.
> > >
> > > Cc: Leon Romanovsky <leon@kernel.org>
> > > Cc: Ira Weiny <ira.weiny@intel.com>
> > > Cc: Jason Gunthorpe <jgg@ziepe.ca>
> > > Cc: Andrew Morton <akpm@linux-foundation.org>
> > > Cc: Doug Ledford <dledford@redhat.com>
> > > Cc: linux-rdma@vger.kernel.org
> > > Cc: linux-mm@kvack.org
> > > Signed-off-by: John Hubbard <jhubbard@nvidia.com>
> >
> > I meant...
> >
> > Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> >
> > <sigh>  just a bit too quick on the keyboard before lunch...  ;-)
> >
> > Ira
>
> I have this mapping in vimrc so i just have to do shift+!
>
> map ! o\rReviewed-by: Yuval Shaia <yuval.shaia@oracle.com>\r^[

I have something similar, but limited to responses through mail client only
and mapped to "rt" key combination.

in my .vimrc:

augroup filetypedetect
	" Mail
	autocmd BufRead,BufNewFile *mutt-* setfiletype mail
	 " Add Reviewed-by tag and delete rest of the email
	function! RBtag()
		r~/.vim/mutt/rb-tag.txt
	endfunction
	nmap rt :call RBtag()<CR>2j<CR>dG<CR>
augroup END

Thanks

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2019-03-05 16:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 19:46 [PATCH v3 0/1] RDMA/umem: minor bug fix in error handling path john.hubbard
2019-03-04 19:46 ` [PATCH v3] " john.hubbard
2019-03-04 11:57   ` Ira Weiny
2019-03-04 11:58   ` Ira Weiny
2019-03-05 15:04     ` Yuval Shaia
2019-03-05 16:45       ` Leon Romanovsky
2019-03-04 19:53   ` Leon Romanovsky
2019-03-04 20:31   ` Jason Gunthorpe

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.