* [PATCH mm-new 1/1] mm: clean up is_guard_pte_marker()
@ 2025-09-24 4:58 Lance Yang
2025-09-24 5:19 ` Dev Jain
0 siblings, 1 reply; 2+ messages in thread
From: Lance Yang @ 2025-09-24 4:58 UTC (permalink / raw)
To: akpm
Cc: richard.weiyang, Liam.Howlett, baohua, baolin.wang, david,
dev.jain, hughd, ioworker0, kasong, kirill, lance.yang,
linux-kernel, linux-mm, lorenzo.stoakes, mpenttil, npache,
ryan.roberts, ziy
From: Lance Yang <lance.yang@linux.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@gmail.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Lance Yang <lance.yang@linux.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
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH mm-new 1/1] mm: clean up is_guard_pte_marker()
2025-09-24 4:58 [PATCH mm-new 1/1] mm: clean up is_guard_pte_marker() Lance Yang
@ 2025-09-24 5:19 ` Dev Jain
0 siblings, 0 replies; 2+ messages in thread
From: Dev Jain @ 2025-09-24 5:19 UTC (permalink / raw)
To: Lance Yang, akpm
Cc: richard.weiyang, Liam.Howlett, baohua, baolin.wang, david, hughd,
ioworker0, kasong, kirill, linux-kernel, linux-mm,
lorenzo.stoakes, mpenttil, npache, ryan.roberts, ziy
On 24/09/25 10:28 am, Lance Yang wrote:
> From: Lance Yang <lance.yang@linux.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@gmail.com>
> Reviewed-by: Zi Yan <ziy@nvidia.com>
> Acked-by: David Hildenbrand <david@redhat.com>
> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> Signed-off-by: Lance Yang <lance.yang@linux.dev>
> ---
Reviewed-by: Dev Jain <dev.jain@arm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-24 5:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-24 4:58 [PATCH mm-new 1/1] mm: clean up is_guard_pte_marker() Lance Yang
2025-09-24 5:19 ` Dev Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox