Skip to contentSkip to conversation

mm/hmm: remove redundant check non_swap_entry()

PATCH Superseded Ralph Campbell 4 participants 7 messages Jun 12, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

---

This is based on the current linux 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.

 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
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

This is based on the current linux 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.

Probably shouldn't mark it as mm/hmm if Andrew is going to pick it

Jason

#2 lore raw
Quoted 5 lines · Jason Gunthorpe
Quoted 4 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

Quoted 7 lines
Quoted 5 lines

This is based on the current linux 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.

Probably shouldn't mark it as mm/hmm if Andrew is going to pick it

OK, I'll mark it as just mm: if I need to repost.

Quoted 4 lines

Jason

Thanks!

#3 lore raw
In reply to Ralph Campbell
Quoted 3 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

That is highly configuration dependent.

#else /* CONFIG_DEVICE_PRIVATE */
...
static inline bool is_device_private_entry(swp_entry_t entry)

{
        return false;
}

...
#if defined(CONFIG_MEMORY_FAILURE) || defined(CONFIG_MIGRATION) || \
defined(CONFIG_DEVICE_PRIVATE)
static inline int non_swap_entry(swp_entry_t entry)

{
        return swp_type(entry) >= MAX_SWAPFILES;
}
#else
static inline int non_swap_entry(swp_entry_t entry)
{
        return 0;
}

#endif

#4 lore raw
Quoted 5 lines · Matthew Wilcox
Quoted 3 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

Quoted 8 lines

That is highly configuration dependent.

#else /* CONFIG_DEVICE_PRIVATE */
...
static inline bool is_device_private_entry(swp_entry_t entry)

{
        return false;
}

The commit message might be a bit confusing, as it is not a subset, I would say that device_private_entry alone is sufficient to tell if the entry is private or not.

For the !CONFIG_DEVICE_PRIVATE case having it wired to false is right.

Jason

#5 lore raw
Quoted 15 lines · Jason Gunthorpe
Quoted 5 lines · Matthew Wilcox
Quoted 3 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

Quoted 8 lines

That is highly configuration dependent.

#else /* CONFIG_DEVICE_PRIVATE */
...
static inline bool is_device_private_entry(swp_entry_t entry)

{
         return false;
}
Quoted 9 lines

The commit message might be a bit confusing, as it is not a subset, I would say that device_private_entry alone is sufficient to tell if the entry is private or not.

For the !CONFIG_DEVICE_PRIVATE case having it wired to false is right.

Jason

How about the following message instead?

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.

#6 lore raw
Quoted 27 lines · Ralph Campbell
Quoted 15 lines · Jason Gunthorpe
Quoted 5 lines · Matthew Wilcox
Quoted 3 lines · Ralph Campbell

In zap_pte_range(), the check for non_swap_entry() and is_device_private_entry() is redundant since the latter is a subset of the former. Remove the redundant check to simplify the code and for clarity.

Quoted 8 lines

That is highly configuration dependent.

#else /* CONFIG_DEVICE_PRIVATE */
...
static inline bool is_device_private_entry(swp_entry_t entry)

{
         return false;
}
Quoted 9 lines

The commit message might be a bit confusing, as it is not a subset, I would say that device_private_entry alone is sufficient to tell if the entry is private or not.

For the !CONFIG_DEVICE_PRIVATE case having it wired to false is right.

Jason

Quoted 6 lines

How about the following message instead?

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.

Yes, that is clearer to me

Jason