From patchwork Tue Nov 3 09:27:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 1392957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=hegIh9lQ; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=G8VVQuzS; dkim=fail reason="signature verification failed" header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=alxfeweV; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CQSYv1TGlz9sVD for ; Tue, 3 Nov 2020 22:42:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Subject:To:From:Date:Message-Id: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=EYkr2qUaskWB7aBwPgbnCKIF+rdc5X9j0GBtHuNk87E=; b=hegIh9lQLWV6zxR/nZwskgfwRg 3yvyAaXGnyP2T5D5hUL7O25UIrqn655bQvdMj2DZknVY5KAIkseYXqsXvO6qjDY56CqNg9XrsWFv/ COeleg5FOhL5HpeKIbayOP+xZVWNRu41dYJyIajutvWyEG3iCRgGQ8piGNTIfcbEbjYjooSfN7eb7 3stbRFqa+3l2PF9t18NfUB1xTBP76GHRkKzMJpIXUY0bPeJ0i+4yq8LS8dzAAAE36510ElnWEEYww SvGrtDl5WK6KG6eYTGS+uA4iYSCRLfmhrWYOfzsIzmFc+UG2DhW5N+c9j9TZJsmZkqZdHjGEv7T6e vj3Y9PJQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZuhT-00033Y-Fm; Tue, 03 Nov 2020 11:42:07 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZtcy-0002rM-0Z; Tue, 03 Nov 2020 10:33:26 +0000 Message-Id: <20201103092712.714480842@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604399602; h=from:from: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; bh=o0Hcy+w+YfdhRzI7mxi56wApHLzMvMt3eijNSMso0PA=; b=G8VVQuzSAG/V3pki7i+aDmE0pr8JhWsV0h1Xg4lWsQluQ7DQ15Ya/IgR0Zw/NMpisVqD/W J/QXEkNEe7NbJqy5Bpmqb8HIJU2Y0O9Bf3CxSUTWS6PBz1JGzlayb0IYq+e5effS3/x5UD MIe/Xe/FG1i/b9FZAe9aHhyyyddX9t7dKFQEPgsOg2KREqovaLBnC0b+0gXF8QmMVtRTpz P8qKTXJkFfaFevqgVNzuSzGRJDl/f8Ri4mxz/TFPyTFN4RhGaqVC7XfpgwRxpGndKVfLoD i26gQR4JX8Q2WWAJMzSewtdQIauZvSoL5odzs7HswoiORYaM8qGtPEpIoF7usw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604399602; h=from:from: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; bh=o0Hcy+w+YfdhRzI7mxi56wApHLzMvMt3eijNSMso0PA=; b=alxfeweVuLzYm2Bj4Ox9pc6F2AVmJk6jrW4CNT45uolk8+Mr53KYB3lrXulO39NFAKfxk9 Xl6j5YSOg+Mrc1BA== Date: Tue, 03 Nov 2020 10:27:12 +0100 From: Thomas Gleixner To: LKML Subject: [patch V3 00/37] mm/highmem: Preemptible variant of kmap_atomic & friends MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201103_053324_326684_21AA5464 X-CRM114-Status: GOOD ( 21.97 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [193.142.43.55 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juri Lelli , linux-aio@kvack.org, Peter Zijlstra , Benjamin Herrenschmidt , Sebastian Andrzej Siewior , Joonas Lahtinen , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, Ben Segall , Chris Mason , Huang Rui , Paul Mackerras , Gerd Hoffmann , Daniel Bristot de Oliveira , sparclinux@vger.kernel.org, Vincent Chen , Christoph Hellwig , Vincent Guittot , Paul McKenney , Max Filippov , Michael Ellerman , x86@kernel.org, Russell King , linux-csky@vger.kernel.org, Ingo Molnar , David Airlie , VMware Graphics , Mel Gorman , nouveau@lists.freedesktop.org, Dave Airlie , linux-snps-arc@lists.infradead.org, Ben Skeggs , linux-xtensa@linux-xtensa.org, Arnd Bergmann , intel-gfx@lists.freedesktop.org, Roland Scheidegger , Josef Bacik , Steven Rostedt , Linus Torvalds , Alexander Viro , spice-devel@lists.freedesktop.org, David Sterba , Rodrigo Vivi , Dietmar Eggemann , linux-arm-kernel@lists.infradead.org, Jani Nikula , Chris Zankel , Michal Simek , Thomas Bogendoerfer , Nick Hu , linux-mm@kvack.org, Vineet Gupta , linux-mips@vger.kernel.org, Christian Koenig , Benjamin LaHaise , Daniel Vetter , linux-fsdevel@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , linux-btrfs@vger.kernel.org, Greentime Hu Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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(-)