Skip to contentSkip to conversation

mm/memory: remove redundant pte_devmap case for copy_one_pte()

PATCH Superseded [email protected] 3 participants 5 messages Apr 19, 2020 – Apr 20, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mm/memory: remove redundant pte_devmap case for copy_one_pte()

From: chenqiwu <[email protected]>

As discussed in patch[1], special mapping ptes such as device mapping ptes don't need to operate on their corresponding pages, so the redundant pte_devmap case can be removed.

[1] https://patchwork.kernel.org/patch/11494691/

---
 mm/memory.c | 2 --
 1 file changed, 2 deletions(-)
mm/memory.c +0 -2
index f703fe8..2143827 100644
@@ -802,8 +802,6 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
 		get_page(page);
 		page_dup_rmap(page, false);
 		rss[mm_counter(page)]++;
-	} else if (pte_devmap(pte)) {
-		page = pte_page(pte);
 	}
 
 out_set_pte:
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 mm/memory: put refcount of normal page in zap_pte_range()

From: chenqiwu <[email protected]>

As discussed in patch[1], there is an imbalnace of normal page refcount between copy_one_pte() and zap_pte_range(). This patch put the refcount of normal page back in zap_pte_range() to fix the imbalance.

[1] https://patchwork.kernel.org/patch/11494691/

---
 mm/memory.c | 1 +
 1 file changed, 1 insertion(+)
mm/memory.c +1 -0
index 2143827..ec8de9a 100644
@@ -1088,6 +1088,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 			}
 			rss[mm_counter(page)]--;
 			page_remove_rmap(page, false);
+			put_page(page);
 			if (unlikely(page_mapcount(page) < 0))
 				print_bad_pte(vma, addr, ptent, page);
 			if (unlikely(__tlb_remove_page(tlb, page))) {
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH 2/2] mm/memory: put refcount of normal page in zap_pte_range()

Quoted 6 lines · On Sun, Apr 19, 2020 at 11:30:17AM +0800, [email protected] wrote:

From: chenqiwu <[email protected]>

As discussed in patch[1], there is an imbalnace of normal page refcount between copy_one_pte() and zap_pte_range(). This patch put the refcount of normal page back in zap_pte_range() to fix the imbalance.

I think you misunderstood the discussion. NAK. Did you test this?

Reviewed-by on v1 1/2
#3 lore raw
In reply to [email protected]
Quoted 7 lines · On Sun, Apr 19, 2020 at 11:30:16AM +0800, [email protected] wrote:

From: chenqiwu <[email protected]>

As discussed in patch[1], special mapping ptes such as device mapping ptes don't need to operate on their corresponding pages, so the redundant pte_devmap case can be removed.

[1] https://patchwork.kernel.org/patch/11494691/

This is a terrible changelog. What it should say is something like:

Since commit 25b2995a35b6 ("mm: remove MEMORY_DEVICE_PUBLIC support"), the assignment to 'page' has been unnecessary. Remove it.

Quoted 22 lines
---
 mm/memory.c | 2 --
 1 file changed, 2 deletions(-)
mm/memory.c +0 -2
index f703fe8..2143827 100644
@@ -802,8 +802,6 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
 		get_page(page);
 		page_dup_rmap(page, false);
 		rss[mm_counter(page)]++;
-	} else if (pte_devmap(pte)) {
-		page = pte_page(pte);
 	}
 
 out_set_pte:
Signature · 1 line
1.9.1
reviewer Acked-by
#4 lore raw
Quoted 7 lines · Matthew Wilcox
Quoted 6 lines · On Sun, Apr 19, 2020 at 11:30:16AM +0800, [email protected] wrote:

From: chenqiwu <[email protected]>

As discussed in patch[1], special mapping ptes such as device mapping ptes don't need to operate on their corresponding pages, so the redundant pte_devmap case can be removed.

Quoted 8 lines
Quoted 1 line

[1] https://patchwork.kernel.org/patch/11494691/

This is a terrible changelog. What it should say is something like:

Since commit 25b2995a35b6 ("mm: remove MEMORY_DEVICE_PUBLIC support"), the assignment to 'page' has been unnecessary. Remove it.

With this changelog, feel free to tadd

Quoted 23 lines
Quoted 23 lines
---
 mm/memory.c | 2 --
 1 file changed, 2 deletions(-)
mm/memory.c +0 -2
index f703fe8..2143827 100644
@@ -802,8 +802,6 @@ struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
 		get_page(page);
 		page_dup_rmap(page, false);
 		rss[mm_counter(page)]++;
-	} else if (pte_devmap(pte)) {
-		page = pte_page(pte);
 	}
 
 out_set_pte:
Signature · 1 line
1.9.1
Signature · 2 lines
Michal Hocko
SUSE Labs