From patchwork Thu Oct 29 22:18:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11867735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85806697 for ; Thu, 29 Oct 2020 22:32:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DFE1D20FC3 for ; Thu, 29 Oct 2020 22:32:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QSHJIt7L"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bG4zbqkg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DFE1D20FC3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA1406B005C; Thu, 29 Oct 2020 18:32:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A4EEB6B005D; Thu, 29 Oct 2020 18:32:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C9EC6B0062; Thu, 29 Oct 2020 18:32:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 5EB036B005C for ; Thu, 29 Oct 2020 18:32:12 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 059C88249980 for ; Thu, 29 Oct 2020 22:32:12 +0000 (UTC) X-FDA: 77426412504.10.jam36_581085127291 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id CF85A16A0BE for ; Thu, 29 Oct 2020 22:32:11 +0000 (UTC) X-Spam-Summary: 1,0,0,1d4e477471f23912,d41d8cd98f00b204,tglx@linutronix.de,,RULES_HIT:1:2:41:69:152:355:379:421:800:967:968:973:988:989:1183:1185:1260:1277:1311:1313:1314:1345:1437:1514:1515:1516:1518:1593:1594:1605:1730:1747:1777:1792:1801:1981:2194:2199:2393:2525:2559:2564:2682:2685:2859:2911:2914:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4049:4250:4321:4362:4425:4605:5007:6117:6261:6653:6742:6743:7875:7903:7974:8660:9025:10004:11026:11658:11914:12043:12050:12160:12291:12296:12297:12555:12683:12986:13148:13161:13180:13229:13230:13846:14095:14096:21080:21222:21325:21433:21627:21939:30003:30012:30041:30045:30054:30091,0,RBL:193.142.43.55:@linutronix.de:.lbl8.mailshell.net-62.14.6.100 64.201.201.201;04ygnjtefb8zbfzuf639bq8zewn6gycysw899xsztjy5zchz97hdoac6ryj8u7f.xbijuq7d7thue3d8mqzpme41mswwgb9yg41huj7c3o9j9zdci5sijc3nt3sgs6g.o-lbl8.mailshell.net-223.238.255.100 ,CacheIP X-HE-Tag: jam36_581085127291 X-Filterd-Recvd-Size: 12107 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 29 Oct 2020 22:32:10 +0000 (UTC) Message-Id: <20201029221806.189523375@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604010728; 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=dHsj3bB6txbW51auQ1NY6Tbn9YUEP9hPQj+cerV4cH0=; b=QSHJIt7LvlxNN9hJ0pBq2tvQAj6s9PRKwf9DDs+9wLl0TB3D07XB2aNc/P+jBNvq3OKdlB 9uImGW8KQrL2/v2DDWGmYr3ItyplTubI+62xRgbsyi4IeFKyTQeBZLSpOp/k//RoMYNU0D MRXq2PcsrvKw8tKj6JtpzI7I7c+m0/l1rgAB1Q7e0HTSfRHwiF/OYPDVhjJi/t5CuooKwL 72rzQkellKlgnCIrCAJFk+1lKoYhevy2jnE7fElUwMoYj2u61NhwHpz39yR1AKfSxC9hiI tHhi3pMD0MqXztTmwu1jN5JS5hiXfWpnm7xNyzYqMOICUggRy8lWVYhFp7D5AA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604010728; 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=dHsj3bB6txbW51auQ1NY6Tbn9YUEP9hPQj+cerV4cH0=; b=bG4zbqkg1p92+Z0M4jQM3XbBv8SsS1VZa551XHoVYcBtO5FLMANBcd4TnLvpnuGvnhoALG sOxX2o7Ksc9Qt8DQ== Date: Thu, 29 Oct 2020 23:18:06 +0100 From: Thomas Gleixner To: LKML Cc: linux-arch@vger.kernel.org, Linus Torvalds , Peter Zijlstra , Paul McKenney , David Airlie , Daniel Vetter , Ard Biesheuvel , Herbert Xu , Christoph Hellwig , Sebastian Andrzej Siewior , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Andrew Morton , linux-mm@kvack.org, x86@kernel.org, Vineet Gupta , linux-snps-arc@lists.infradead.org, Russell King , Arnd Bergmann , linux-arm-kernel@lists.infradead.org, Guo Ren , linux-csky@vger.kernel.org, Michal Simek , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Nick Hu , Greentime Hu , Vincent Chen , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, "David S. Miller" , sparclinux@vger.kernel.org, Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org Subject: [patch V2 00/18] mm/highmem: Preemptible variant of kmap_atomic & friends MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Following up to the discussion in: https://lore.kernel.org/r/20200914204209.256266093@linutronix.de and the initial version of this: https://lore.kernel.org/r/20200919091751.011116649@linutronix.de this series provides a preemptible variant of kmap_atomic & related interfaces. Now that the scheduler folks have wrapped their heads around the migration disable scheduler woes, there is not a real reason anymore to confine migration disabling to RT. As expressed in the earlier discussion by graphics and crypto folks, there is interest to get rid of their kmap_atomic* usage because they need only a temporary stable map and not all the bells and whistels of kmap_atomic*. This series provides kmap_local.* iomap_local variants which only disable migration to keep the virtual mapping address stable accross preemption, but do neither disable pagefaults nor preemption. The new functions can be used in any context, but if used in atomic context the caller has to take care of eventually disabling pagefaults. This is achieved by: - Removing the RT dependency from migrate_disable/enable() - Consolidating all kmap atomic implementations in generic code - 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_temporary*() 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_temporary. Note, that this is only lightly tested on X86 and completely untested on all other architectures. There is also a still to be investigated question from Linus on the initial posting versus the per cpu / per task mapping stack depth which might need to be made larger due to the ability to take page faults within a mapping region. Though I wanted to share the current state of affairs before investigating that further. If there is consensus in going forward with this, I'll have a deeper look into this issue. 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 Changes vs. V1: - Make it truly functional by depending on migrate disable/enable (Brown paperbag) - Rename to kmap_local.* (Linus) - Fix the sched in/out issue Linus pointed out - Fix a few style issues (Christoph) - Split a few things out into seperate patches to make review simpler - Pick up acked/reviewed tags as appropriate Thanks, tglx --- a/arch/arm/mm/highmem.c | 121 ------------------ a/arch/microblaze/mm/highmem.c | 78 ------------ a/arch/nds32/mm/highmem.c | 48 ------- a/arch/powerpc/mm/highmem.c | 67 ---------- a/arch/sparc/mm/highmem.c | 115 ----------------- arch/arc/Kconfig | 1 arch/arc/include/asm/highmem.h | 8 + arch/arc/mm/highmem.c | 44 ------ arch/arm/Kconfig | 1 arch/arm/include/asm/highmem.h | 31 +++- arch/arm/mm/Makefile | 1 arch/csky/Kconfig | 1 arch/csky/include/asm/highmem.h | 4 arch/csky/mm/highmem.c | 75 ----------- arch/microblaze/Kconfig | 1 arch/microblaze/include/asm/highmem.h | 6 arch/microblaze/mm/Makefile | 1 arch/microblaze/mm/init.c | 6 arch/mips/Kconfig | 1 arch/mips/include/asm/highmem.h | 4 arch/mips/mm/highmem.c | 77 ------------ arch/mips/mm/init.c | 3 arch/nds32/Kconfig.cpu | 1 arch/nds32/include/asm/highmem.h | 21 ++- arch/nds32/mm/Makefile | 1 arch/powerpc/Kconfig | 1 arch/powerpc/include/asm/highmem.h | 6 arch/powerpc/mm/Makefile | 1 arch/powerpc/mm/mem.c | 7 - arch/sparc/Kconfig | 1 arch/sparc/include/asm/highmem.h | 7 - arch/sparc/mm/Makefile | 3 arch/sparc/mm/srmmu.c | 2 arch/x86/include/asm/fixmap.h | 1 arch/x86/include/asm/highmem.h | 12 + arch/x86/include/asm/iomap.h | 13 -- arch/x86/mm/highmem_32.c | 59 --------- arch/x86/mm/init_32.c | 15 -- arch/x86/mm/iomap_32.c | 57 -------- arch/xtensa/Kconfig | 1 arch/xtensa/include/asm/highmem.h | 9 + arch/xtensa/mm/highmem.c | 44 ------ b/arch/x86/Kconfig | 3 include/linux/highmem.h | 203 ++++++++++++++++++++++--------- include/linux/io-mapping.h | 42 +++++- include/linux/preempt.h | 38 ----- include/linux/sched.h | 11 + kernel/entry/common.c | 2 kernel/fork.c | 1 kernel/sched/core.c | 30 +++- kernel/sched/sched.h | 2 lib/smp_processor_id.c | 2 mm/Kconfig | 3 mm/highmem.c | 218 ++++++++++++++++++++++++++++++++-- 54 files changed, 542 insertions(+), 969 deletions(-)