From patchwork Wed Aug 22 15:30:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 10573023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5AA8A1390 for ; Wed, 22 Aug 2018 15:46:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49E192B783 for ; Wed, 22 Aug 2018 15:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C4562B79C; Wed, 22 Aug 2018 15:46:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A53B2B783 for ; Wed, 22 Aug 2018 15:46:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1177E6B251E; Wed, 22 Aug 2018 11:46:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0A0496B251F; Wed, 22 Aug 2018 11:46:09 -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 E5B936B2520; Wed, 22 Aug 2018 11:46:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f70.google.com (mail-wm0-f70.google.com [74.125.82.70]) by kanga.kvack.org (Postfix) with ESMTP id 894C96B251E for ; Wed, 22 Aug 2018 11:46:08 -0400 (EDT) Received: by mail-wm0-f70.google.com with SMTP id y18-v6so2068565wma.9 for ; Wed, 22 Aug 2018 08:46:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:message-id:user-agent:date:from :to:cc:subject:references:mime-version; bh=gBeaEcB0CRaE9iudyXRMqxnJyX6OHIKa2QWqyXhblwA=; b=KFFln+2v5Wg69GTtytOoG9LG7xmIRuz3iW9LxJaBe/D5558+k1AJsOws0euW3tiTyE GqY/r5O8P2JSyiv+visEhKN/xiMZ8ekRtUW62Bxyrtg19f13PMWgDF9Cccz9cGo3mffR 3lZaZH+d0PhDtL0Ev07zauWCjfYuT8Why/AlNO65VlAbYqMwHPSHXbIEdCzN4gMijAj0 SNutEhVOoc51xWG04x9+FWVXXNXgQUoZ0gAxVdd1gORjKbza6kz9Sm2fzVXWnp0A1Su7 7wVISi535cCVr6dkYMLa4QHenVyUcDFk9Ym1UwSEao2HdhiNy0wnZ3FEsvSkGHMSTW0n XOmg== X-Gm-Message-State: APzg51CSf4sjkg3S3x2qhPJCnbmztjfMUQvfW+ghz4pqjvxrcFvreXy3 RTtwkW7LL9sznjP5cWh9fJinEk4QJ1f0445JMS2ZWhKLBZZ2pE1kvKFCYu9o8ijgL3hFCoFSegf 3VeXDHRHDWFCMe4J93f0EHbO7MB2Yket0hnbkdyF1nzjAudDyZlLekDJ6wKq+Pg3Y/A== X-Received: by 2002:a1c:e146:: with SMTP id y67-v6mr2617333wmg.108.1534952768071; Wed, 22 Aug 2018 08:46:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaG58KKlg9vK8yEE3FqCsLnuNd3BW6hIf1Efb9W/kHjoCZ1x0fCy0YyrdbVJUJQ3fYVQpb4 X-Received: by 2002:a1c:e146:: with SMTP id y67-v6mr2617295wmg.108.1534952767179; Wed, 22 Aug 2018 08:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534952767; cv=none; d=google.com; s=arc-20160816; b=jb4WnKOdZEOYZhX32Bbzc9XSqfaIL/IiRYbFgSv8c09dmhbsfgUnwQV2mxr8u3v4D+ 3oo1YAH9G9cySlRhPzaWAcQQe1VkPn1Qd23N+HAVF6mZfkBGq+fmF8FceLbXAqTwiKRl 8sXTAr/iqh54qqJ0RL4QaHuK9dSp2tkDX0sGtRgU/O+M9Lx8mNLKzqrFTC/nI8DhwDCP tWZL8ELQCCr06rHcuysGrglXS/mJQxekhRXhcVl07QGV/Blvck5c13swUBKB6x6vY8Ud U/8p/QZb2+BzwpeW/5ZiH4nHyteBFQmarevFh1m4osm/TouPjiNt/Wb70Z0W0+MzVqK1 7TXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:subject:cc:to:from:date:user-agent :message-id:dkim-signature:arc-authentication-results; bh=gBeaEcB0CRaE9iudyXRMqxnJyX6OHIKa2QWqyXhblwA=; b=Lt5xVOWStKpvdRYQ1nxDYwAn/TfcvJe+dxd5niRJKLg1Lc/5zwcT6NT7SYzcpn6bOk ZsBgN6CYoASueAcf/qBJRIv7sq8JHSaI4pzZfoCcrF76l35V/V3OoQb9ATMcR5Au02b5 /QZ8F9+hkkyCvaskE9R0eIrg7CtB2qVi4dWCh6JcBYVQas45nI7HR4IzRHPaQ4r0o7+p sDdKhzJirZWyY3EtH10k2TWzI5xZ26CLmkqkcmjGoGUjBsVyHcDqlaCqVH/7347Pg4ns vTUo2uRDbyxMqEF13mDG3CfjGeCtyfPQ5/RDYFUGSmeE8CzlaDxewxn2xNACumn4Pg+l hqLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=p8G9EifM; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 2001:8b0:10b:1231::1 as permitted sender) smtp.mailfrom=peterz@infradead.org Received: from merlin.infradead.org (merlin.infradead.org. [2001:8b0:10b:1231::1]) by mx.google.com with ESMTPS id w73-v6si1662086wmw.15.2018.08.22.08.46.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 08:46:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of peterz@infradead.org designates 2001:8b0:10b:1231::1 as permitted sender) client-ip=2001:8b0:10b:1231::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=p8G9EifM; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 2001:8b0:10b:1231::1 as permitted sender) smtp.mailfrom=peterz@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gBeaEcB0CRaE9iudyXRMqxnJyX6OHIKa2QWqyXhblwA=; b=p8G9EifMms1fnFzIqWxv4jM6D0 0B4AEcLzmWE82yYl6NkQstHOzRaDl6nz148SfhDGz2POBDPUnTAsFeykKD15z9nlHnl3UPh4STzDz /IvBYWeIjwOLR2oH53h0kGxmGAFj5Xa6jRNvfNOaqqrhI0br6H3XbCckmWOd7dxwjWxwuDcmmhWEX xSDrnlqpqemTVvJNSZGc21VZjQXWL55S+9DTWiL53eJUr/FgkOZEWzcgTw0PiO35IB+YVmYf7RbFL bv68dVEqmevxLaN2YagmWBfXpkVAK6PL+iC9Ja20Ms1U52qXQvkSpjJt7XmBbzcr4KeSi3zBf2xks zJsIiR3A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsVKN-0000WU-K1; Wed, 22 Aug 2018 15:45:47 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id C627D2024D726; Wed, 22 Aug 2018 17:45:44 +0200 (CEST) Message-ID: <20180822154046.877071284@infradead.org> User-Agent: quilt/0.65 Date: Wed, 22 Aug 2018 17:30:16 +0200 From: Peter Zijlstra To: torvalds@linux-foundation.org Cc: peterz@infradead.org, luto@kernel.org, x86@kernel.org, bp@alien8.de, will.deacon@arm.com, riel@surriel.com, jannh@google.com, ascannell@google.com, dave.hansen@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/4] x86/mm: Only use tlb_remove_table() for paravirt References: <20180822153012.173508681@infradead.org> 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: X-Virus-Scanned: ClamAV using ClamSMTP If we don't use paravirt; don't play unnecessary and complicated games to free page-tables. Suggested-by: Linus Torvalds Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/Kconfig | 2 +- arch/x86/hyperv/mmu.c | 2 ++ arch/x86/include/asm/paravirt.h | 5 +++++ arch/x86/include/asm/paravirt_types.h | 3 +++ arch/x86/include/asm/tlbflush.h | 3 +++ arch/x86/kernel/kvm.c | 5 ++++- arch/x86/kernel/paravirt.c | 2 ++ arch/x86/mm/pgtable.c | 8 ++++---- arch/x86/xen/mmu_pv.c | 1 + 9 files changed, 25 insertions(+), 6 deletions(-) --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -179,7 +179,7 @@ config X86 select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP - select HAVE_RCU_TABLE_FREE + select HAVE_RCU_TABLE_FREE if PARAVIRT select HAVE_RCU_TABLE_INVALIDATE if HAVE_RCU_TABLE_FREE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION --- a/arch/x86/hyperv/mmu.c +++ b/arch/x86/hyperv/mmu.c @@ -9,6 +9,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -231,4 +232,5 @@ void hyperv_setup_mmu_ops(void) pr_info("Using hypercall for remote TLB flush\n"); pv_mmu_ops.flush_tlb_others = hyperv_flush_tlb_others; + pv_mmu_ops.tlb_remove_table = tlb_remove_table; } --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -309,6 +309,11 @@ static inline void flush_tlb_others(cons PVOP_VCALL2(pv_mmu_ops.flush_tlb_others, cpumask, info); } +static inline void paravirt_tlb_remove_table(struct mmu_gather *tlb, void *table) +{ + PVOP_VCALL2(pv_mmu_ops.tlb_remove_table, tlb, table); +} + static inline int paravirt_pgd_alloc(struct mm_struct *mm) { return PVOP_CALL1(int, pv_mmu_ops.pgd_alloc, mm); --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h @@ -54,6 +54,7 @@ struct desc_struct; struct task_struct; struct cpumask; struct flush_tlb_info; +struct mmu_gather; /* * Wrapper type for pointers to code which uses the non-standard @@ -222,6 +223,8 @@ struct pv_mmu_ops { void (*flush_tlb_others)(const struct cpumask *cpus, const struct flush_tlb_info *info); + void (*tlb_remove_table)(struct mmu_gather *tlb, void *table); + /* Hooks for allocating and freeing a pagetable top-level */ int (*pgd_alloc)(struct mm_struct *mm); void (*pgd_free)(struct mm_struct *mm, pgd_t *pgd); --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -552,6 +552,9 @@ extern void arch_tlbbatch_flush(struct a #ifndef CONFIG_PARAVIRT #define flush_tlb_others(mask, info) \ native_flush_tlb_others(mask, info) + +#define paravirt_tlb_remove_table(tlb, page) \ + tlb_remove_page(tlb, (void *)(page)) #endif #endif /* _ASM_X86_TLBFLUSH_H */ --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -45,6 +45,7 @@ #include #include #include +#include static int kvmapf = 1; @@ -636,8 +637,10 @@ static void __init kvm_guest_init(void) if (kvm_para_has_feature(KVM_FEATURE_PV_TLB_FLUSH) && !kvm_para_has_hint(KVM_HINTS_REALTIME) && - kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) + kvm_para_has_feature(KVM_FEATURE_STEAL_TIME)) { pv_mmu_ops.flush_tlb_others = kvm_flush_tlb_others; + pv_mmu_ops.tlb_remove_table = tlb_remove_table; + } if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) apic_set_eoi_write(kvm_guest_apic_eoi_write); --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -41,6 +41,7 @@ #include #include #include +#include /* * nop stub, which must not clobber anything *including the stack* to @@ -409,6 +410,7 @@ struct pv_mmu_ops pv_mmu_ops __ro_after_ .flush_tlb_kernel = native_flush_tlb_global, .flush_tlb_one_user = native_flush_tlb_one_user, .flush_tlb_others = native_flush_tlb_others, + .tlb_remove_table = (void (*)(struct mmu_gather *, void *))tlb_remove_page, .pgd_alloc = __paravirt_pgd_alloc, .pgd_free = paravirt_nop, --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -63,7 +63,7 @@ void ___pte_free_tlb(struct mmu_gather * { pgtable_page_dtor(pte); paravirt_release_pte(page_to_pfn(pte)); - tlb_remove_table(tlb, pte); + paravirt_tlb_remove_table(tlb, pte); } #if CONFIG_PGTABLE_LEVELS > 2 @@ -79,21 +79,21 @@ void ___pmd_free_tlb(struct mmu_gather * tlb->need_flush_all = 1; #endif pgtable_pmd_page_dtor(page); - tlb_remove_table(tlb, page); + paravirt_tlb_remove_table(tlb, page); } #if CONFIG_PGTABLE_LEVELS > 3 void ___pud_free_tlb(struct mmu_gather *tlb, pud_t *pud) { paravirt_release_pud(__pa(pud) >> PAGE_SHIFT); - tlb_remove_table(tlb, virt_to_page(pud)); + paravirt_tlb_remove_table(tlb, virt_to_page(pud)); } #if CONFIG_PGTABLE_LEVELS > 4 void ___p4d_free_tlb(struct mmu_gather *tlb, p4d_t *p4d) { paravirt_release_p4d(__pa(p4d) >> PAGE_SHIFT); - tlb_remove_table(tlb, virt_to_page(p4d)); + paravirt_tlb_remove_table(tlb, virt_to_page(p4d)); } #endif /* CONFIG_PGTABLE_LEVELS > 4 */ #endif /* CONFIG_PGTABLE_LEVELS > 3 */ --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -2397,6 +2397,7 @@ static const struct pv_mmu_ops xen_mmu_o .flush_tlb_kernel = xen_flush_tlb, .flush_tlb_one_user = xen_flush_tlb_one_user, .flush_tlb_others = xen_flush_tlb_others, + .tlb_remove_table = tlb_remove_table, .pgd_alloc = xen_pgd_alloc, .pgd_free = xen_pgd_free,