From patchwork Fri Sep 13 08:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anshuman Khandual X-Patchwork-Id: 13803154 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9294FA372B for ; Fri, 13 Sep 2024 08:45:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7194E6B00D1; Fri, 13 Sep 2024 04:45:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A0046B00D2; Fri, 13 Sep 2024 04:45:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51AE06B00D3; Fri, 13 Sep 2024 04:45:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2C8B56B00D1 for ; Fri, 13 Sep 2024 04:45:16 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D919AC2081 for ; Fri, 13 Sep 2024 08:45:15 +0000 (UTC) X-FDA: 82559080590.13.9AB0BCF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id 23ABC40019 for ; Fri, 13 Sep 2024 08:45:13 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726217060; a=rsa-sha256; cv=none; b=pNyBEfdzhvlfD7rs6+NTx/3Kf8txcfG9Pytse48E99FH1uCOZZSQUOkGbmYXuso+ehzcLW Dpo/pgb9ziewv2SIsgL/fMKLhzhlwo0oZtW0kNza3kdRnQRKEyRRGvLCVOm99PvnG0oH7A TQZsoYoZGLPHw9vhxEuLUQ/yGsNMvmk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726217060; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DfoPueKoSMiPINFrFEnLdwElCrFNUUFiXm5c72uAasM=; b=JLdrsBj8AQP3BurRZQ9Sib8CLhdmApHhscBRhZVBICh5MYoRszlyx+xA6z02YEpewaZxjD 7N37nWtQE5h8lmZtvFpLbxLgZgZwJZIl/hPcA1L7jkGuMfvjFxNXNemzXe10JSf1n9hFVd sGm3Z977K1+oTHjAXi+OaA+nrWFiHBE= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E3EAA15BF; Fri, 13 Sep 2024 01:45:42 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.16.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2AD203F73B; Fri, 13 Sep 2024 01:45:06 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Andrew Morton , David Hildenbrand , Ryan Roberts , "Mike Rapoport (IBM)" , Arnd Bergmann , x86@kernel.org, linux-m68k@lists.linux-m68k.org, linux-fsdevel@vger.kernel.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Dimitri Sivanich , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Muchun Song , Andrey Ryabinin , Miaohe Lin , Naoya Horiguchi , Pasha Tatashin Subject: [PATCH 5/7] mm: Use pudp_get() for accessing PUD entries Date: Fri, 13 Sep 2024 14:14:31 +0530 Message-Id: <20240913084433.1016256-6-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240913084433.1016256-1-anshuman.khandual@arm.com> References: <20240913084433.1016256-1-anshuman.khandual@arm.com> MIME-Version: 1.0 X-Stat-Signature: ixhxfajeqm5qyk1pko1ucgat5t6tcrdk X-Rspamd-Queue-Id: 23ABC40019 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1726217113-950473 X-HE-Meta: U2FsdGVkX1/2rhTBq028YbV88eCDyYYj2oYpmtYgBSCKo4SDCrUjWui+V/jK/2VAX7SQG7GdQ+1Rq8V40n8C9ELBcH7Fmobiqt68RLkpH/yBTvyS2saCZidyFH7A0KTOgsa/K8RJn2ijsicEDHcY510uOlaH4xstT7OK/BeHcGJm2rGdj3vZVs/9vbqVzslknayo3f8PVmqWiEMQWO1b2d9B7hDKxwTZeJWK+Jn6rn+qXX7Vx82t6Q2WJVQYCFx/VLpxcOy40VxvxDeCEPGgEvR5hVB4X5eW2oEkXRGVenyaCPjPQuw6PVcn53RA5ZKgegS3iQJNfnz4Go/vZJuO1Yz+CzjjrR5pc5cd8PzOTgSiNiBbrO9i/eqM2aFeINRBfGfk8Yi4X4oxe5aHjil6BznJSGc1vJ/bg+g+PzFud2oBLGgE4onGH3wAkJjuVaWOLmbUULFkVG2sumVO2limcxaN8uOcftHrSWY30RrljCPOde9j4l7+q8joyx4Ep0GIs4EHT5NexW9pssTm8BeCrZfpSAlOX8AOg1VhKf7fYGJGu+g4I3fZYELRlQJuV1TDqm7NPXKC2RXMJbAZ06mvLPtDr9C+wJHB7A1IzNG5lCnE7SFHz6SH6EzbKxDkFapJXXqzoXMwYNW8Ljd+mOcuVB3mAGnpuh6Ka8mUO0M6Yuo2bIOc8QtJB8rtm2V7GPt/WBl7mTbgEL/v2LpP5pSDMfvCeInME5C6roR7H5xdhouLxYVsWpqaJVwjH2QffR0odQMXr8MjHRsShwA5BgDKgmnxElBJ7ElJiT1aK3RxCndTU3f/+a9SiLa6FH60+ukHpKUJCRlCL7bNnen06AYGCY68WR/geR4Jm0iOZU3t7lEBvtnOe+yfYQb7Y5ocwj/LvjnIHJK911ipfSRcVGLx52bA7Hl3hmDJ/d/QxStZOd4DibKHoNPTZ9UFUuDvCw4RTNyp0PQw3p/ojijEtGQ aU6xs2kx XNtKOzvtwtvDZsS2vHmTm12Ape0WTbkVSmKzcQQAlai2AnZt0KR70xLTWROHq8aofb1u39RDMaM3QhOUVuY3MWwNZXKAennBKg3hg7SEbV1gf7tcsHlPDSvepyjdRU7NaKqpL/D5lmlPHzfUjtYOWnrwW+rtTWDbrEJptz2BsiJXT1MQRZk5z41YzG2jpfsuM5iDQJWYVpQJ0yxpObzMTjXkDE7b9tIHKIOZVYmxBA3jAxh933jAgvZaUmbJ21uMuzgVYZCGQs5ryvsBWmDd1uQe8/mT9lJeg4vphinmbaLUAotPJL2h4VcvJfvBacEQ4U+ItDXlMaBCHlodeojn9sO1jP1w3y6L9qgRA4pe0DTvpUcQ8u1QlpPQrPvhetv5/DexeU2SAXona8VaATITdwb9xlehbLe74c6h8/hQnCPTaCDKJq+S9MhSH2ccTrl9FYQw01N1cJsFtX6Xi52jODxyTvxJHUM/EgnZPhsZ3LlNVGPAyN07WnbuDGAiS6O5pQSZrRL2N9JRsSurZcP3VxxcWXiw4sFnNheE6ZEmelH4yA91Jgox72zuVckNeCHsfw0pVsgQmvp2PEq9MryWBnTd9PsPmN2a/cNmv3wgawheTPt/uEsyuqIqk4qICkxE4pa/N0djdLgqueGx8SCc9vDrXE2z6i2eNsFtf X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Convert PUD accesses via pudp_get() helper that defaults as READ_ONCE() but also provides the platform an opportunity to override when required. Cc: Dimitri Sivanich Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: "Jérôme Glisse" Cc: Muchun Song Cc: Andrey Ryabinin Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Pasha Tatashin Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-perf-users@vger.kernel.org Cc: kasan-dev@googlegroups.com Signed-off-by: Anshuman Khandual --- drivers/misc/sgi-gru/grufault.c | 2 +- include/linux/huge_mm.h | 2 +- include/linux/mm.h | 2 +- include/linux/pgtable.h | 10 +++++----- kernel/events/core.c | 2 +- mm/gup.c | 12 ++++++------ mm/hmm.c | 2 +- mm/huge_memory.c | 16 ++++++++-------- mm/hugetlb.c | 6 +++--- mm/kasan/init.c | 10 +++++----- mm/kasan/shadow.c | 4 ++-- mm/mapping_dirty_helpers.c | 2 +- mm/memory-failure.c | 4 ++-- mm/memory.c | 10 +++++----- mm/page_table_check.c | 2 +- mm/page_vma_mapped.c | 2 +- mm/pgalloc-track.h | 2 +- mm/pgtable-generic.c | 2 +- mm/ptdump.c | 4 ++-- 19 files changed, 48 insertions(+), 48 deletions(-) diff --git a/drivers/misc/sgi-gru/grufault.c b/drivers/misc/sgi-gru/grufault.c index f3d6249b7dfb..0a06ec92f090 100644 --- a/drivers/misc/sgi-gru/grufault.c +++ b/drivers/misc/sgi-gru/grufault.c @@ -220,7 +220,7 @@ static int atomic_pte_lookup(struct vm_area_struct *vma, unsigned long vaddr, goto err; pudp = pud_offset(p4dp, vaddr); - if (unlikely(pud_none(*pudp))) + if (unlikely(pud_none(pudp_get(pudp)))) goto err; pmdp = pmd_offset(pudp, vaddr); diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 351d6c72af9e..17ee222e4004 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -378,7 +378,7 @@ static inline spinlock_t *pmd_trans_huge_lock(pmd_t *pmd, static inline spinlock_t *pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma) { - if (pud_trans_huge(*pud) || pud_devmap(*pud)) + if (pud_trans_huge(pudp_get(pud)) || pud_devmap(pudp_get(pud))) return __pud_trans_huge_lock(pud, vma); else return NULL; diff --git a/include/linux/mm.h b/include/linux/mm.h index 258e49323306..1bb1599b5779 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2832,7 +2832,7 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, p4d_t *p4d, static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) { - return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))? + return (unlikely(pud_none(pudp_get(pud))) && __pmd_alloc(mm, pud, address)) ? NULL: pmd_offset(pud, address); } #endif /* CONFIG_MMU */ diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 188a183205b3..b25a0a505ce6 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -611,7 +611,7 @@ static inline pud_t pudp_huge_get_and_clear(struct mm_struct *mm, unsigned long address, pud_t *pudp) { - pud_t pud = *pudp; + pud_t pud = pudp_get(pudp); pud_clear(pudp); page_table_check_pud_clear(mm, pud); @@ -893,7 +893,7 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm, static inline void pudp_set_wrprotect(struct mm_struct *mm, unsigned long address, pud_t *pudp) { - pud_t old_pud = *pudp; + pud_t old_pud = pudp_get(pudp); set_pud_at(mm, address, pudp, pud_wrprotect(old_pud)); } @@ -1072,7 +1072,7 @@ static inline int pgd_same(pgd_t pgd_a, pgd_t pgd_b) #define set_pud_safe(pudp, pud) \ ({ \ - WARN_ON_ONCE(pud_present(*pudp) && !pud_same(*pudp, pud)); \ + WARN_ON_ONCE(pud_present(pudp_get(pudp)) && !pud_same(pudp_get(pudp), pud)); \ set_pud(pudp, pud); \ }) @@ -1259,9 +1259,9 @@ static inline int p4d_none_or_clear_bad(p4d_t *p4d) static inline int pud_none_or_clear_bad(pud_t *pud) { - if (pud_none(*pud)) + if (pud_none(pudp_get(pud))) return 1; - if (unlikely(pud_bad(*pud))) { + if (unlikely(pud_bad(pudp_get(pud)))) { pud_clear_bad(pud); return 1; } diff --git a/kernel/events/core.c b/kernel/events/core.c index 8a6c6bbcd658..35e2f2789246 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -7619,7 +7619,7 @@ static u64 perf_get_pgtable_size(struct mm_struct *mm, unsigned long addr) return p4d_leaf_size(p4d); pudp = pud_offset_lockless(p4dp, p4d, addr); - pud = READ_ONCE(*pudp); + pud = pudp_get(pudp); if (!pud_present(pud)) return 0; diff --git a/mm/gup.c b/mm/gup.c index aeeac0a54944..300fc7eb306c 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -606,7 +606,7 @@ static struct page *follow_huge_pud(struct vm_area_struct *vma, { struct mm_struct *mm = vma->vm_mm; struct page *page; - pud_t pud = *pudp; + pud_t pud = pudp_get(pudp); unsigned long pfn = pud_pfn(pud); int ret; @@ -989,7 +989,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)) { @@ -1117,7 +1117,7 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address, if (p4d_none(*p4d)) return -EFAULT; pud = pud_offset(p4d, address); - if (pud_none(*pud)) + if (pud_none(pudp_get(pud))) return -EFAULT; pmd = pmd_offset(pud, address); if (!pmd_present(pmdp_get(pmd))) @@ -3025,7 +3025,7 @@ static int gup_fast_devmap_pud_leaf(pud_t orig, pud_t *pudp, unsigned long addr, if (!gup_fast_devmap_leaf(fault_pfn, addr, end, flags, pages, nr)) return 0; - if (unlikely(pud_val(orig) != pud_val(*pudp))) { + if (unlikely(pud_val(orig) != pud_val(pudp_get(pudp)))) { gup_fast_undo_dev_pagemap(nr, nr_start, flags, pages); return 0; } @@ -3118,7 +3118,7 @@ static int gup_fast_pud_leaf(pud_t orig, pud_t *pudp, unsigned long addr, if (!folio) return 0; - if (unlikely(pud_val(orig) != pud_val(*pudp))) { + if (unlikely(pud_val(orig) != pud_val(pudp_get(pudp)))) { gup_put_folio(folio, refs, flags); return 0; } @@ -3219,7 +3219,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))) diff --git a/mm/hmm.c b/mm/hmm.c index 7e0229ae4a5a..c1b093d670b8 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -423,7 +423,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); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3545142a5dc9..994babaca75f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1247,13 +1247,13 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, spinlock_t *ptl; ptl = pud_lock(mm, pud); - if (!pud_none(*pud)) { + if (!pud_none(pudp_get(pud))) { if (write) { - if (pud_pfn(*pud) != pfn_t_to_pfn(pfn)) { - WARN_ON_ONCE(!is_huge_zero_pud(*pud)); + if (pud_pfn(pudp_get(pud)) != pfn_t_to_pfn(pfn)) { + WARN_ON_ONCE(!is_huge_zero_pud(pudp_get(pud))); goto out_unlock; } - entry = pud_mkyoung(*pud); + entry = pud_mkyoung(pudp_get(pud)); entry = maybe_pud_mkwrite(pud_mkdirty(entry), vma); if (pudp_set_access_flags(vma, addr, pud, entry, 1)) update_mmu_cache_pud(vma, addr, pud); @@ -1475,7 +1475,7 @@ void touch_pud(struct vm_area_struct *vma, unsigned long addr, { pud_t _pud; - _pud = pud_mkyoung(*pud); + _pud = pud_mkyoung(pudp_get(pud)); if (write) _pud = pud_mkdirty(_pud); if (pudp_set_access_flags(vma, addr & HPAGE_PUD_MASK, @@ -2284,7 +2284,7 @@ spinlock_t *__pud_trans_huge_lock(pud_t *pud, struct vm_area_struct *vma) spinlock_t *ptl; ptl = pud_lock(vma->vm_mm, pud); - if (likely(pud_trans_huge(*pud) || pud_devmap(*pud))) + if (likely(pud_trans_huge(pudp_get(pud)) || pud_devmap(pudp_get(pud)))) return ptl; spin_unlock(ptl); return NULL; @@ -2318,7 +2318,7 @@ static void __split_huge_pud_locked(struct vm_area_struct *vma, pud_t *pud, VM_BUG_ON(haddr & ~HPAGE_PUD_MASK); VM_BUG_ON_VMA(vma->vm_start > haddr, vma); VM_BUG_ON_VMA(vma->vm_end < haddr + HPAGE_PUD_SIZE, vma); - VM_BUG_ON(!pud_trans_huge(*pud) && !pud_devmap(*pud)); + VM_BUG_ON(!pud_trans_huge(pudp_get(pud)) && !pud_devmap(pudp_get(pud))); count_vm_event(THP_SPLIT_PUD); @@ -2336,7 +2336,7 @@ void __split_huge_pud(struct vm_area_struct *vma, pud_t *pud, (address & HPAGE_PUD_MASK) + HPAGE_PUD_SIZE); mmu_notifier_invalidate_range_start(&range); ptl = pud_lock(vma->vm_mm, pud); - if (unlikely(!pud_trans_huge(*pud) && !pud_devmap(*pud))) + if (unlikely(!pud_trans_huge(pudp_get(pud)) && !pud_devmap(pudp_get(pud)))) goto out; __split_huge_pud_locked(vma, pud, range.start); diff --git a/mm/hugetlb.c b/mm/hugetlb.c index aaf508be0a2b..a3820242b01e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7328,7 +7328,7 @@ pte_t *huge_pmd_share(struct mm_struct *mm, struct vm_area_struct *vma, goto out; spin_lock(&mm->page_table_lock); - if (pud_none(*pud)) { + if (pud_none(pudp_get(pud))) { pud_populate(mm, pud, (pmd_t *)((unsigned long)spte & PAGE_MASK)); mm_inc_nr_pmds(mm); @@ -7417,7 +7417,7 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma, pte = (pte_t *)pud; } else { BUG_ON(sz != PMD_SIZE); - if (want_pmd_share(vma, addr) && pud_none(*pud)) + if (want_pmd_share(vma, addr) && pud_none(pudp_get(pud))) pte = huge_pmd_share(mm, vma, addr, pud); else pte = (pte_t *)pmd_alloc(mm, pud, addr); @@ -7461,7 +7461,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (sz == PUD_SIZE) /* must be pud huge, non-present or none */ return (pte_t *)pud; - if (!pud_present(*pud)) + if (!pud_present(pudp_get(pud))) return NULL; /* must have a valid entry and size to go further */ diff --git a/mm/kasan/init.c b/mm/kasan/init.c index 4418bcdcb2aa..f4cf519443e1 100644 --- a/mm/kasan/init.c +++ b/mm/kasan/init.c @@ -162,7 +162,7 @@ static int __ref zero_pud_populate(p4d_t *p4d, unsigned long addr, continue; } - if (pud_none(*pud)) { + if (pud_none(pudp_get(pud))) { pmd_t *p; if (slab_is_available()) { @@ -315,7 +315,7 @@ static void kasan_free_pmd(pmd_t *pmd_start, pud_t *pud) return; } - pmd_free(&init_mm, (pmd_t *)page_to_virt(pud_page(*pud))); + pmd_free(&init_mm, (pmd_t *)page_to_virt(pud_page(pudp_get(pud)))); pud_clear(pud); } @@ -326,7 +326,7 @@ static void kasan_free_pud(pud_t *pud_start, p4d_t *p4d) for (i = 0; i < PTRS_PER_PUD; i++) { pud = pud_start + i; - if (!pud_none(*pud)) + if (!pud_none(pudp_get(pud))) return; } @@ -407,10 +407,10 @@ static void kasan_remove_pud_table(pud_t *pud, unsigned long addr, next = pud_addr_end(addr, end); - if (!pud_present(*pud)) + if (!pud_present(pudp_get(pud))) continue; - if (kasan_pmd_table(*pud)) { + if (kasan_pmd_table(pudp_get(pud))) { if (IS_ALIGNED(addr, PUD_SIZE) && IS_ALIGNED(next, PUD_SIZE)) { pud_clear(pud); diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c index aec16a7236f7..dbd8164c75f1 100644 --- a/mm/kasan/shadow.c +++ b/mm/kasan/shadow.c @@ -197,9 +197,9 @@ static bool shadow_mapped(unsigned long addr) if (p4d_none(*p4d)) return false; pud = pud_offset(p4d, addr); - if (pud_none(*pud)) + if (pud_none(pudp_get(pud))) return false; - if (pud_leaf(*pud)) + if (pud_leaf(pudp_get(pud))) return true; pmd = pmd_offset(pud, addr); if (pmd_none(pmdp_get(pmd))) diff --git a/mm/mapping_dirty_helpers.c b/mm/mapping_dirty_helpers.c index 2f8829b3541a..c556cc4e3480 100644 --- a/mm/mapping_dirty_helpers.c +++ b/mm/mapping_dirty_helpers.c @@ -149,7 +149,7 @@ static int wp_clean_pud_entry(pud_t *pud, unsigned long addr, unsigned long end, struct mm_walk *walk) { #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD - pud_t pudval = READ_ONCE(*pud); + pud_t pudval = pudp_get(pud); /* Do not split a huge pud */ if (pud_trans_huge(pudval) || pud_devmap(pudval)) { diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 305dbef3cc4d..fbb63401fb51 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -417,9 +417,9 @@ static unsigned long dev_pagemap_mapping_shift(struct vm_area_struct *vma, if (!p4d_present(*p4d)) return 0; pud = pud_offset(p4d, address); - if (!pud_present(*pud)) + if (!pud_present(pudp_get(pud))) return 0; - if (pud_devmap(*pud)) + if (pud_devmap(pudp_get(pud))) return PUD_SHIFT; pmd = pmd_offset(pud, address); if (!pmd_present(pmdp_get(pmd))) diff --git a/mm/memory.c b/mm/memory.c index 43953a6d350f..af6c9346493c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1753,7 +1753,7 @@ static inline unsigned long zap_pud_range(struct mmu_gather *tlb, pud = pud_offset(p4d, addr); do { next = pud_addr_end(addr, end); - if (pud_trans_huge(*pud) || pud_devmap(*pud)) { + if (pud_trans_huge(pudp_get(pud)) || pud_devmap(pudp_get(pud))) { if (next - addr != HPAGE_PUD_SIZE) { mmap_assert_locked(tlb->mm); split_huge_pud(vma, pud, addr); @@ -2819,7 +2819,7 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud, unsigned long next; int err = 0; - BUG_ON(pud_leaf(*pud)); + BUG_ON(pud_leaf(pudp_get(pud))); if (create) { pmd = pmd_alloc_track(mm, pud, addr, mask); @@ -2866,11 +2866,11 @@ static int apply_to_pud_range(struct mm_struct *mm, p4d_t *p4d, } do { next = pud_addr_end(addr, end); - if (pud_none(*pud) && !create) + if (pud_none(pudp_get(pud)) && !create) continue; - if (WARN_ON_ONCE(pud_leaf(*pud))) + if (WARN_ON_ONCE(pud_leaf(pudp_get(pud)))) return -EINVAL; - if (!pud_none(*pud) && WARN_ON_ONCE(pud_bad(*pud))) { + if (!pud_none(pudp_get(pud)) && WARN_ON_ONCE(pud_bad(pudp_get(pud)))) { if (!create) continue; pud_clear_bad(pud); diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 48a2cf56c80e..2a22d098b0b1 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -254,7 +254,7 @@ void __page_table_check_pud_set(struct mm_struct *mm, pud_t *pudp, pud_t pud) if (&init_mm == mm) return; - __page_table_check_pud_clear(mm, *pudp); + __page_table_check_pud_clear(mm, pudp_get(pudp)); if (pud_user_accessible_page(pud)) { page_table_check_set(pud_pfn(pud), PUD_SIZE >> PAGE_SHIFT, pud_write(pud)); diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index ae5cc42aa208..511266307771 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -222,7 +222,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) continue; } pud = pud_offset(p4d, pvmw->address); - if (!pud_present(*pud)) { + if (!pud_present(pudp_get(pud))) { step_forward(pvmw, PUD_SIZE); continue; } diff --git a/mm/pgalloc-track.h b/mm/pgalloc-track.h index e9e879de8649..0f6b809431a3 100644 --- a/mm/pgalloc-track.h +++ b/mm/pgalloc-track.h @@ -33,7 +33,7 @@ static inline pmd_t *pmd_alloc_track(struct mm_struct *mm, pud_t *pud, unsigned long address, pgtbl_mod_mask *mod_mask) { - if (unlikely(pud_none(*pud))) { + if (unlikely(pud_none(pudp_get(pud)))) { if (__pmd_alloc(mm, pud, address)) return NULL; *mod_mask |= PGTBL_PUD_MODIFIED; diff --git a/mm/pgtable-generic.c b/mm/pgtable-generic.c index a5045d0fc73e..5bd02c6208e7 100644 --- a/mm/pgtable-generic.c +++ b/mm/pgtable-generic.c @@ -153,7 +153,7 @@ pud_t pudp_huge_clear_flush(struct vm_area_struct *vma, unsigned long address, pud_t pud; VM_BUG_ON(address & ~HPAGE_PUD_MASK); - VM_BUG_ON(!pud_trans_huge(*pudp) && !pud_devmap(*pudp)); + VM_BUG_ON(!pud_trans_huge(pudp_get(pudp)) && !pud_devmap(pudp_get(pudp))); pud = pudp_huge_get_and_clear(vma->vm_mm, address, pudp); flush_pud_tlb_range(vma, address, address + HPAGE_PUD_SIZE); return pud; diff --git a/mm/ptdump.c b/mm/ptdump.c index e17588a32012..32ae8e829329 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -30,7 +30,7 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long addr, unsigned long next, struct mm_walk *walk) { struct ptdump_state *st = walk->private; - pgd_t val = READ_ONCE(*pgd); + pgd_t val = pgdp_get(pgd); #if CONFIG_PGTABLE_LEVELS > 4 && \ (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)) @@ -76,7 +76,7 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long addr, unsigned long next, struct mm_walk *walk) { struct ptdump_state *st = walk->private; - pud_t val = READ_ONCE(*pud); + pud_t val = pudp_get(pud); #if CONFIG_PGTABLE_LEVELS > 2 && \ (defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS))