linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: John Hubbard <jhubbard@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Jan Kara <jack@suse.cz>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH] mm/gup: further simplify __gup_device_huge()
Date: Thu, 16 Sep 2021 10:35:09 +0200	[thread overview]
Message-ID: <20210916083509.GB10610@quack2.suse.cz> (raw)
In-Reply-To: <20210904004224.86391-1-jhubbard@nvidia.com>

On Fri 03-09-21 17:42:24, John Hubbard wrote:
> commit 6401c4eb57f9 ("mm: gup: fix potential pgmap refcnt leak in
> __gup_device_huge()") simplified the return paths, but didn't go quite
> far enough, as discussed in [1].
> 
> Remove the "ret" variable entirely, because there is enough information
> already available to provide the return value.
> 
> [1] https://lore.kernel.org/r/CAHk-=wgQTRX=5SkCmS+zfmpqubGHGJvXX_HgnPG8JSpHKHBMeg@mail.gmail.com
> 
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Miaohe Lin <linmiaohe@huawei.com>
> Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
> Cc: Jan Kara <jack@suse.cz>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Signed-off-by: John Hubbard <jhubbard@nvidia.com>

Looks sane. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  mm/gup.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index 9935a4480710..6e62f1518c1f 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2241,7 +2241,6 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr,
>  {
>  	int nr_start = *nr;
>  	struct dev_pagemap *pgmap = NULL;
> -	int ret = 1;
>  
>  	do {
>  		struct page *page = pfn_to_page(pfn);
> @@ -2249,14 +2248,12 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr,
>  		pgmap = get_dev_pagemap(pfn, pgmap);
>  		if (unlikely(!pgmap)) {
>  			undo_dev_pagemap(nr, nr_start, flags, pages);
> -			ret = 0;
>  			break;
>  		}
>  		SetPageReferenced(page);
>  		pages[*nr] = page;
>  		if (unlikely(!try_grab_page(page, flags))) {
>  			undo_dev_pagemap(nr, nr_start, flags, pages);
> -			ret = 0;
>  			break;
>  		}
>  		(*nr)++;
> @@ -2264,7 +2261,7 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr,
>  	} while (addr += PAGE_SIZE, addr != end);
>  
>  	put_dev_pagemap(pgmap);
> -	return ret;
> +	return addr == end;
>  }
>  
>  static int __gup_device_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
> -- 
> 2.33.0
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2021-09-16  8:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04  0:42 [PATCH] mm/gup: further simplify __gup_device_huge() John Hubbard
2021-09-16  8:35 ` Jan Kara [this message]

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=20210916083509.GB10610@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=imbrenda@linux.ibm.com \
    --cc=jhubbard@nvidia.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=torvalds@linux-foundation.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).