All of lore.kernel.org
 help / color / mirror / Atom feed
From: Usama Arif <usama.arif@linux.dev>
To: Zi Yan <ziy@nvidia.com>
Cc: "Mika Penttilä" <mpenttil@redhat.com>,
	"Balbir Singh" <balbirs@nvidia.com>,
	"Kiryl Shutsemau" <kas@kernel.org>,
	matthew.brost@intel.com, npache@redhat.com, david@kernel.org,
	"Usama Arif" <usamaarif642@gmail.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-mm@kvack.org, joshua.hahnjy@gmail.com, hannes@cmpxchg.org,
	rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net,
	ying.huang@linux.alibaba.com, apopple@nvidia.com,
	riel@surriel.com, shakeel.butt@linux.dev,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH] mm/migrate_device: fix folio refcount leak on folio_split_unmapped failure
Date: Fri, 6 Mar 2026 13:47:35 +0300	[thread overview]
Message-ID: <3dd4399f-a138-4ec0-b3a8-0ce200423ebe@linux.dev> (raw)
In-Reply-To: <1EAE2E58-7A71-4B59-B1EF-3A3C753DDC1E@nvidia.com>


> 
> I do not think there is a need to explain why there is no folio_put()
> below. How about below?
> 
> 1. it makes sure the folio has the right ref count,
> 2. it explains folio_get() is for split_huge_pmd_address() instead of
>    folio_split_unmapped().
> 
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index 0a8b31939640f..0b31b878210ba 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -914,8 +914,14 @@ static int migrate_vma_split_unmapped_folio(struct migrate_vma *migrate,
>  	unsigned long flags;
>  	int ret = 0;
> 
> +	VM_WARN_ON_ONCE(folio_ref_count(folio) == 1);

Thanks! I have sent it in [1]. One thing is, I think you mean over here
folio_ref_count(folio) != 1, right? Thats what the patch has.


[1] https://lore.kernel.org/all/20260306104409.3915811-1-usama.arif@linux.dev/

> +	/*
> +	 * take a reference, since split_huge_pmd_address() with freeze = true
> +	 * drops a reference at the end.
> +	 */
>  	folio_get(folio);
>  	split_huge_pmd_address(migrate->vma, addr, true);
> +	
>  	ret = folio_split_unmapped(folio, 0);
>  	if (ret)
>  		return ret;
> 
> 
>>
>>>>
>>>>
>>>> [1] https://gist.github.com/uarif1/65e1e816af7aa0ae38dd6ec64d62a993
>>>> [2] https://gist.github.com/uarif1/79ea9500667daa4e2ef09cb5d308f041
>>>> [3] https://gist.github.com/uarif1/8a35a6c65ba8b3a1c1dfe72dc30e821d
>>>
>>>
>>> Best Regards,
>>> Yan, Zi
> 
> 
> Best Regards,
> Yan, Zi



  reply	other threads:[~2026-03-06 10:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 12:01 [PATCH] mm/migrate_device: fix folio refcount leak on folio_split_unmapped failure Usama Arif
2026-03-04 14:00 ` Kiryl Shutsemau
2026-03-04 15:17 ` Zi Yan
2026-03-04 21:48   ` Balbir Singh
2026-03-04 21:54     ` Zi Yan
2026-03-04 22:02       ` Matthew Brost
2026-03-04 22:09       ` Balbir Singh
2026-03-04 23:28         ` Usama Arif
2026-03-05  6:09           ` Mika Penttilä
2026-03-05 11:44             ` Usama Arif
2026-03-05 12:09               ` Mika Penttilä
2026-03-05 16:36                 ` Usama Arif
2026-03-05 16:39                   ` Zi Yan
2026-03-05 17:00                     ` Usama Arif
2026-03-05 17:32                       ` Zi Yan
2026-03-06 10:47                         ` Usama Arif [this message]
2026-03-05 22:04                       ` Balbir Singh
2026-03-06 10:51                         ` Usama Arif
2026-03-04 15:25 ` Joshua Hahn

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=3dd4399f-a138-4ec0-b3a8-0ce200423ebe@linux.dev \
    --to=usama.arif@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=balbirs@nvidia.com \
    --cc=byungchul@sk.com \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kas@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.brost@intel.com \
    --cc=mpenttil@redhat.com \
    --cc=npache@redhat.com \
    --cc=rakie.kim@sk.com \
    --cc=riel@surriel.com \
    --cc=shakeel.butt@linux.dev \
    --cc=usamaarif642@gmail.com \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    /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 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.