Skip to contentSkip to conversation

mm: remove redundant check non_swap_entry()

PATCH Applied Ralph Campbell 2 participants 2 messages Jun 15, 2020 – Jun 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mm: remove redundant check non_swap_entry()

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is unnecessary since the latter is sufficient to determine if the page is a device private page. Remove the test for non_swap_entry() to simplify the code and for clarity.

---

This is based on the linux 5.8.0-rc1 tree and is intended for Andrew's mm tree. There is no rush so it could go into 5.9 but I think it is safe enough to go into an rc after the patch is reviewed.

Changes since v1:
Updated the change log to be more clear.
Added Jason Gunthorpe's reviewed-by.
Rebased to 5.8.0-rc1

 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
index dc7f3543b1fd..bdbb4f97e7d0 100644
@@ -1098,7 +1098,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 		}
 
 		entry = pte_to_swp_entry(ptent);
-		if (non_swap_entry(entry) && is_device_private_entry(entry)) {
+		if (is_device_private_entry(entry)) {
 			struct page *page = device_private_entry_to_page(entry);
 
 			if (unlikely(details && details->check_mapping)) {
Signature · 1 line
2.20.1
Acked-by on v2 1/1
#1 lore raw
Quoted 27 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is unnecessary since the latter is sufficient to determine if the page is a device private page. Remove the test for non_swap_entry() to simplify the code and for clarity.

---

This is based on the linux 5.8.0-rc1 tree and is intended for Andrew's mm tree. There is no rush so it could go into 5.9 but I think it is safe enough to go into an rc after the patch is reviewed.

Changes since v1:
Updated the change log to be more clear.
Added Jason Gunthorpe's reviewed-by.
Rebased to 5.8.0-rc1

 mm/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +0 -0
index dc7f3543b1fd..bdbb4f97e7d0 100644

mm/memory.c static unsigned long zap_pte_range(struct mmu_gather *tlb, · line 1104

Quoted 8 lines
mm/memory.c +1 -1
@@ -1098,7 +1098,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
 		}
 
 		entry = pte_to_swp_entry(ptent);
-		if (non_swap_entry(entry) && is_device_private_entry(entry)) {
+		if (is_device_private_entry(entry)) {
 			struct page *page = device_private_entry_to_page(entry);
 
 			if (unlikely(details && details->check_mapping)) {

Looks like 5.9 material. LGTM

Signature · 3 lines
Thanks,

David / dhildenb