From patchwork Sat Sep 19 09:17:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11786877 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 BB097139F for ; Sat, 19 Sep 2020 09:50:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CB1021582 for ; Sat, 19 Sep 2020 09:50:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ul0AzmKX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KbJ6GiNR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbgISJuD (ORCPT ); Sat, 19 Sep 2020 05:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbgISJuD (ORCPT ); Sat, 19 Sep 2020 05:50:03 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A32A7C0613CE; Sat, 19 Sep 2020 02:50:02 -0700 (PDT) Message-Id: <20200919091751.011116649@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1600509000; 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=wXMSkZdDTGr2cnZMoKDSJw7MNirhJVzX4vOCHJbvoN0=; b=ul0AzmKXYj0qCi93y+r/rwwgxSXPin2sTe3PYhi7zjaY3NKa41EvWRmaZkAKju2f4qLfIs i1aVPwNRkUKTlsYfZfyyB/zi5KZf7ZY7OD58PCvZV59UcRuCOhEQsNPck5r1VuTJtHi72C +LNe+RY18cKtN3h7SPt+666fUzU5ch+DkMG/6qPFHiUag3Vd24Fa5TJBueGpK9wLzW3bo0 IscYJhM/dQECgU1ilCEI7V6IMnuxdAonST0geBGtFlUWgd5xXJJx546wfo5abrk+4cO8Sx euhWyLJDvleHSJCh+QF6n/GwOhvNr9+hHKu+6tM3Z9VRQSgIOxJikgFGusnWsg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1600509000; 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=wXMSkZdDTGr2cnZMoKDSJw7MNirhJVzX4vOCHJbvoN0=; b=KbJ6GiNRGpCyvVdElEw4H+4LtrSHxOXy5YeKjcqGSrhkBp5nKWiHepRirVJ50oI9WjzN2D 1DCAFhaD9E835KBw== Date: Sat, 19 Sep 2020 11:17:51 +0200 From: Thomas Gleixner To: LKML Cc: linux-arch@vger.kernel.org, Linus Torvalds , Paul McKenney , x86@kernel.org, Sebastian Andrzej Siewior , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Andrew Morton , Linux-MM , Russell King , Linux ARM , Chris Zankel , Max Filippov , linux-xtensa@linux-xtensa.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , intel-gfx , dri-devel , Ard Biesheuvel , Herbert Xu , Vineet Gupta , linux-snps-arc@lists.infradead.org, Arnd Bergmann , 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 Subject: [patch RFC 00/15] mm/highmem: Provide a preemptible variant of kmap_atomic & friends MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org First of all, sorry for the horribly big Cc list! Following up to the discussion in: https://lore.kernel.org/r/20200914204209.256266093@linutronix.de this provides a preemptible variant of kmap_atomic & related interfaces. This is achieved by: - 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. The lot is also available from git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git highmem 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 | 30 +++-- 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 | 29 +++-- 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 | 141 +++++++++++++++--------- include/linux/io-mapping.h | 2 include/linux/sched.h | 9 + kernel/sched/core.c | 10 + mm/Kconfig | 3 mm/highmem.c | 192 ++++++++++++++++++++++++++++++++-- 49 files changed, 422 insertions(+), 909 deletions(-)