linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] mm: use ptep_get() instead of directly dereferencing pte_t*
@ 2025-03-10 14:04 Ryan Roberts
  2025-03-10 14:10 ` Lorenzo Stoakes
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Ryan Roberts @ 2025-03-10 14:04 UTC (permalink / raw)
  To: Andrew Morton, Lorenzo Stoakes; +Cc: Ryan Roberts, linux-mm, linux-kernel

It is best practice for all pte accesses to go via the arch helpers, to
ensure non-torn values and to allow the arch to intervene where needed
(contpte for arm64 for example). While in this case it was probably safe
to directly dereference, let's tidy it up for consistency.

Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index 22e270f727ed..33a22c2d6b20 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -202,7 +202,7 @@ static bool try_to_map_unused_to_zeropage(struct page_vma_mapped_walk *pvmw,
 		return false;
 	VM_BUG_ON_PAGE(!PageAnon(page), page);
 	VM_BUG_ON_PAGE(!PageLocked(page), page);
-	VM_BUG_ON_PAGE(pte_present(*pvmw->pte), page);
+	VM_BUG_ON_PAGE(pte_present(ptep_get(pvmw->pte)), page);

 	if (folio_test_mlocked(folio) || (pvmw->vma->vm_flags & VM_LOCKED) ||
 	    mm_forbids_zeropage(pvmw->vma->vm_mm))
--
2.43.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-11  6:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 14:04 [PATCH v1] mm: use ptep_get() instead of directly dereferencing pte_t* Ryan Roberts
2025-03-10 14:10 ` Lorenzo Stoakes
2025-03-10 15:51 ` Qi Zheng
2025-03-10 16:31   ` Ryan Roberts
2025-03-11  3:14     ` Qi Zheng
2025-03-11  5:28 ` Anshuman Khandual
2025-03-11  6:03 ` Dev Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox