mm: Replace READ_ONCE() with standard page table accessors
Subsystems (7)
PATCH 1/1 mm: Replace READ_ONCE() with standard page table accessors
Replace all READ_ONCE() with a standard page table accessors i.e pxdp_get() that defaults into READ_ONCE() in cases where platform does not override.
--- mm/gup.c | 10 +++++----- mm/hmm.c | 2 +- mm/memory.c | 4 ++-- mm/mprotect.c | 2 +- mm/sparse-vmemmap.c | 2 +- mm/vmscan.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)
mm/gup.c +5 -5
@@ -964,7 +964,7 @@ static struct page *follow_pud_mask(struct vm_area_struct *vma,struct mm_struct *mm = vma->vm_mm; pudp =pud_offset (p4dp, address); - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (!pud_present (pud))return no_page_table (vma, flags, address);if (pud_leaf (pud)) {
@@ -989,7 +989,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma,p4d_t *p4dp, p4d; p4dp =p4d_offset (pgdp, address); - p4d =READ_ONCE (*p4dp); + p4d =p4dp_get (p4dp);BUILD_BUG_ON (p4d_leaf (p4d));if (!p4d_present (p4d) ||p4d_bad (p4d))
@@ -3080,7 +3080,7 @@ static int gup_fast_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, pudp =pud_offset_lockless (p4dp, p4d, addr); do { - pud_t pud = READ_ONCE(*pudp); + pud_t pud = pudp_get(pudp); next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud)))
@@ -3106,7 +3106,7 @@ static int gup_fast_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, p4dp =p4d_offset_lockless (pgdp, pgd, addr); do { - p4d_t p4d = READ_ONCE(*p4dp); + p4d_t p4d = p4dp_get(p4dp); next = p4d_addr_end(addr, end); if (!p4d_present(p4d))
@@ -3128,7 +3128,7 @@ static void gup_fast_pgd_range(unsigned long addr, unsigned long end, pgdp =pgd_offset (current->mm, addr); do { - pgd_t pgd = READ_ONCE(*pgdp); + pgd_t pgd = pgdp_get(pgdp); next = pgd_addr_end(addr, end); if (pgd_none(pgd))
mm/hmm.c +1 -1
@@ -431,7 +431,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end,/* Normally we don't want to split the huge page */ walk->action =ACTION_CONTINUE ; - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (!pud_present (pud)) {spin_unlock (ptl);return hmm_vma_walk_hole (start, end,-1 , walk);
mm/memory.c +2 -2
@@ -6549,12 +6549,12 @@ int follow_pfnmap_start(struct follow_pfnmap_args *args) goto out; p4dp =p4d_offset (pgdp, address); - p4d =READ_ONCE (*p4dp); + p4d =p4dp_get (p4dp);if (p4d_none (p4d) ||unlikely (p4d_bad (p4d))) goto out; pudp =pud_offset (p4dp, address); - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (pud_none (pud)) goto out;if (pud_leaf (pud)) {
mm/mprotect.c +1 -1
@@ -599,7 +599,7 @@ static inline long change_pud_range(struct mmu_gather *tlb,break ; } - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (pud_none (pud))continue ;
mm/sparse-vmemmap.c +1 -1
@@ -439,7 +439,7 @@ int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end,return -ENOMEM ; pmd =pmd_offset (pud, addr); -if (pmd_none (READ_ONCE (*pmd))) { +if (pmd_none (pmdp_get (pmd))) {void *p; p =vmemmap_alloc_block_buf (PMD_SIZE , node, altmap);
mm/vmscan.c +1 -1
@@ -3772,7 +3772,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end, pud =pud_offset (p4d, start &P4D_MASK ); restart:for (i =pud_index (start), addr = start; addr != end; i++, addr = next) { -pud_t val =READ_ONCE (pud[i]); +pud_t val =pudp_get (pud + i); next =pud_addr_end (addr, end);
Signature · 1 line
2.30.2
Quoted 2 lines · Anshuman Khandual
Replace all
READ_ONCE()with a standard page table accessors i.epxdp_get()that defaults intoREAD_ONCE()in cases where platform does not override.
Does any platform override into something else currently? The way you write the description implies that.
Quoted 114 lines
Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- mm/gup.c | 10 +++++----- mm/hmm.c | 2 +- mm/memory.c | 4 ++-- mm/mprotect.c | 2 +- mm/sparse-vmemmap.c | 2 +- mm/vmscan.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)mm/gup.c +5
-5@@ -964,7 +964,7 @@ static struct page *follow_pud_mask(struct vm_area_struct *vma,struct mm_struct *mm = vma->vm_mm; pudp =pud_offset (p4dp, address); - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (!pud_present (pud))return no_page_table (vma, flags, address);if (pud_leaf (pud)) {@@ -989,7 +989,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma,p4d_t *p4dp, p4d; p4dp =p4d_offset (pgdp, address); - p4d =READ_ONCE (*p4dp); + p4d =p4dp_get (p4dp);BUILD_BUG_ON (p4d_leaf (p4d));if (!p4d_present (p4d) ||p4d_bad (p4d))@@ -3080,7 +3080,7 @@ static int gup_fast_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, pudp =pud_offset_lockless (p4dp, p4d, addr); do { - pud_t pud = READ_ONCE(*pudp); + pud_t pud = pudp_get(pudp); next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud)))@@ -3106,7 +3106,7 @@ static int gup_fast_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, p4dp =p4d_offset_lockless (pgdp, pgd, addr); do { - p4d_t p4d = READ_ONCE(*p4dp); + p4d_t p4d = p4dp_get(p4dp); next = p4d_addr_end(addr, end); if (!p4d_present(p4d))@@ -3128,7 +3128,7 @@ static void gup_fast_pgd_range(unsigned long addr, unsigned long end, pgdp =pgd_offset (current->mm, addr); do { - pgd_t pgd = READ_ONCE(*pgdp); + pgd_t pgd = pgdp_get(pgdp); next = pgd_addr_end(addr, end); if (pgd_none(pgd))mm/hmm.c +1
-1@@ -431,7 +431,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end,/* Normally we don't want to split the huge page */ walk->action =ACTION_CONTINUE ; - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (!pud_present (pud)) {spin_unlock (ptl);return hmm_vma_walk_hole (start, end,-1 , walk);mm/memory.c +2
-2@@ -6549,12 +6549,12 @@ int follow_pfnmap_start(struct follow_pfnmap_args *args) goto out; p4dp =p4d_offset (pgdp, address); - p4d =READ_ONCE (*p4dp); + p4d =p4dp_get (p4dp);if (p4d_none (p4d) ||unlikely (p4d_bad (p4d))) goto out; pudp =pud_offset (p4dp, address); - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (pud_none (pud)) goto out;if (pud_leaf (pud)) {mm/mprotect.c +1
-1@@ -599,7 +599,7 @@ static inline long change_pud_range(struct mmu_gather *tlb,break ; } - pud =READ_ONCE (*pudp); + pud =pudp_get (pudp);if (pud_none (pud))continue ;mm/sparse-vmemmap.c +0
-0
mm/sparse-vmemmap.c int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, · line 442
Quoted 5 lines
mm/sparse-vmemmap.c +1
-1@@ -439,7 +439,7 @@ int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end,return -ENOMEM ; pmd =pmd_offset (pud, addr); -if (pmd_none (READ_ONCE (*pmd))) { +if (pmd_none (pmdp_get (pmd))) {
I believe sparse-vmemmap is only for 64 bit arches so we are safe.
Quoted 16 lines
mm/sparse-vmemmap.c +0
-0void *p; p =vmemmap_alloc_block_buf (PMD_SIZE , node, altmap);mm/vmscan.c +1
-1@@ -3772,7 +3772,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end, pud =pud_offset (p4d, start &P4D_MASK ); restart:for (i =pud_index (start), addr = start; addr != end; i++, addr = next) { -pud_t val =READ_ONCE (pud[i]); +pud_t val =pudp_get (pud + i); next =pud_addr_end (addr, end);
Quoted 7 lines · Dev Jain
Quoted 2 lines · Anshuman Khandual
Replace all
READ_ONCE()with a standard page table accessors i.epxdp_get()that defaults intoREAD_ONCE()in cases where platform does not override.Does any platform override into something else currently? The way you write the description implies that.
That's how the callbacks have been designed to be overridden when required.
Quoted 122 lines
Quoted 101 lines
Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
mm/gup.c | 10 +++++-----
mm/hmm.c | 2 +-
mm/memory.c | 4 ++--
mm/mprotect.c | 2 +-
mm/sparse-vmemmap.c| 2 +-
mm/vmscan.c | 2 +-6 files changed, 11 insertions(+), 11 deletions(-)mm/gup.c +5
-5@@ -964,7 +964,7 @@ static struct page *follow_pud_mask(struct vm_area_struct *vma, struct mm_struct *mm = vma->vm_mm; pudp = pud_offset(p4dp, address); - pud = READ_ONCE(*pudp); + pud = pudp_get(pudp); if (!pud_present(pud)) return no_page_table(vma, flags, address); if (pud_leaf(pud)) {@@ -989,7 +989,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, p4d_t *p4dp, p4d; p4dp = p4d_offset(pgdp, address); - p4d = READ_ONCE(*p4dp); + p4d = p4dp_get(p4dp); BUILD_BUG_ON(p4d_leaf(p4d)); if (!p4d_present(p4d) || p4d_bad(p4d))@@ -3080,7 +3080,7 @@ static int gup_fast_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, pudp = pud_offset_lockless(p4dp, p4d, addr); do { - pud_t pud = READ_ONCE(*pudp); + pud_t pud = pudp_get(pudp); next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud)))@@ -3106,7 +3106,7 @@ static int gup_fast_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, p4dp = p4d_offset_lockless(pgdp, pgd, addr); do { - p4d_t p4d = READ_ONCE(*p4dp); + p4d_t p4d = p4dp_get(p4dp); next = p4d_addr_end(addr, end); if (!p4d_present(p4d))@@ -3128,7 +3128,7 @@ static void gup_fast_pgd_range(unsigned long addr, unsigned long end, pgdp = pgd_offset(current->mm, addr); do { - pgd_t pgd = READ_ONCE(*pgdp); + pgd_t pgd = pgdp_get(pgdp); next = pgd_addr_end(addr, end); if (pgd_none(pgd))mm/hmm.c +1
-0@@ -431,7 +431,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, /* Normally we don't want to split the huge page */ walk->action = ACTION_CONTINUE; - pud = READ_ONCE(*pudp); + pud = pudp_get(pudp); if (!pud_present(pud)) { spin_unlock(ptl); return hmm_vma_walk_hole(start, end, -1, walk);mm/memory.c +2
-2@@ -6549,12 +6549,12 @@ int follow_pfnmap_start(struct follow_pfnmap_args *args) goto out; p4dp = p4d_offset(pgdp, address); - p4d = READ_ONCE(*p4dp); + p4d = p4dp_get(p4dp); if (p4d_none(p4d) || unlikely(p4d_bad(p4d))) goto out; pudp = pud_offset(p4dp, address); - pud = READ_ONCE(*pudp); + pud = pudp_get(pudp); if (pud_none(pud)) goto out; if (pud_leaf(pud)) {mm/mprotect.c +1
-0@@ -599,7 +599,7 @@ static inline long change_pud_range(struct mmu_gather *tlb, break; } - pud = READ_ONCE(*pudp); + pud = pudp_get(pudp); if (pud_none(pud)) continue;diff --git
a/mm/sparse-vmemmap.cb/mm/sparse-vmemmap.cindexdbd8daccade2..37522d6cb398100644mm/sparse-vmemmap.c int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, · line 441
Quoted 4 lines
mm/sparse-vmemmap.c +1
-1@@ -439,7 +439,7 @@ int __meminit vmemmap_populate_hugepages(unsigned long start, unsigned long end, return -ENOMEM; pmd = pmd_offset(pud, addr); - if (pmd_none(READ_ONCE(*pmd))) { + if (pmd_none(pmdp_get(pmd))) {I believe sparse-vmemmap is only for 64 bit arches so we are safe.
Quoted 14 lines
mm/sparse-vmemmap.c +0
-0void *p; p = vmemmap_alloc_block_buf(PMD_SIZE, node, altmap);mm/vmscan.c +0
-0@@ -3772,7 +3772,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end, pud = pud_offset(p4d, start & P4D_MASK);restart:
for (i =pud_index(start), addr = start; addr != end; i++, addr = next) { -pud_tval =READ_ONCE(pud[i]);
+pud_tval =pudp_get(pud + i);
next =pud_addr_end(addr, end);
Dev Jain
Reviewed-byQuoted 8 lines · Anshuman Khandual
Quoted 5 lines · Dev Jain
Quoted 2 lines · Anshuman Khandual
Replace all
READ_ONCE()with a standard page table accessors i.epxdp_get()that defaults intoREAD_ONCE()in cases where platform does not override.Does any platform override into something else currently? The way you write the description implies that.
That's how the callbacks have been designed to be overridden when required.
What I mean is, if currently some arch is overriding into something else, this patch will be a functional change. So it is beneficial to say in the description that the patch is a safeguard for when the platform chooses to override, and no functional change is intended.
Quoted 1 line
Quoted 1 line
Quoted 9 lines · Anshuman Khandual
Replace all
READ_ONCE()with a standard page table accessors i.epxdp_get()that defaults intoREAD_ONCE()in cases where platform does not override.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
Signature · 3 lines
Cheers David / dhildenb
Quoted 10 lines · Anshuman Khandual
Replace all
READ_ONCE()with a standard page table accessors i.epxdp_get()that defaults intoREAD_ONCE()in cases where platform does not override.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
LGTM. I still assume it is a no-op change :)
Quoted 8 lines · Anshuman Khandual
Replace all
READ_ONCE()with a standard page table accessors i.epxdp_get()that defaults intoREAD_ONCE()in cases where platform does not override.Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me