[patch V4 0/8] mm/highmem: Preemptible variant of kmap_atomic & friends

From: Thomas Gleixner
Date: Wed Nov 18 2020 - 15:58:35 EST


This is the outstanding set of patches for the preemptible kmap_*()
implementation. The previous version is here:

https://lore.kernel.org/r/20201103092712.714480842@xxxxxxxxxxxxx

The following changes come with it:

- Better debugging for kmap* by enforcing the temporary mappings even for
lowmem pages when the architecture allows it.

- Support for enforced mappings on X86 for both 32 and 64 bit. As
KMAP_LOCAL is already independent from HIGHMEM this needs only the extra
fixmap space on 64bit and no further code changes.

- Removing the RT dependency from migrate_disable/enable(). This patch
still needs some help from the scheduler folks vs. the comment in
preempt.h.

- Switching from per CPU storage of the kmap index to a per task storage
by adding a pteval array to the per task storage which contains the
ptevals of the currently active temporary kmaps

- Adding context switch code which checks whether the outgoing or the
incoming task has active temporary kmaps. If so, the outgoing task's
kmaps are removed and the incoming task's kmaps are restored.

- Adding new interfaces k[un]map_local*() which are not disabling
preemption and can be called from any context (except NMI).

Contrary to kmap() which provides preemptible and "persistant" mappings,
these interfaces are meant to replace the temporary mappings provided by
kmap_atomic*() today.

This allows to get rid of conditional mapping choices and allows to have
preemptible short term "mappings" on 64bit which are today enforced to be
non-preemptible due to the highmem constraints. It clearly puts overhead on
the highmem users, but highmem is slow anyway.

This is not a wholesale conversion which makes kmap_atomic magically
preemptible because there might be usage sites which rely on the implicit
preempt disable. So this needs to be done on a case by case basis and the
call sites converted to kmap_local().

Changes vs. V3:

- Rebased on top of the merged consolidation patches and on top of
the latest version of migrate disable support.

- New debug features (enforced mappings)

- Dropped the conversion patches as they need review from the respective
subsystems and better go through the relevant trees for 5.12

The series is based on

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git core/mm

with

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/core

merged in.

It is also available from git:

git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git highmem

Thanks,

tglx
---
Documentation/driver-api/io-mapping.rst | 74 +++++++++++--------
arch/x86/Kconfig | 1
arch/x86/include/asm/fixmap.h | 12 ++-
arch/x86/include/asm/pgtable_64_types.h | 6 +
arch/x86/kernel/crash_dump_32.c | 48 ++----------
include/asm-generic/kmap_size.h | 2
include/linux/highmem-internal.h | 58 +++++++++++++++
include/linux/highmem.h | 43 +++++++----
include/linux/io-mapping.h | 30 +++++++
include/linux/kernel.h | 21 +++--
include/linux/preempt.h | 38 ----------
include/linux/sched.h | 11 ++
kernel/entry/common.c | 2
kernel/fork.c | 1
kernel/sched/core.c | 63 ++++++++++++++--
kernel/sched/sched.h | 4 -
lib/Kconfig.debug | 22 +++++
lib/smp_processor_id.c | 2
mm/highmem.c | 121 ++++++++++++++++++++++++++++----
19 files changed, 400 insertions(+), 159 deletions(-)