From patchwork Thu Aug 30 16:15:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 145546 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp92015ljw; Thu, 30 Aug 2018 09:16:21 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbSu6vKtzoT9Mt40t6xp7Za/n/SGY2O2GCwZCJbZl8ccAjMwNNuHlF/9mm845Cq2CqHe13J X-Received: by 2002:a17:902:543:: with SMTP id 61-v6mr11032481plf.126.1535645781619; Thu, 30 Aug 2018 09:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535645781; cv=none; d=google.com; s=arc-20160816; b=aJO3raRo5oiS9kI1F5e8vidIVkODaIiM2InK17VB3f45TctZAjHcnr7jV+1iQuCGmP 8O8nw32tJvMOnj/fHIaf+Qfrrde4gQ4EMkau43sre3lAvRs3I3qIpRIsnrAkrDJC87ki rArChjWq/aWacAW4Tvbvqij2jSRCQIOlOLgGlaKOCbeuBBFE8XQ5op++koEzHTaIpjUM io/S70YqMlbhnRbDeqCpC7Kh0EagTq6OTHre/SI9xQybHSJuSg4toOK0vvWBvAL22o9I kHuWkmlFMCQF3jDvVhRkXKDkskeUtU6Lr4x3Z4yVnB/z7xlzZI+0BdoOdsuZeA9te8KB 7LSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ZfSEMpqkcRgvHnIpNQ31wW5KrAeyJCKYVUYCkLULD94=; b=Uvtj/AOXnmS9M1mJ8TA3JLVNzr/ULJa3dJbdw5kIWp86zT/6fNgNvLmUCLg4SF5wpK tcAkRh6uz3mfYj3wicb0+6aufd+tisBwRqhsIDspgCnp26Mz5XfkaZZjhfPQqpWqc3pS moZubF1qthctwkeFhdReKrGLcjT882ePIP2DAFdFEzebH6Rdcxgm/fWzD/uYX+M0dsHg wUJ2N86/c81t7DFlXeeR3jy/uBKQU6SfcDGiQyTqmrGUGk+bsN55cTAlgQ7/T9nWHh03 Nnz2Oqhem0hOqOUSTNWeTL/bqfv9d73BxiDiXdbGCeETMJT3VGQWZ/No0O13a4nGySEk 8oRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si7273901pgh.307.2018.08.30.09.16.20; Thu, 30 Aug 2018 09:16:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbeH3UTL (ORCPT + 32 others); Thu, 30 Aug 2018 16:19:11 -0400 Received: from foss.arm.com ([217.140.101.70]:44870 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbeH3USm (ORCPT ); Thu, 30 Aug 2018 16:18:42 -0400 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 055231AED; Thu, 30 Aug 2018 09:15:50 -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 CB7B83F819; Thu, 30 Aug 2018 09:15:49 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 8DA801AE3A76; Thu, 30 Aug 2018 17:16:01 +0100 (BST) From: Will Deacon To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, benh@au1.ibm.com, torvalds@linux-foundation.org, npiggin@gmail.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, Will Deacon Subject: [PATCH 08/12] asm-generic/tlb: Track freeing of page-table directories in struct mmu_gather Date: Thu, 30 Aug 2018 17:15:42 +0100 Message-Id: <1535645747-9823-9-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1535645747-9823-1-git-send-email-will.deacon@arm.com> References: <1535645747-9823-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Peter Zijlstra Signed-off-by: Will Deacon --- include/asm-generic/tlb.h | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) -- 2.1.4 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