From patchwork Fri May 8 14:40:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 11536733 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 CAA01139F for ; Fri, 8 May 2020 14:40:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A178420CC7 for ; Fri, 8 May 2020 14:40:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A178420CC7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9CA1C8E0005; Fri, 8 May 2020 10:40:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9A0828E0003; Fri, 8 May 2020 10:40:53 -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 8B6818E0005; Fri, 8 May 2020 10:40:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 73B458E0003 for ; Fri, 8 May 2020 10:40:53 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3679E16934 for ; Fri, 8 May 2020 14:40:53 +0000 (UTC) X-FDA: 76793813586.20.wood25_7c15d59ce224b X-Spam-Summary: 2,0,0,dea84165972f9425,d41d8cd98f00b204,joro@8bytes.org,,RULES_HIT:41:69:355:379:541:800:967:968:973:988:989:1260:1345:1437:1534:1542:1711:1730:1747:1777:1792:1801:2194:2199:2393:2525:2559:2566:2570:2682:2685:2693:2703:2859:2911:2933:2937:2939:2942:2945:2947:2951:2954:3022:3354:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4361:4425:4605:5007:6119:6120:6261:7514:7903:9025:10004:11658:13161:13180:13229,0,RBL:81.169.241.247:@8bytes.org:.lbl8.mailshell.net-64.201.201.201 62.14.6.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: wood25_7c15d59ce224b X-Filterd-Recvd-Size: 4007 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Fri, 8 May 2020 14:40:52 +0000 (UTC) Received: by theia.8bytes.org (Postfix, from userid 1000) id 404DF423; Fri, 8 May 2020 16:40:50 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: hpa@zytor.com, Dave Hansen , Andy Lutomirski , Peter Zijlstra , rjw@rjwysocki.net, Arnd Bergmann , Andrew Morton , Steven Rostedt , Vlastimil Babka , Michal Hocko , Joerg Roedel , joro@8bytes.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 0/7] mm: Get rid of vmalloc_sync_(un)mappings() Date: Fri, 8 May 2020 16:40:36 +0200 Message-Id: <20200508144043.13893-1-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 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: Hi, after the recent issue with vmalloc and tracing code[1] on x86 and a long history of previous issues related to the vmalloc_sync_mappings() interface, I thought the time has come to remove it. Please see [2], [3], and [4] for some other issues in the past. The patches are based on v5.7-rc4 and add tracking of page-table directory changes to the vmalloc and ioremap code. Depending on which page-table levels changes have been made, a new per-arch function is called: arch_sync_kernel_mappings(). On x86-64 with 4-level paging, this function will not be called more than 64 times in a systems runtime (because vmalloc-space takes 64 PGD entries which are only populated, but never cleared). As a side effect this also allows to get rid of vmalloc faults on x86, making it safe to touch vmalloc'ed memory in the page-fault handler. Note that this potentially includes per-cpu memory. The code is tested on x86-64, x86-32 with and without PAE. It also fixes the issue described in [1]. Additionally this code has been compile-tested on almost all architectures supported by Linux. I couldn't find working compilers for hexagon and unicore32, so these are not tested. Please review. Regards, Joerg [1] https://lore.kernel.org/lkml/20200430141120.GA8135@suse.de/ [2] https://lore.kernel.org/lkml/20191009124418.8286-1-joro@8bytes.org/ [3] https://lore.kernel.org/lkml/20190719184652.11391-1-joro@8bytes.org/ [4] https://lore.kernel.org/lkml/20191126111119.GA110513@gmail.com/ Joerg Roedel (7): mm: Add functions to track page directory modifications mm/vmalloc: Track which page-table levels were modified mm/ioremap: Track which page-table levels were modified x86/mm/64: Implement arch_sync_kernel_mappings() x86/mm/32: Implement arch_sync_kernel_mappings() mm: Remove vmalloc_sync_(un)mappings() x86/mm: Remove vmalloc faulting arch/x86/include/asm/pgtable-2level_types.h | 2 + arch/x86/include/asm/pgtable-3level_types.h | 2 + arch/x86/include/asm/pgtable_64_types.h | 2 + arch/x86/include/asm/switch_to.h | 23 --- arch/x86/kernel/setup_percpu.c | 6 +- arch/x86/mm/fault.c | 176 +------------------- arch/x86/mm/init_64.c | 5 + arch/x86/mm/pti.c | 8 +- drivers/acpi/apei/ghes.c | 6 - include/asm-generic/5level-fixup.h | 5 +- include/asm-generic/pgtable.h | 23 +++ include/linux/mm.h | 46 +++++ include/linux/vmalloc.h | 13 +- kernel/notifier.c | 1 - lib/ioremap.c | 46 +++-- mm/nommu.c | 12 -- mm/vmalloc.c | 109 +++++++----- 17 files changed, 199 insertions(+), 286 deletions(-)