linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
@ 2025-10-07  0:50 Wei Yang
  2025-10-07  1:16 ` Lance Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Wei Yang @ 2025-10-07  0:50 UTC (permalink / raw)
  To: akpm, david, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
	npache, ryan.roberts, dev.jain, baohua, lance.yang
  Cc: linux-mm, Wei Yang, Usama Arif, Matthew Wilcox

Currently we install pmd folio with map_anon_folio_pmd() in
__do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
collapse_huge_page(), it is done with identical code except statistics
adjustment.

Unify the process with map_anon_folio_pmd() to install pmd folio. Split
it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
in page fault or not respectively.

No functional change is intended.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Lance Yang <lance.yang@linux.dev>
Cc: Dev Jain <dev.jain@arm.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>

---
v2:
  * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
---
 include/linux/huge_mm.h |  6 ++++++
 mm/huge_memory.c        | 14 ++++++++++----
 mm/khugepaged.c         |  9 +--------
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
index e3ed008a076a..277ade3b7640 100644
--- a/include/linux/huge_mm.h
+++ b/include/linux/huge_mm.h
@@ -539,6 +539,8 @@ void split_huge_pmd_locked(struct vm_area_struct *vma, unsigned long address,
 			   pmd_t *pmd, bool freeze);
 bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
 			   pmd_t *pmdp, struct folio *folio);
+void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
+		struct vm_area_struct *vma, unsigned long haddr);
 
 #else /* CONFIG_TRANSPARENT_HUGEPAGE */
 
@@ -629,6 +631,10 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
 	return false;
 }
 
+void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
+		struct vm_area_struct *vma, unsigned long haddr)
+{}
+
 #define split_huge_pud(__vma, __pmd, __address)	\
 	do { } while (0)
 
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index f13de93637bf..88960530b1d5 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1217,7 +1217,7 @@ static struct folio *vma_alloc_anon_folio_pmd(struct vm_area_struct *vma,
 	return folio;
 }
 
-static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
+void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
 		struct vm_area_struct *vma, unsigned long haddr)
 {
 	pmd_t entry;
@@ -1228,11 +1228,17 @@ static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
 	folio_add_lru_vma(folio, vma);
 	set_pmd_at(vma->vm_mm, haddr, pmd, entry);
 	update_mmu_cache_pmd(vma, haddr, pmd);
+	deferred_split_folio(folio, false);
+}
+
+static void map_anon_folio_pmd_pf(struct folio *folio, pmd_t *pmd,
+		struct vm_area_struct *vma, unsigned long haddr)
+{
+	map_anon_folio_pmd_nopf(folio, pmd, vma, haddr);
 	add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
 	count_vm_event(THP_FAULT_ALLOC);
 	count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC);
 	count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC);
-	deferred_split_folio(folio, false);
 }
 
 static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf)
@@ -1271,7 +1277,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf)
 			return ret;
 		}
 		pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable);
-		map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
+		map_anon_folio_pmd_pf(folio, vmf->pmd, vma, haddr);
 		mm_inc_nr_ptes(vma->vm_mm);
 		spin_unlock(vmf->ptl);
 	}
@@ -1877,7 +1883,7 @@ static vm_fault_t do_huge_zero_wp_pmd(struct vm_fault *vmf)
 	if (ret)
 		goto release;
 	(void)pmdp_huge_clear_flush(vma, haddr, vmf->pmd);
-	map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
+	map_anon_folio_pmd_pf(folio, vmf->pmd, vma, haddr);
 	goto unlock;
 release:
 	folio_put(folio);
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index f4f57ba69d72..ce7181b6ae4e 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -1224,17 +1224,10 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
 	__folio_mark_uptodate(folio);
 	pgtable = pmd_pgtable(_pmd);
 
-	_pmd = folio_mk_pmd(folio, vma->vm_page_prot);
-	_pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma);
-
 	spin_lock(pmd_ptl);
 	BUG_ON(!pmd_none(*pmd));
-	folio_add_new_anon_rmap(folio, vma, address, RMAP_EXCLUSIVE);
-	folio_add_lru_vma(folio, vma);
 	pgtable_trans_huge_deposit(mm, pmd, pgtable);
-	set_pmd_at(mm, address, pmd, _pmd);
-	update_mmu_cache_pmd(vma, address, pmd);
-	deferred_split_folio(folio, false);
+	map_anon_folio_pmd_nopf(folio, pmd, vma, address);
 	spin_unlock(pmd_ptl);
 
 	folio = NULL;
-- 
2.34.1



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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07  0:50 [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd() Wei Yang
@ 2025-10-07  1:16 ` Lance Yang
  2025-10-07  4:06 ` Anshuman Khandual
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Lance Yang @ 2025-10-07  1:16 UTC (permalink / raw)
  To: Wei Yang
  Cc: linux-mm, dev.jain, Usama Arif, baohua, Matthew Wilcox, david,
	ziy, akpm, ryan.roberts, baolin.wang, npache, lorenzo.stoakes,
	Liam.Howlett



On 2025/10/7 08:50, Wei Yang wrote:
> Currently we install pmd folio with map_anon_folio_pmd() in
> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
> collapse_huge_page(), it is done with identical code except statistics
> adjustment.
> 
> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
> in page fault or not respectively.
> 
> No functional change is intended.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Usama Arif <usamaarif642@gmail.com>
> Cc: Matthew Wilcox <willy@infradead.org>

Nice cleanup!

Acked-by: Lance Yang <lance.yang@linux.dev>

But one nit below.

> 
> ---
> v2:
>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
> ---
>   include/linux/huge_mm.h |  6 ++++++
>   mm/huge_memory.c        | 14 ++++++++++----
>   mm/khugepaged.c         |  9 +--------
>   3 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index e3ed008a076a..277ade3b7640 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -539,6 +539,8 @@ void split_huge_pmd_locked(struct vm_area_struct *vma, unsigned long address,
>   			   pmd_t *pmd, bool freeze);
>   bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
>   			   pmd_t *pmdp, struct folio *folio);
> +void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
> +		struct vm_area_struct *vma, unsigned long haddr);
>   
>   #else /* CONFIG_TRANSPARENT_HUGEPAGE */
>   
> @@ -629,6 +631,10 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
>   	return false;
>   }
>   
> +void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
> +		struct vm_area_struct *vma, unsigned long haddr)
> +{}

Nit: can you put the braces on separate lines?

+void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
+		struct vm_area_struct *vma, unsigned long haddr)
+{
+}

AFAIK, this is the preferred style in kernel for empty function bodies.

> +
>   #define split_huge_pud(__vma, __pmd, __address)	\
>   	do { } while (0)
>   
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index f13de93637bf..88960530b1d5 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -1217,7 +1217,7 @@ static struct folio *vma_alloc_anon_folio_pmd(struct vm_area_struct *vma,
>   	return folio;
>   }
>   
> -static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
> +void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
>   		struct vm_area_struct *vma, unsigned long haddr)
>   {
>   	pmd_t entry;
> @@ -1228,11 +1228,17 @@ static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd,
>   	folio_add_lru_vma(folio, vma);
>   	set_pmd_at(vma->vm_mm, haddr, pmd, entry);
>   	update_mmu_cache_pmd(vma, haddr, pmd);
> +	deferred_split_folio(folio, false);
> +}
> +
> +static void map_anon_folio_pmd_pf(struct folio *folio, pmd_t *pmd,
> +		struct vm_area_struct *vma, unsigned long haddr)
> +{
> +	map_anon_folio_pmd_nopf(folio, pmd, vma, haddr);
>   	add_mm_counter(vma->vm_mm, MM_ANONPAGES, HPAGE_PMD_NR);
>   	count_vm_event(THP_FAULT_ALLOC);
>   	count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC);
>   	count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC);
> -	deferred_split_folio(folio, false);
>   }
>   
>   static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf)
> @@ -1271,7 +1277,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf)
>   			return ret;
>   		}
>   		pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable);
> -		map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
> +		map_anon_folio_pmd_pf(folio, vmf->pmd, vma, haddr);
>   		mm_inc_nr_ptes(vma->vm_mm);
>   		spin_unlock(vmf->ptl);
>   	}
> @@ -1877,7 +1883,7 @@ static vm_fault_t do_huge_zero_wp_pmd(struct vm_fault *vmf)
>   	if (ret)
>   		goto release;
>   	(void)pmdp_huge_clear_flush(vma, haddr, vmf->pmd);
> -	map_anon_folio_pmd(folio, vmf->pmd, vma, haddr);
> +	map_anon_folio_pmd_pf(folio, vmf->pmd, vma, haddr);
>   	goto unlock;
>   release:
>   	folio_put(folio);
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index f4f57ba69d72..ce7181b6ae4e 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1224,17 +1224,10 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
>   	__folio_mark_uptodate(folio);
>   	pgtable = pmd_pgtable(_pmd);
>   
> -	_pmd = folio_mk_pmd(folio, vma->vm_page_prot);
> -	_pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma);
> -
>   	spin_lock(pmd_ptl);
>   	BUG_ON(!pmd_none(*pmd));
> -	folio_add_new_anon_rmap(folio, vma, address, RMAP_EXCLUSIVE);
> -	folio_add_lru_vma(folio, vma);
>   	pgtable_trans_huge_deposit(mm, pmd, pgtable);
> -	set_pmd_at(mm, address, pmd, _pmd);
> -	update_mmu_cache_pmd(vma, address, pmd);
> -	deferred_split_folio(folio, false);
> +	map_anon_folio_pmd_nopf(folio, pmd, vma, address);
>   	spin_unlock(pmd_ptl);
>   
>   	folio = NULL;



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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07  0:50 [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd() Wei Yang
  2025-10-07  1:16 ` Lance Yang
@ 2025-10-07  4:06 ` Anshuman Khandual
  2025-10-07  9:54   ` Dev Jain
  2025-10-07  8:53 ` David Hildenbrand
  2025-10-07 15:05 ` Zi Yan
  3 siblings, 1 reply; 10+ messages in thread
From: Anshuman Khandual @ 2025-10-07  4:06 UTC (permalink / raw)
  To: Wei Yang, akpm, david, lorenzo.stoakes, ziy, baolin.wang,
	Liam.Howlett, npache, ryan.roberts, dev.jain, baohua, lance.yang
  Cc: linux-mm, Usama Arif, Matthew Wilcox



On 07/10/25 6:20 AM, Wei Yang wrote:
> Currently we install pmd folio with map_anon_folio_pmd() in
> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
> collapse_huge_page(), it is done with identical code except statistics
> adjustment.
> 
> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
> in page fault or not respectively.
> 
> No functional change is intended.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Usama Arif <usamaarif642@gmail.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> 
> ---
> v2:
>   * split to map_anon_folio_pmd_[no]pf() suggested by Matthew

On which branch this patch applies against ?



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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07  0:50 [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd() Wei Yang
  2025-10-07  1:16 ` Lance Yang
  2025-10-07  4:06 ` Anshuman Khandual
@ 2025-10-07  8:53 ` David Hildenbrand
  2025-10-07 15:05 ` Zi Yan
  3 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2025-10-07  8:53 UTC (permalink / raw)
  To: Wei Yang, akpm, lorenzo.stoakes, ziy, baolin.wang, Liam.Howlett,
	npache, ryan.roberts, dev.jain, baohua, lance.yang
  Cc: linux-mm, Usama Arif, Matthew Wilcox

On 07.10.25 02:50, Wei Yang wrote:
> Currently we install pmd folio with map_anon_folio_pmd() in
> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
> collapse_huge_page(), it is done with identical code except statistics
> adjustment.
> 
> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
> in page fault or not respectively.
> 
> No functional change is intended.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Usama Arif <usamaarif642@gmail.com>
> Cc: Matthew Wilcox <willy@infradead.org>
> 
> ---
> v2:
>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
> ---
>   include/linux/huge_mm.h |  6 ++++++
>   mm/huge_memory.c        | 14 ++++++++++----
>   mm/khugepaged.c         |  9 +--------
>   3 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h
> index e3ed008a076a..277ade3b7640 100644
> --- a/include/linux/huge_mm.h
> +++ b/include/linux/huge_mm.h
> @@ -539,6 +539,8 @@ void split_huge_pmd_locked(struct vm_area_struct *vma, unsigned long address,
>   			   pmd_t *pmd, bool freeze);
>   bool unmap_huge_pmd_locked(struct vm_area_struct *vma, unsigned long addr,
>   			   pmd_t *pmdp, struct folio *folio);
> +void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
> +		struct vm_area_struct *vma, unsigned long haddr);
>   
>   #else /* CONFIG_TRANSPARENT_HUGEPAGE */
>   
> @@ -629,6 +631,10 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
>   	return false;
>   }
>   
> +void map_anon_folio_pmd_nopf(struct folio *folio, pmd_t *pmd,
> +		struct vm_area_struct *vma, unsigned long haddr)
> +{}

static inline void ...

And as Lance mentioned, put {} on separate lines.

Nothing else jumped at me, thanks!

Acked-by: David Hildenbrand <david@redhat.com>

-- 
Cheers

David / dhildenb



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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07  4:06 ` Anshuman Khandual
@ 2025-10-07  9:54   ` Dev Jain
  2025-10-07 12:24     ` Lance Yang
  0 siblings, 1 reply; 10+ messages in thread
From: Dev Jain @ 2025-10-07  9:54 UTC (permalink / raw)
  To: Anshuman Khandual, Wei Yang, akpm, david, lorenzo.stoakes, ziy,
	baolin.wang, Liam.Howlett, npache, ryan.roberts, baohua,
	lance.yang
  Cc: linux-mm, Usama Arif, Matthew Wilcox


On 07/10/25 9:36 am, Anshuman Khandual wrote:
>
> On 07/10/25 6:20 AM, Wei Yang wrote:
>> Currently we install pmd folio with map_anon_folio_pmd() in
>> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
>> collapse_huge_page(), it is done with identical code except statistics
>> adjustment.
>>
>> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
>> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
>> in page fault or not respectively.
>>
>> No functional change is intended.
>>
>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Lance Yang <lance.yang@linux.dev>
>> Cc: Dev Jain <dev.jain@arm.com>
>> Cc: Zi Yan <ziy@nvidia.com>
>> Cc: Usama Arif <usamaarif642@gmail.com>
>> Cc: Matthew Wilcox <willy@infradead.org>
>>
>> ---
>> v2:
>>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
> On which branch this patch applies against ?

+1, does not apply on mm-new for me. There have been multiple patches
changing the same file so it will be beneficial to say what commit
it applies against.

>


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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07  9:54   ` Dev Jain
@ 2025-10-07 12:24     ` Lance Yang
  2025-10-07 13:11       ` Dev Jain
  0 siblings, 1 reply; 10+ messages in thread
From: Lance Yang @ 2025-10-07 12:24 UTC (permalink / raw)
  To: Dev Jain, Anshuman Khandual
  Cc: linux-mm, Usama Arif, baolin.wang, Matthew Wilcox, david,
	lorenzo.stoakes, ryan.roberts, npache, baohua, Liam.Howlett, ziy,
	akpm, Wei Yang



On 2025/10/7 17:54, Dev Jain wrote:
> 
> On 07/10/25 9:36 am, Anshuman Khandual wrote:
>>
>> On 07/10/25 6:20 AM, Wei Yang wrote:
>>> Currently we install pmd folio with map_anon_folio_pmd() in
>>> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
>>> collapse_huge_page(), it is done with identical code except statistics
>>> adjustment.
>>>
>>> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
>>> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
>>> in page fault or not respectively.
>>>
>>> No functional change is intended.
>>>
>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>> Cc: David Hildenbrand <david@redhat.com>
>>> Cc: Lance Yang <lance.yang@linux.dev>
>>> Cc: Dev Jain <dev.jain@arm.com>
>>> Cc: Zi Yan <ziy@nvidia.com>
>>> Cc: Usama Arif <usamaarif642@gmail.com>
>>> Cc: Matthew Wilcox <willy@infradead.org>
>>>
>>> ---
>>> v2:
>>>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
>> On which branch this patch applies against ?
> 
> +1, does not apply on mm-new for me. There have been multiple patches
> changing the same file so it will be beneficial to say what commit
> it applies against.

I think this patch applies on top of the patch[1], which is based on mm-new.

[1] 
https://lore.kernel.org/linux-mm/20251002013825.20448-1-richard.weiyang@gmail.com



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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07 12:24     ` Lance Yang
@ 2025-10-07 13:11       ` Dev Jain
  2025-10-07 14:59         ` Zi Yan
  0 siblings, 1 reply; 10+ messages in thread
From: Dev Jain @ 2025-10-07 13:11 UTC (permalink / raw)
  To: Lance Yang, Anshuman Khandual
  Cc: linux-mm, Usama Arif, baolin.wang, Matthew Wilcox, david,
	lorenzo.stoakes, ryan.roberts, npache, baohua, Liam.Howlett, ziy,
	akpm, Wei Yang


On 07/10/25 5:54 pm, Lance Yang wrote:
>
>
> On 2025/10/7 17:54, Dev Jain wrote:
>>
>> On 07/10/25 9:36 am, Anshuman Khandual wrote:
>>>
>>> On 07/10/25 6:20 AM, Wei Yang wrote:
>>>> Currently we install pmd folio with map_anon_folio_pmd() in
>>>> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
>>>> collapse_huge_page(), it is done with identical code except statistics
>>>> adjustment.
>>>>
>>>> Unify the process with map_anon_folio_pmd() to install pmd folio. 
>>>> Split
>>>> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
>>>> in page fault or not respectively.
>>>>
>>>> No functional change is intended.
>>>>
>>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>>> Cc: David Hildenbrand <david@redhat.com>
>>>> Cc: Lance Yang <lance.yang@linux.dev>
>>>> Cc: Dev Jain <dev.jain@arm.com>
>>>> Cc: Zi Yan <ziy@nvidia.com>
>>>> Cc: Usama Arif <usamaarif642@gmail.com>
>>>> Cc: Matthew Wilcox <willy@infradead.org>
>>>>
>>>> ---
>>>> v2:
>>>>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
>>> On which branch this patch applies against ?
>>
>> +1, does not apply on mm-new for me. There have been multiple patches
>> changing the same file so it will be beneficial to say what commit
>> it applies against.
>
> I think this patch applies on top of the patch[1], which is based on 
> mm-new.
>
> [1] 
> https://lore.kernel.org/linux-mm/20251002013825.20448-1-richard.weiyang@gmail.com 
>

Thanks, but this is not yet in mm-new. There are some unaddressed 
comments there.

Wei, please resend this patch based on mm-new. I would urge you to hold 
off sending

multiple patches all of which change the same file and have close 
dependency, till the

first one gets merged.

>
>


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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07 13:11       ` Dev Jain
@ 2025-10-07 14:59         ` Zi Yan
  2025-10-08  1:20           ` Wei Yang
  0 siblings, 1 reply; 10+ messages in thread
From: Zi Yan @ 2025-10-07 14:59 UTC (permalink / raw)
  To: Dev Jain
  Cc: Lance Yang, Anshuman Khandual, linux-mm, Usama Arif, baolin.wang,
	Matthew Wilcox, david, lorenzo.stoakes, ryan.roberts, npache,
	baohua, Liam.Howlett, akpm, Wei Yang

On 7 Oct 2025, at 9:11, Dev Jain wrote:

> On 07/10/25 5:54 pm, Lance Yang wrote:
>>
>>
>> On 2025/10/7 17:54, Dev Jain wrote:
>>>
>>> On 07/10/25 9:36 am, Anshuman Khandual wrote:
>>>>
>>>> On 07/10/25 6:20 AM, Wei Yang wrote:
>>>>> Currently we install pmd folio with map_anon_folio_pmd() in
>>>>> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
>>>>> collapse_huge_page(), it is done with identical code except statistics
>>>>> adjustment.
>>>>>
>>>>> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
>>>>> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
>>>>> in page fault or not respectively.
>>>>>
>>>>> No functional change is intended.
>>>>>
>>>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>>>> Cc: David Hildenbrand <david@redhat.com>
>>>>> Cc: Lance Yang <lance.yang@linux.dev>
>>>>> Cc: Dev Jain <dev.jain@arm.com>
>>>>> Cc: Zi Yan <ziy@nvidia.com>
>>>>> Cc: Usama Arif <usamaarif642@gmail.com>
>>>>> Cc: Matthew Wilcox <willy@infradead.org>
>>>>>
>>>>> ---
>>>>> v2:
>>>>>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
>>>> On which branch this patch applies against ?
>>>
>>> +1, does not apply on mm-new for me. There have been multiple patches
>>> changing the same file so it will be beneficial to say what commit
>>> it applies against.
>>
>> I think this patch applies on top of the patch[1], which is based on mm-new.
>>
>> [1] https://lore.kernel.org/linux-mm/20251002013825.20448-1-richard.weiyang@gmail.com
>
> Thanks, but this is not yet in mm-new. There are some unaddressed comments there.
>
> Wei, please resend this patch based on mm-new. I would urge you to hold off sending
>
> multiple patches all of which change the same file and have close dependency, till the
>
> first one gets merged.

Or just send both patches in a series to show the dependency. That makes
reviewers’ lives much easier.

Best Regards,
Yan, Zi


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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07  0:50 [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd() Wei Yang
                   ` (2 preceding siblings ...)
  2025-10-07  8:53 ` David Hildenbrand
@ 2025-10-07 15:05 ` Zi Yan
  3 siblings, 0 replies; 10+ messages in thread
From: Zi Yan @ 2025-10-07 15:05 UTC (permalink / raw)
  To: Wei Yang
  Cc: akpm, david, lorenzo.stoakes, baolin.wang, Liam.Howlett, npache,
	ryan.roberts, dev.jain, baohua, lance.yang, linux-mm, Usama Arif,
	Matthew Wilcox

On 6 Oct 2025, at 20:50, Wei Yang wrote:

> Currently we install pmd folio with map_anon_folio_pmd() in
> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
> collapse_huge_page(), it is done with identical code except statistics
> adjustment.
>
> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
> in page fault or not respectively.
>
> No functional change is intended.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Lance Yang <lance.yang@linux.dev>
> Cc: Dev Jain <dev.jain@arm.com>
> Cc: Zi Yan <ziy@nvidia.com>
> Cc: Usama Arif <usamaarif642@gmail.com>
> Cc: Matthew Wilcox <willy@infradead.org>
>
> ---
> v2:
>   * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
> ---
>  include/linux/huge_mm.h |  6 ++++++
>  mm/huge_memory.c        | 14 ++++++++++----
>  mm/khugepaged.c         |  9 +--------
>  3 files changed, 17 insertions(+), 12 deletions(-)

After addressing Lance’s and David’s comments, feel free to add:
Reviewed-by: Zi Yan <ziy@nvidia.com>

Best Regards,
Yan, Zi


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

* Re: [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd()
  2025-10-07 14:59         ` Zi Yan
@ 2025-10-08  1:20           ` Wei Yang
  0 siblings, 0 replies; 10+ messages in thread
From: Wei Yang @ 2025-10-08  1:20 UTC (permalink / raw)
  To: Zi Yan
  Cc: Dev Jain, Lance Yang, Anshuman Khandual, linux-mm, Usama Arif,
	baolin.wang, Matthew Wilcox, david, lorenzo.stoakes,
	ryan.roberts, npache, baohua, Liam.Howlett, akpm, Wei Yang

On Tue, Oct 07, 2025 at 10:59:33AM -0400, Zi Yan wrote:
>On 7 Oct 2025, at 9:11, Dev Jain wrote:
>
>> On 07/10/25 5:54 pm, Lance Yang wrote:
>>>
>>>
>>> On 2025/10/7 17:54, Dev Jain wrote:
>>>>
>>>> On 07/10/25 9:36 am, Anshuman Khandual wrote:
>>>>>
>>>>> On 07/10/25 6:20 AM, Wei Yang wrote:
>>>>>> Currently we install pmd folio with map_anon_folio_pmd() in
>>>>>> __do_huge_pmd_anonymous_page() and do_huge_zero_wp_pmd(). While in
>>>>>> collapse_huge_page(), it is done with identical code except statistics
>>>>>> adjustment.
>>>>>>
>>>>>> Unify the process with map_anon_folio_pmd() to install pmd folio. Split
>>>>>> it to map_anon_folio_pmd_pf() and map_anon_folio_pmd_nopf() to be used
>>>>>> in page fault or not respectively.
>>>>>>
>>>>>> No functional change is intended.
>>>>>>
>>>>>> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
>>>>>> Cc: David Hildenbrand <david@redhat.com>
>>>>>> Cc: Lance Yang <lance.yang@linux.dev>
>>>>>> Cc: Dev Jain <dev.jain@arm.com>
>>>>>> Cc: Zi Yan <ziy@nvidia.com>
>>>>>> Cc: Usama Arif <usamaarif642@gmail.com>
>>>>>> Cc: Matthew Wilcox <willy@infradead.org>
>>>>>>
>>>>>> ---
>>>>>> v2:
>>>>>>    * split to map_anon_folio_pmd_[no]pf() suggested by Matthew
>>>>> On which branch this patch applies against ?
>>>>
>>>> +1, does not apply on mm-new for me. There have been multiple patches
>>>> changing the same file so it will be beneficial to say what commit
>>>> it applies against.
>>>
>>> I think this patch applies on top of the patch[1], which is based on mm-new.
>>>
>>> [1] https://lore.kernel.org/linux-mm/20251002013825.20448-1-richard.weiyang@gmail.com
>>
>> Thanks, but this is not yet in mm-new. There are some unaddressed comments there.
>>
>> Wei, please resend this patch based on mm-new. I would urge you to hold off sending
>>
>> multiple patches all of which change the same file and have close dependency, till the
>>
>> first one gets merged.

Sorry for the unconvenience.

>
>Or just send both patches in a series to show the dependency. That makes
>reviewers’ lives much easier.
>

Thanks, this is a good suggestion. Will resend them together.

>Best Regards,
>Yan, Zi

-- 
Wei Yang
Help you, Help me


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

end of thread, other threads:[~2025-10-08  1:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-07  0:50 [Patch v2] mm/khugepaged: unify pmd folio installation with map_anon_folio_pmd() Wei Yang
2025-10-07  1:16 ` Lance Yang
2025-10-07  4:06 ` Anshuman Khandual
2025-10-07  9:54   ` Dev Jain
2025-10-07 12:24     ` Lance Yang
2025-10-07 13:11       ` Dev Jain
2025-10-07 14:59         ` Zi Yan
2025-10-08  1:20           ` Wei Yang
2025-10-07  8:53 ` David Hildenbrand
2025-10-07 15:05 ` Zi Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox