diff mbox series

[RFC,v1,1/2] fixup for 9947ea2c1e608e32669d5caeb67b3e3fba3309e8 "mm/gup: track FOLL_PIN pages"

Message ID 20200228154322.329228-2-imbrenda@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series add callbacks for inaccessible pages | expand

Commit Message

Claudio Imbrenda Feb. 28, 2020, 3:43 p.m. UTC
in case pin fails, we need to unpin, just a put_page will not be enough

Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
---
 mm/gup.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Claudio Imbrenda Feb. 28, 2020, 3:45 p.m. UTC | #1
sorry, this one was a mistake, please ignore


On Fri, 28 Feb 2020 16:43:20 +0100
Claudio Imbrenda <imbrenda@linux.ibm.com> wrote:

> in case pin fails, we need to unpin, just a put_page will not be
> enough
> 
> Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
>  mm/gup.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index f589299b0d4a..0b9a806898f3 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2134,7 +2134,10 @@ static int gup_pte_range(pmd_t pmd, unsigned
> long addr, unsigned long end, goto pte_unmap;
>  
>  		if (unlikely(pte_val(pte) != pte_val(*ptep))) {
> -			put_page(head);
> +			if (flags & FOLL_GET)
> +				put_page(head);
> +			else if (flags & FOLL_PIN)
> +				unpin_user_page(head);
>  			goto pte_unmap;
>  		}
>
diff mbox series

Patch

diff --git a/mm/gup.c b/mm/gup.c
index f589299b0d4a..0b9a806898f3 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2134,7 +2134,10 @@  static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end,
 			goto pte_unmap;
 
 		if (unlikely(pte_val(pte) != pte_val(*ptep))) {
-			put_page(head);
+			if (flags & FOLL_GET)
+				put_page(head);
+			else if (flags & FOLL_PIN)
+				unpin_user_page(head);
 			goto pte_unmap;
 		}