linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch V3 00/37] mm/highmem: Preemptible variant of kmap_atomic & friends
@ 2020-11-03  9:27 Thomas Gleixner
  2020-11-03  9:27 ` [patch V3 01/37] mm/highmem: Un-EXPORT __kmap_atomic_idx() Thomas Gleixner
                   ` (36 more replies)
  0 siblings, 37 replies; 69+ messages in thread
From: Thomas Gleixner @ 2020-11-03  9:27 UTC (permalink / raw)
  To: LKML
  Cc: Linus Torvalds, Peter Zijlstra, Paul McKenney, Christoph Hellwig,
	Sebastian Andrzej Siewior, Andrew Morton, linux-mm,
	Alexander Viro, Benjamin LaHaise, linux-fsdevel, linux-aio,
	Chris Mason, Josef Bacik, David Sterba, linux-btrfs, x86,
	Vineet Gupta, linux-snps-arc, Russell King, Arnd Bergmann,
	linux-arm-kernel, linux-csky, Michal Simek, Thomas Bogendoerfer,
	linux-mips, Nick Hu, Greentime Hu, Vincent Chen,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev, David S. Miller, sparclinux, Chris Zankel,
	Max Filippov, linux-xtensa, Ingo Molnar, Juri Lelli,
	Vincent Guittot, Dietmar Eggemann, Steven Rostedt, Ben Segall,
	Mel Gorman, Daniel Bristot de Oliveira, Christian Koenig,
	Huang Rui, David Airlie, Daniel Vetter, dri-devel,
	VMware Graphics, Roland Scheidegger, Dave Airlie, Gerd Hoffmann,
	virtualization, spice-devel, Ben Skeggs, nouveau, Jani Nikula,
	Joonas Lahtinen, Rodrigo Vivi, intel-gfx

Following up to the discussion in:

  https://lore.kernel.org/r/20200914204209.256266093@linutronix.de

and the second version of this:

  https://lore.kernel.org/r/20201029221806.189523375@linutronix.de

this series provides a preemptible variant of kmap_atomic & related
interfaces.

This is achieved by:

 - Removing the RT dependency from migrate_disable/enable()

 - Consolidating all kmap atomic implementations in generic code including
   a useful version of the CONFIG_DEBUG_HIGHMEM which provides guard pages
   between the individual maps instead of just increasing the map size.

 - Switching from per CPU storage of the kmap index to a per task storage

 - 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().

Note, that this is only tested on X86 and completely untested on all other
architectures (at least it compiles except on csky which does not compile
with the newest cross tools from kernel.org independent of this change).

The lot is available from

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

It is based on Peter Zijlstras migrate disable branch which is close to be
merged into the tip tree, but still not finalized:

   git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git sched/migrate-disable

The series has the following parts:

    Patches  1 - 22: Consolidation work which is independent of the scheduler
    	       	     changes

		     79 files changed, 595 insertions(+), 1296 deletions(-)

    Patch   23:      Needs to be folded back into the sched/migrate-disable

    Patches 24 - 26: The preemptible kmap_local() implementation

    	       	     9 files changed, 283 insertions(+), 57 deletions(-)

    Patches 27 - 37: Cleanup of the less common kmap/io_map_atomic users

    	       	     19 files changed, 114 insertions(+), 256 deletions(-)

Vs. merging this pile:

If everyone agrees, I'd like to take the first part (1-22) through tip so
that the preemptible implementation can be sorted in tip once the scheduler
prerequisites are there. The initial cleanups (27-37) might have to wait if
there are conflicts vs. the drm/gpu tree. We'll see.

>From what I can tell kmap_atomic() can be removed all together and
completly replaced by kmap_local(). Most of the usage sites are trivial and
just doing memcpy(), memset() or trivial operations on the temporarily
mapped page. The interesting ones are those which do either conditional
stuff or have copy_.*_user_inatomic() inside. As shown with the crash and
drm/gpu cleanups this allows to simplify the code quite a bit.

Changes vs. V2:

  - Remove the migrate disable from kmap_local and only issue that when the
    there is an actual highmem mapping. (Linus)
  - Reordered the series so the consolidation is upfront
  - Get rid of kmap_types.h and the associated cruft
  - Fixup documentation and add function documentation for kmap_*
  - Splitout the internal implementation into a seperate header
  - More cleanups - removal of unused functions
  - Replace a few of the less frequently used kmap_atomic and
    io_mapping_map_atomic variants and remove those interfaces.

Thanks,

	tglx
---
 arch/alpha/include/asm/kmap_types.h                   |   15 
 arch/arc/include/asm/kmap_types.h                     |   14 
 arch/arm/include/asm/kmap_types.h                     |   10 
 arch/arm/mm/highmem.c                                 |  121 -------
 arch/ia64/include/asm/kmap_types.h                    |   13 
 arch/microblaze/mm/highmem.c                          |   78 ----
 arch/mips/include/asm/kmap_types.h                    |   13 
 arch/nds32/mm/highmem.c                               |   48 --
 arch/parisc/include/asm/kmap_types.h                  |   13 
 arch/powerpc/include/asm/kmap_types.h                 |   13 
 arch/powerpc/mm/highmem.c                             |   67 ----
 arch/sh/include/asm/kmap_types.h                      |   15 
 arch/sparc/include/asm/kmap_types.h                   |   11 
 arch/sparc/mm/highmem.c                               |  115 -------
 arch/um/include/asm/kmap_types.h                      |   13 
 arch/x86/include/asm/kmap_types.h                     |   13 
 b/Documentation/driver-api/io-mapping.rst             |   92 ++---
 b/arch/arc/Kconfig                                    |    1 
 b/arch/arc/include/asm/highmem.h                      |   26 +
 b/arch/arc/mm/highmem.c                               |   54 ---
 b/arch/arm/Kconfig                                    |    1 
 b/arch/arm/include/asm/fixmap.h                       |    4 
 b/arch/arm/include/asm/highmem.h                      |   33 +-
 b/arch/arm/mm/Makefile                                |    1 
 b/arch/arm/mm/cache-feroceon-l2.c                     |    6 
 b/arch/arm/mm/cache-xsc3l2.c                          |    4 
 b/arch/csky/Kconfig                                   |    1 
 b/arch/csky/include/asm/fixmap.h                      |    4 
 b/arch/csky/include/asm/highmem.h                     |    6 
 b/arch/csky/mm/highmem.c                              |   75 ----
 b/arch/microblaze/Kconfig                             |    1 
 b/arch/microblaze/include/asm/fixmap.h                |    4 
 b/arch/microblaze/include/asm/highmem.h               |    6 
 b/arch/microblaze/mm/Makefile                         |    1 
 b/arch/microblaze/mm/init.c                           |    6 
 b/arch/mips/Kconfig                                   |    1 
 b/arch/mips/include/asm/fixmap.h                      |    4 
 b/arch/mips/include/asm/highmem.h                     |    6 
 b/arch/mips/kernel/crash_dump.c                       |   42 --
 b/arch/mips/mm/highmem.c                              |   77 ----
 b/arch/mips/mm/init.c                                 |    4 
 b/arch/nds32/Kconfig.cpu                              |    1 
 b/arch/nds32/include/asm/fixmap.h                     |    4 
 b/arch/nds32/include/asm/highmem.h                    |   22 -
 b/arch/nds32/mm/Makefile                              |    1 
 b/arch/openrisc/mm/init.c                             |    1 
 b/arch/openrisc/mm/ioremap.c                          |    1 
 b/arch/powerpc/Kconfig                                |    1 
 b/arch/powerpc/include/asm/fixmap.h                   |    4 
 b/arch/powerpc/include/asm/highmem.h                  |    7 
 b/arch/powerpc/mm/Makefile                            |    1 
 b/arch/powerpc/mm/mem.c                               |    7 
 b/arch/sh/include/asm/fixmap.h                        |    8 
 b/arch/sh/mm/init.c                                   |    8 
 b/arch/sparc/Kconfig                                  |    1 
 b/arch/sparc/include/asm/highmem.h                    |    8 
 b/arch/sparc/include/asm/vaddrs.h                     |    4 
 b/arch/sparc/mm/Makefile                              |    3 
 b/arch/sparc/mm/srmmu.c                               |    2 
 b/arch/um/include/asm/fixmap.h                        |    1 
 b/arch/x86/Kconfig                                    |    3 
 b/arch/x86/include/asm/fixmap.h                       |    5 
 b/arch/x86/include/asm/highmem.h                      |   13 
 b/arch/x86/include/asm/iomap.h                        |   13 
 b/arch/x86/include/asm/paravirt_types.h               |    1 
 b/arch/x86/kernel/crash_dump_32.c                     |   48 --
 b/arch/x86/mm/highmem_32.c                            |   59 ---
 b/arch/x86/mm/init_32.c                               |   15 
 b/arch/x86/mm/iomap_32.c                              |   57 ---
 b/arch/xtensa/Kconfig                                 |    1 
 b/arch/xtensa/include/asm/fixmap.h                    |    4 
 b/arch/xtensa/include/asm/highmem.h                   |   12 
 b/arch/xtensa/mm/highmem.c                            |   46 --
 b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c      |    7 
 b/drivers/gpu/drm/i915/i915_gem.c                     |   40 --
 b/drivers/gpu/drm/i915/selftests/i915_gem.c           |    4 
 b/drivers/gpu/drm/i915/selftests/i915_gem_gtt.c       |    8 
 b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/fbmem.h |    8 
 b/drivers/gpu/drm/qxl/qxl_image.c                     |   18 -
 b/drivers/gpu/drm/qxl/qxl_ioctl.c                     |   27 -
 b/drivers/gpu/drm/qxl/qxl_object.c                    |   12 
 b/drivers/gpu/drm/qxl/qxl_object.h                    |    4 
 b/drivers/gpu/drm/qxl/qxl_release.c                   |    4 
 b/drivers/gpu/drm/ttm/ttm_bo_util.c                   |   20 -
 b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c                |   30 -
 b/fs/aio.c                                            |    1 
 b/fs/btrfs/ctree.h                                    |    1 
 b/include/asm-generic/Kbuild                          |    2 
 b/include/asm-generic/kmap_size.h                     |   12 
 b/include/linux/highmem-internal.h                    |  210 ++++++++++++
 b/include/linux/highmem.h                             |  294 ++++++------------
 b/include/linux/io-mapping.h                          |   28 -
 b/include/linux/kernel.h                              |   21 -
 b/include/linux/preempt.h                             |   38 --
 b/include/linux/sched.h                               |   11 
 b/kernel/entry/common.c                               |    2 
 b/kernel/fork.c                                       |    1 
 b/kernel/sched/core.c                                 |   63 +++
 b/kernel/sched/sched.h                                |    4 
 b/lib/smp_processor_id.c                              |    2 
 b/mm/Kconfig                                          |    3 
 b/mm/highmem.c                                        |  255 ++++++++++++++-
 include/asm-generic/kmap_types.h                      |   11 
 103 files changed, 959 insertions(+), 1576 deletions(-)

^ permalink raw reply	[flat|nested] 69+ messages in thread

end of thread, other threads:[~2020-11-12 11:08 UTC | newest]

Thread overview: 69+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03  9:27 [patch V3 00/37] mm/highmem: Preemptible variant of kmap_atomic & friends Thomas Gleixner
2020-11-03  9:27 ` [patch V3 01/37] mm/highmem: Un-EXPORT __kmap_atomic_idx() Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 02/37] highmem: Remove unused functions Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 03/37] fs: Remove asm/kmap_types.h includes Thomas Gleixner
2020-11-03 11:12   ` David Sterba
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 04/37] sh/highmem: Remove all traces of unused cruft Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 05/37] asm-generic: Provide kmap_size.h Thomas Gleixner
2020-11-03 12:25   ` Arnd Bergmann
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 06/37] highmem: Provide generic variant of kmap_atomic* Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 07/37] highmem: Make DEBUG_HIGHMEM functional Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 08/37] x86/mm/highmem: Use generic kmap atomic implementation Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 09/37] arc/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 10/37] ARM: highmem: Switch to generic kmap atomic Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
     [not found]   ` <CGME20201112081036eucas1p14e135a370d3bccab311727fd2e89f4df@eucas1p1.samsung.com>
2020-11-12  8:10     ` [patch V3 10/37] " Marek Szyprowski
2020-11-12 11:03       ` Thomas Gleixner
2020-11-12 11:07       ` Sebastian Andrzej Siewior
2020-11-03  9:27 ` [patch V3 11/37] csky/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 12/37] microblaze/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 13/37] mips/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 14/37] nds32/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 15/37] powerpc/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 16/37] sparc/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 17/37] xtensa/mm/highmem: " Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 18/37] highmem: Get rid of kmap_types.h Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 19/37] mm/highmem: Remove the old kmap_atomic cruft Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 20/37] io-mapping: Cleanup atomic iomap Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 21/37] Documentation/io-mapping: Remove outdated blurb Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 22/37] highmem: High implementation details and document API Thomas Gleixner
2020-11-03 17:48   ` Linus Torvalds
2020-11-03 19:00     ` Thomas Gleixner
2020-11-06 23:27   ` [tip: core/mm] " tip-bot2 for Thomas Gleixner
2020-11-03  9:27 ` [patch V3 23/37] sched: Make migrate_disable/enable() independent of RT Thomas Gleixner
2020-11-03  9:27 ` [patch V3 24/37] sched: highmem: Store local kmaps in task struct Thomas Gleixner
2020-11-03 13:49   ` Thomas Gleixner
2020-11-03 13:51   ` [patch V4 " Thomas Gleixner
2020-11-03  9:27 ` [patch V3 25/37] mm/highmem: Provide kmap_local* Thomas Gleixner
2020-11-03  9:27 ` [patch V3 26/37] io-mapping: Provide iomap_local variant Thomas Gleixner
2020-11-03  9:27 ` [patch V3 27/37] x86/crashdump/32: Simplify copy_oldmem_page() Thomas Gleixner
2020-11-03  9:27 ` [patch V3 28/37] mips/crashdump: " Thomas Gleixner
2020-11-03  9:27 ` [patch V3 29/37] ARM: mm: Replace kmap_atomic_pfn() Thomas Gleixner
2020-11-03  9:27 ` [patch V3 30/37] highmem: Remove kmap_atomic_pfn() Thomas Gleixner
2020-11-03  9:27 ` [patch V3 31/37] drm/ttm: Replace kmap_atomic() usage Thomas Gleixner
2020-11-03  9:27 ` [patch V3 32/37] drm/vmgfx: Replace kmap_atomic() Thomas Gleixner
2020-11-03  9:27 ` [patch V3 33/37] highmem: Remove kmap_atomic_prot() Thomas Gleixner
2020-11-03  9:27 ` [patch V3 34/37] drm/qxl: Replace io_mapping_map_atomic_wc() Thomas Gleixner
2020-11-03  9:27 ` [patch V3 35/37] drm/nouveau/device: " Thomas Gleixner
2020-11-03  9:27 ` [patch V3 36/37] drm/i915: " Thomas Gleixner
2020-11-03  9:27 ` [patch V3 37/37] io-mapping: Remove io_mapping_map_atomic_wc() Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).