From patchwork Tue Sep 4 11:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 10587203 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 BEDCA14E0 for ; Tue, 4 Sep 2018 11:45:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A83BA29261 for ; Tue, 4 Sep 2018 11:45:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C9982926A; Tue, 4 Sep 2018 11:45:31 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE 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 22C2029261 for ; Tue, 4 Sep 2018 11:45:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A6766B6D51; Tue, 4 Sep 2018 07:45:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2CEE76B6D55; Tue, 4 Sep 2018 07:45:22 -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 085A66B6D51; Tue, 4 Sep 2018 07:45:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id A36FF6B6D52 for ; Tue, 4 Sep 2018 07:45:21 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id w194-v6so3828711oiw.5 for ; Tue, 04 Sep 2018 04:45:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=E3dL0F6LtXoWeiJ3fMJnIB2P7vgcB2aMq324R5er1Gk=; b=HKhGzID6DWKmsgliwkVHkCOMM2rV9wNKuACyZhRsYNXkBMmbG09UtWKKwXd5IRpV+x qxv7VFR7ajBBKaBGTcOffbZgoL/oFrulQDpfUvVVD8kWNPlZ66sd4FDK9i+iTP242gmW +9BRligUMMFUYo4Or4ZJ5VdsbA13OzeldIg5GhWZ0OPt07aesg9Jae0zQIao/XATb2Fr mAM8YmsJk89JPyEZ4veRAzyk31yrb4DXyVdIDUsn2ayUnyHyZ5D/PKp8DsC+sRVq2rHs F0PAUbKPLRE1s0U9FT+Idcd47CxmLBMDHVi9qkHLv5a2Ki42H64mb19BfC7z1iuxatFh 1JiA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of will.deacon@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=will.deacon@arm.com X-Gm-Message-State: APzg51AxFHNs3ji6fSlnnsY+NjGYXDmfxrTo8Mcs2Oc7E6mbKCx1BaQY OYMIEIeyjPI313h2maZVp737VKmDjA7LNEduIdgceVxzFDtmRzsdfsn4BzKB+reMYiLC0dKnfff PclFCrrmBgjzWniE3ZxczTxNdUYhTl34pxi71j2ZHsMRsj8xJPg9C0hvOfh19TRFVOA== X-Received: by 2002:aca:401:: with SMTP id 1-v6mr22419992oie.28.1536061521210; Tue, 04 Sep 2018 04:45:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbZO9YnwsU4jx25iMeZNjsN1t/0VQFv8L2QgSXWBEK1nmeHx2vrf4O4BVyZchjyQbH6H9Ju X-Received: by 2002:aca:401:: with SMTP id 1-v6mr22419927oie.28.1536061520415; Tue, 04 Sep 2018 04:45:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536061520; cv=none; d=google.com; s=arc-20160816; b=It2lYKfUg7rwb2RHmws4d4ASF1EWoAoiaJPwH2+/eX9MdUH5ks12Ry65VOmskwI00q 3na6jBxdI/tS59A+jbI6PIMPicJzIS5Za1UT6721+ZU5pbxMp/taaW1PAu2gt7p8IF2V RzcvazZYxpdDLCdVxF9M5xusgHfWPUEWDeF9Qi3Au3SZ34uCfF+KsGnwytT+ZekeEsb5 UtfG3MUfd5YYdzIWHs7MuFZ17yOeaAtPPuSFRE8wRnyhc+CjcqPrvgEfZPvVYJNhwIKM p4ZvbNV1kRsHtRDJf83WynXo8e5VztfnnXielRIuoIDSzG1trW2jDEwaNC5lfaXQLUam 6b+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=E3dL0F6LtXoWeiJ3fMJnIB2P7vgcB2aMq324R5er1Gk=; b=iZ4NBdSolu3WRoDBQkubxV2fudzd910V2Mw3rKsKHuk7CnhE7M0Vlk1gsXrcF+BwCc Dy50ew9u7aXgP1SE0AkS1zE4jCb9VBeZeiyT0AYSKaElaVln2mgCsOfizAlBNjDZqDhR mS6tAifLpY78P0oc+8kaAlNisKCFUQyHcz4P55INw+PxNjifdFxj6tPRV40trLffSO1Y 90uvGLW0oIiGuMyAo8cmMNmXKyT7GqLsQWNUC0pMcYq7pkLQcYTz1xwOjLR2P6kEa2VF /xqNTGgp8E4ypjL63P9pavRnTcZSvyx25yrRZjaQWaoBZ867dlI4gO9/GZtybQaiLqNj cfoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of will.deacon@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=will.deacon@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id k73-v6si14211436oib.416.2018.09.04.04.45.20 for ; Tue, 04 Sep 2018 04:45:20 -0700 (PDT) Received-SPF: pass (google.com: domain of will.deacon@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of will.deacon@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=will.deacon@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C165515AD; Tue, 4 Sep 2018 04:45:19 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 927423F763; Tue, 4 Sep 2018 04:45:19 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 97A6D1AE358D; Tue, 4 Sep 2018 12:45:33 +0100 (BST) From: Will Deacon To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, npiggin@gmail.com, linux-mm@kvack.org, kirill.shutemov@linux.intel.com, akpm@linux-foundation.org, mhocko@suse.com, aneesh.kumar@linux.vnet.ibm.com Subject: [PATCH v2 2/5] asm-generic/tlb: Track freeing of page-table directories in struct mmu_gather Date: Tue, 4 Sep 2018 12:45:30 +0100 Message-Id: <1536061533-16188-3-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1536061533-16188-1-git-send-email-will.deacon@arm.com> References: <1536061533-16188-1-git-send-email-will.deacon@arm.com> 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 From: Peter Zijlstra Some architectures require different TLB invalidation instructions depending on whether it is only the last-level of page table being changed, or whether there are also changes to the intermediate (directory) entries higher up the tree. Add a new bit to the flags bitfield in struct mmu_gather so that the architecture code can operate accordingly if it's the intermediate levels being invalidated. Acked-by: Nicholas Piggin Signed-off-by: Peter Zijlstra Signed-off-by: Will Deacon --- include/asm-generic/tlb.h | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index a25e236f7a7f..2b444ad94566 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -99,12 +99,22 @@ struct mmu_gather { #endif unsigned long start; unsigned long end; - /* we are in the middle of an operation to clear - * a full mm and can make some optimizations */ - unsigned int fullmm : 1, - /* we have performed an operation which - * requires a complete flush of the tlb */ - need_flush_all : 1; + /* + * we are in the middle of an operation to clear + * a full mm and can make some optimizations + */ + unsigned int fullmm : 1; + + /* + * we have performed an operation which + * requires a complete flush of the tlb + */ + unsigned int need_flush_all : 1; + + /* + * we have removed page directories + */ + unsigned int freed_tables : 1; struct mmu_gather_batch *active; struct mmu_gather_batch local; @@ -139,6 +149,7 @@ static inline void __tlb_reset_range(struct mmu_gather *tlb) tlb->start = TASK_SIZE; tlb->end = 0; } + tlb->freed_tables = 0; } static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) @@ -280,6 +291,7 @@ static inline void tlb_remove_check_page_size_change(struct mmu_gather *tlb, #define pte_free_tlb(tlb, ptep, address) \ do { \ __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb->freed_tables = 1; \ __pte_free_tlb(tlb, ptep, address); \ } while (0) #endif @@ -287,7 +299,8 @@ static inline void tlb_remove_check_page_size_change(struct mmu_gather *tlb, #ifndef pmd_free_tlb #define pmd_free_tlb(tlb, pmdp, address) \ do { \ - __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb->freed_tables = 1; \ __pmd_free_tlb(tlb, pmdp, address); \ } while (0) #endif @@ -297,6 +310,7 @@ static inline void tlb_remove_check_page_size_change(struct mmu_gather *tlb, #define pud_free_tlb(tlb, pudp, address) \ do { \ __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb->freed_tables = 1; \ __pud_free_tlb(tlb, pudp, address); \ } while (0) #endif @@ -306,7 +320,8 @@ static inline void tlb_remove_check_page_size_change(struct mmu_gather *tlb, #ifndef p4d_free_tlb #define p4d_free_tlb(tlb, pudp, address) \ do { \ - __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + __tlb_adjust_range(tlb, address, PAGE_SIZE); \ + tlb->freed_tables = 1; \ __p4d_free_tlb(tlb, pudp, address); \ } while (0) #endif