linux-stable/arch/arm
Hugh Dickins 766b59e876 arm: allow pte_offset_map[_lock]() to fail
Patch series "arch: allow pte_offset_map[_lock]() to fail", v2.

What is it all about?  Some mmap_lock avoidance i.e.  latency reduction. 
Initially just for the case of collapsing shmem or file pages to THPs; but
likely to be relied upon later in other contexts e.g.  freeing of empty
page tables (but that's not work I'm doing).  mmap_write_lock avoidance
when collapsing to anon THPs?  Perhaps, but again that's not work I've
done: a quick attempt was not as easy as the shmem/file case.

I would much prefer not to have to make these small but wide-ranging
changes for such a niche case; but failed to find another way, and have
heard that shmem MADV_COLLAPSE's usefulness is being limited by that
mmap_write_lock it currently requires.

These changes (though of course not these exact patches, and not all of
these architectures!) have been in Google's data centre kernel for three
years now: we do rely upon them.

What are the per-arch changes about?  Generally, two things.

One: the current mmap locking may not be enough to guard against that
tricky transition between pmd entry pointing to page table, and empty pmd
entry, and pmd entry pointing to huge page: pte_offset_map() will have to
validate the pmd entry for itself, returning NULL if no page table is
there.  What to do about that varies: often the nearby error handling
indicates just to skip it; but in some cases a "goto again" looks
appropriate (and if that risks an infinite loop, then there must have been
an oops, or pfn 0 mistaken for page table, before).

Deeper study of each site might show that 90% of them here in arch code
could only fail if there's corruption e.g.  a transition to THP would be
surprising on an arch without HAVE_ARCH_TRANSPARENT_HUGEPAGE.  But given
the likely extension to freeing empty page tables, I have not limited this
set of changes to THP; and it has been easier, and sets a better example,
if each site is given appropriate handling.

Two: pte_offset_map() will need to do an rcu_read_lock(), with the
corresponding rcu_read_unlock() in pte_unmap().  But most architectures
never supported CONFIG_HIGHPTE, so some don't always call pte_unmap()
after pte_offset_map(), or have used userspace pte_offset_map() where
pte_offset_kernel() is more correct.  No problem in the current tree, but
a problem once an rcu_read_unlock() will be needed to keep balance.

A common special case of that comes in arch/*/mm/hugetlbpage.c, if the
architecture supports hugetlb pages down at the lowest PTE level. 
huge_pte_alloc() uses pte_alloc_map(), but generic hugetlb code does no
corresponding pte_unmap(); similarly for huge_pte_offset().

In rare transient cases, not yet made possible, pte_offset_map() and
pte_offset_map_lock() may not find a page table: handle appropriately.

Link: https://lkml.kernel.org/r/a4963be9-7aa6-350-66d0-2ba843e1af44@google.com
Link: https://lkml.kernel.org/r/813429a1-204a-1844-eeae-7fd72826c28@google.com
Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Greg Ungerer <gerg@linux-m68k.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: John David Anglin <dave.anglin@bell.net>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Will Deacon <will@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-06-19 16:19:05 -07:00
..
boot i.MX fixes for 6.4: 2023-05-25 17:22:38 +02:00
common ARM: Convert to platform remove callback returning void 2023-03-17 16:03:57 +01:00
configs - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
crypto This update includes the following changes: 2023-02-21 18:10:50 -08:00
include ARM: perf: Mark all accessor functions inline 2023-05-16 14:57:29 +01:00
kernel ARM updates for v6.4-rc1 2023-05-14 09:17:32 -07:00
lib arm: allow pte_offset_map[_lock]() to fail 2023-06-19 16:19:05 -07:00
mach-actions treewide: Trace IPIs sent via smp_send_reschedule() 2023-03-24 11:01:28 +01:00
mach-airoha
mach-alpine
mach-artpec
mach-asm9260
mach-aspeed
mach-at91
mach-axxia
mach-bcm ARM: bcm: Use of_address_to_resource() 2023-03-24 14:08:43 -07:00
mach-berlin
mach-clps711x
mach-davinci Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
mach-digicolor
mach-dove PCI: Introduce pci_dev_for_each_resource() 2023-04-04 10:43:52 -05:00
mach-ep93xx ARM: SoC updates for 6.3 2023-02-20 15:36:37 -08:00
mach-exynos ARM: EXYNOS: Use of_address_to_resource() 2023-03-22 18:47:01 +01:00
mach-footbridge ARM: unused boardfile removal for 6.3 2023-02-20 15:28:57 -08:00
mach-gemini
mach-highbank
mach-hisi
mach-hpe
mach-imx i.MX SoC changes for 6.4: 2023-04-14 14:04:03 +02:00
mach-ixp4xx
mach-keystone
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson
mach-milbeaut
mach-mmp ARM: mmp: remove obsolete config USB_EHCI_MV_U2O 2023-03-19 22:25:45 +01:00
mach-moxart
mach-mstar ARM: mstar: remove unused config MACH_MERCURY 2023-03-24 18:53:25 +01:00
mach-mv78xx0 pci-v6.4-changes 2023-04-27 10:45:30 -07:00
mach-mvebu
mach-mxs ARM: mxs: Use of_property_present() for testing DT property presence 2023-03-14 15:05:52 +08:00
mach-nomadik
mach-npcm
mach-nspire
mach-omap1 gpio updates for v6.4-rc1 2023-04-25 17:18:18 -07:00
mach-omap2 gpio updates for v6.4-rc1 2023-04-25 17:18:18 -07:00
mach-orion5x pci-v6.4-changes 2023-04-27 10:45:30 -07:00
mach-pxa Input updates for 6.4 merge window: 2023-05-01 17:18:56 -07:00
mach-qcom firmware: qcom_scm: Move qcom_scm.h to include/linux/firmware/qcom/ 2023-02-08 19:15:16 -08:00
mach-rda
mach-realtek
mach-rockchip
mach-rpc lazy tlb: introduce lazy tlb mm refcount helper functions 2023-03-28 16:20:08 -07:00
mach-s3c ARM: s3c64xx: Use the right include 2023-03-06 12:33:01 +02:00
mach-s5pv210
mach-sa1100 ARM updates for v6.4-rc1 2023-05-14 09:17:32 -07:00
mach-shmobile ARM: sh-mobile: Use of_cpu_node_to_id() to read CPU node 'reg' 2023-03-30 16:02:42 +02:00
mach-socfpga
mach-spear ARM: spear: remove obsolete config MACH_SPEAR600 2023-03-24 18:53:08 +01:00
mach-sti
mach-stm32 ARM: stm32: add support for STM32MP151 2023-03-28 16:39:36 +02:00
mach-sunplus
mach-sunxi ARM: sunxi: Drop of_device.h include 2023-04-13 17:46:34 -05:00
mach-tegra power: remove pda_power supply driver 2023-02-01 17:23:38 +01:00
mach-uniphier
mach-ux500
mach-versatile
mach-vt8500
mach-zynq
mm arm: allow pte_offset_map[_lock]() to fail 2023-06-19 16:19:05 -07:00
net
nwfpe
plat-orion ARM: orion/gpio: Use the right include 2023-03-06 12:33:00 +02:00
probes
tools cachestat: wire up cachestat for other architectures 2023-06-09 16:25:16 -07:00
vdso vdso: Improve cmd_vdso_check to check all dynamic relocations 2023-03-21 21:15:34 +01:00
vfp ARM: 9297/1: vfp: avoid unbalanced stack on 'success' return path 2023-05-10 10:50:25 +01:00
xen
Kbuild
Kconfig - Nick Piggin's "shoot lazy tlbs" series, to improve the peformance of 2023-04-27 19:42:02 -07:00
Kconfig-nommu
Kconfig.assembler
Kconfig.debug ARM udpates for 6.3-rc1 2023-02-21 15:21:29 -08:00
Makefile ARM: oxnas: remove OXNAS support 2023-04-04 16:32:37 +02:00