Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/gup: merge pXd huge mapping checks

Huge mapping checks in GUP are slightly redundant and can be simplified.

pXd_huge() now is the same as pXd_leaf(). pmd_trans_huge() and
pXd_devmap() should both imply pXd_leaf(). Time to merge them into one.

Link: https://lkml.kernel.org/r/20240318200404.448346-11-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Konrad Dybcio <konrad.dybcio@linaro.org>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Lucas Stach <l.stach@pengutronix.de>
Cc: Mark Salter <msalter@redhat.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Naoya Horiguchi <nao.horiguchi@gmail.com>
Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Peter Xu and committed by
Andrew Morton
7db86dc3 460b9adc

+3 -4
+3 -4
mm/gup.c
··· 3017 3017 if (!pmd_present(pmd)) 3018 3018 return 0; 3019 3019 3020 - if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || 3021 - pmd_devmap(pmd))) { 3020 + if (unlikely(pmd_leaf(pmd))) { 3022 3021 /* See gup_pte_range() */ 3023 3022 if (pmd_protnone(pmd)) 3024 3023 return 0; ··· 3054 3055 next = pud_addr_end(addr, end); 3055 3056 if (unlikely(!pud_present(pud))) 3056 3057 return 0; 3057 - if (unlikely(pud_huge(pud) || pud_devmap(pud))) { 3058 + if (unlikely(pud_leaf(pud))) { 3058 3059 if (!gup_huge_pud(pud, pudp, addr, next, flags, 3059 3060 pages, nr)) 3060 3061 return 0; ··· 3107 3108 next = pgd_addr_end(addr, end); 3108 3109 if (pgd_none(pgd)) 3109 3110 return; 3110 - if (unlikely(pgd_huge(pgd))) { 3111 + if (unlikely(pgd_leaf(pgd))) { 3111 3112 if (!gup_huge_pgd(pgd, pgdp, addr, next, flags, 3112 3113 pages, nr)) 3113 3114 return;