Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3002319imm; Fri, 24 Aug 2018 08:54:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZto5EN+IZiUJ61jXEdcCo+I7yqelbCfPyYGcYaIg4Ag2w8ZOTqlD344VyC2fX0YAxb5r8X X-Received: by 2002:a62:1219:: with SMTP id a25-v6mr2607170pfj.104.1535126050043; Fri, 24 Aug 2018 08:54:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535126050; cv=none; d=google.com; s=arc-20160816; b=FHupp/FnbW8J/QGDtyTjFtk6V4QcLdR5iH6wv0gnwFN2apii9gQ7inQz+NFBdTYYUf fbiSXuUHMk6/ox30Fe7sZdtXCd3Op14Q4ZU2gFCyGTEq8v/ALCf0qmUE6SiRgWYA7hmk Hiq1o1JmWo0PFuk8riBLaAPc3j1GoSeUvL94iAYoocG74d4E6625ix755IPxvT5235BL FJKBQxdhiQWal3c8gAi5d7v+N4zhmk7RsFfIYq+B0KSS6XN5CobOE0ZzZY13ElG3Z5bn rbd2T7eg/lDw7f5vAGQ+ssaBbzvaDoRkrJiNF01a5/a8XvewWow16fsViJb5u3aXHyJE oRpg== 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=yCfibgqVcJKkMihTC97KVlbXJOk1cx2tlzA5BAYAvEc=; b=N1eIf6wr2LfBKXB/pSbkTp+OpMKlVW8sEGCgYugYinVZu6k4qGketyf7cHsUrBkBnh i0SowHFXTvDoSOIgKjcy4Oc1reurvfXAzhQJDhIlNEBWISKh4pnUDXpoMWRETGm8v0mn AnXe1DHYI8wPBUg3xJzRY4RrMVn4RoFmbBd1PUkao7FTr65xvv7gRXOS6wTFyzRAZu8q WkISy5K2FP8aalrryaXwFdPruF2TOst/NJU12EPerC4fLEhdgFKeYdsta7mf1plE2CTv kQdiFMzqRtQup1xP8dm+YOxKuDWOB6rmw6y+vLaMVsrvEmDQ6EHkBE8cmnJ9d2hfCbat FG5A== 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 n72-v6si8051093pfk.14.2018.08.24.08.53.54; Fri, 24 Aug 2018 08:54:10 -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 S1727880AbeHXT1z (ORCPT + 99 others); Fri, 24 Aug 2018 15:27:55 -0400 Received: from foss.arm.com ([217.140.101.70]:32882 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727592AbeHXT1w (ORCPT ); Fri, 24 Aug 2018 15:27:52 -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 D72BA19BF; Fri, 24 Aug 2018 08:52:38 -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 A97903F7F3; Fri, 24 Aug 2018 08:52:38 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 2C3291AE33B8; Fri, 24 Aug 2018 16:52:48 +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: [RFC PATCH 08/11] asm-generic/tlb: Track freeing of page-table directories in struct mmu_gather Date: Fri, 24 Aug 2018 16:52:43 +0100 Message-Id: <1535125966-7666-9-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1535125966-7666-1-git-send-email-will.deacon@arm.com> References: <1535125966-7666-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(-) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 859f897d3d53..a5caf90264e6 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 -- 2.1.4