From: Lance Yang Date: Wed, 24 Sep 2025 04:58:30 +0000 (+0800) Subject: mm: clean up is_guard_pte_marker() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=89be2815f465a8b167fbef09a8b664bad28713bb;p=thirdparty%2Fkernel%2Fstable.git mm: clean up is_guard_pte_marker() 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. Link: https://lkml.kernel.org/r/20250924045830.3817-1-lance.yang@linux.dev Signed-off-by: Lance Yang Reviewed-by: Wei Yang Reviewed-by: Zi Yan Acked-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes Reviewed-by: Dev Jain Cc: Baolin Wang Cc: Barry Song Cc: Hugh Dickins Cc: Kairui Song Cc: "Kirill A. Shutemov" Cc: Liam Howlett Cc: Mariano Pache Cc: Mika Penttilä Cc: Ryan Roberts Signed-off-by: Andrew Morton --- diff --git a/mm/madvise.c b/mm/madvise.c index 35ed4ab0d7c53..fb1c86e630b66 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,