[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250924045830.3817-1-lance.yang@linux.dev>
Date: Wed, 24 Sep 2025 12:58:30 +0800
From: Lance Yang <lance.yang@...ux.dev>
To: akpm@...ux-foundation.org
Cc: richard.weiyang@...il.com,
Liam.Howlett@...cle.com,
baohua@...nel.org,
baolin.wang@...ux.alibaba.com,
david@...hat.com,
dev.jain@....com,
hughd@...gle.com,
ioworker0@...il.com,
kasong@...cent.com,
kirill@...temov.name,
lance.yang@...ux.dev,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
lorenzo.stoakes@...cle.com,
mpenttil@...hat.com,
npache@...hat.com,
ryan.roberts@....com,
ziy@...dia.com
Subject: [PATCH mm-new 1/1] mm: clean up is_guard_pte_marker()
From: Lance Yang <lance.yang@...ux.dev>
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.
Reviewed-by: Wei Yang <richard.weiyang@...il.com>
Reviewed-by: Zi Yan <ziy@...dia.com>
Acked-by: David Hildenbrand <david@...hat.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Signed-off-by: Lance Yang <lance.yang@...ux.dev>
---
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/20250918050431.36855-1-lance.yang@linux.dev
mm/madvise.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/madvise.c b/mm/madvise.c
index 35ed4ab0d7c5..fb1c86e630b6 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -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,
--
2.49.0
Powered by blists - more mailing lists