Skip to contentSkip to conversation

mm: clean up is_guard_pte_marker()

PATCH Applied Lance Yang 2 participants 2 messages Sep 24, 2025

Subsystems (2)
lore
Share & tools
lore

Lance Yang

author
#0 lore raw

PATCH 1/1 mm: clean up is_guard_pte_marker()

From: Lance Yang <[email protected]>

Let's simplify the implementation. The current code is redundant as it effectively expands to:

  is_swap_pte(pte) &&
  is_pte_marker_entry(...) && // from is_pte_marker()
  is_pte_marker_entry(...)    // from is_guard_swp_entry()

While a modern compiler could likely optimize this away, let's have clean code and not rely on it.

---
This patch is split from the series[1]. The cleanup can be applied independently because is_guard_pte_marker() is no longer exposed.

The original Acked-by and Reviewed-by tags are kept as the change is trivial enough.

[1] https://lore.kernel.org/linux-mm/[email protected]

 mm/madvise.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/madvise.c +2 -2
index 35ed4ab0d7c5..fb1c86e630b6 100644
@@ -1071,8 +1071,8 @@ static bool is_valid_guard_vma(struct vm_area_struct *vma, bool allow_locked)
 
 static bool is_guard_pte_marker(pte_t ptent)
 {
-	return is_pte_marker(ptent) &&
-		is_guard_swp_entry(pte_to_swp_entry(ptent));
+	return is_swap_pte(ptent) &&
+	       is_guard_swp_entry(pte_to_swp_entry(ptent));
 }
 
 static int guard_install_pud_entry(pud_t *pud, unsigned long addr,
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Lance Yang

From: Lance Yang <[email protected]>

Let's simplify the implementation. The current code is redundant as it effectively expands to:

   is_swap_pte(pte) &&
   is_pte_marker_entry(...) && // from is_pte_marker()
   is_pte_marker_entry(...)    // from is_guard_swp_entry()

While a modern compiler could likely optimize this away, let's have clean code and not rely on it.

Quoted 6 lines

---