Skip to content

Commit 13c63ce

Browse files
Gavin Shanwilldeacon
authored andcommitted
arm64: mm: Drop redundant check in pmd_trans_huge()
pmd_val(pmd) is redundant because a positive pmd_present(pmd) ensures a positive pmd_val(pmd) according to their definitions like below. #define pmd_val(x) ((x).pmd) #define pmd_present(pmd) pte_present(pmd_pte(pmd)) #define pte_present(pte) (pte_valid(pte) || pte_present_invalid(pte)) #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID)) #define pte_present_invalid(pte) \ ((pte_val(pte) & (PTE_VALID | PTE_PRESENT_INVALID)) == PTE_PRESENT_INVALID) pte_present() can't be positive unless either of the flag PTE_VALID or PTE_PRESENT_INVALID is set. In this case, pmd_val(pmd) should be positive either. So lets drop the redundant check pmd_val(pmd) and no functional changes intended. Signed-off-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Dev Jain <dev.jain@arm.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> Link: https://lore.kernel.org/r/20250508085251.204282-1-gshan@redhat.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 1ef3095 commit 13c63ce

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

arch/arm64/include/asm/pgtable.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,8 +837,7 @@ static inline int pmd_trans_huge(pmd_t pmd)
837837
* If pmd is present-invalid, pmd_table() won't detect it
838838
* as a table, so force the valid bit for the comparison.
839839
*/
840-
return pmd_val(pmd) && pmd_present(pmd) &&
841-
!pmd_table(__pmd(pmd_val(pmd) | PTE_VALID));
840+
return pmd_present(pmd) && !pmd_table(__pmd(pmd_val(pmd) | PTE_VALID));
842841
}
843842
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
844843

0 commit comments

Comments
 (0)