From patchwork Wed Sep 26 11:36:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 10615793 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 8099214BD for ; Wed, 26 Sep 2018 11:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7100D2A97C for ; Wed, 26 Sep 2018 11:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 634982A9CC; Wed, 26 Sep 2018 11:55:01 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 9F8102A97C for ; Wed, 26 Sep 2018 11:54:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DDA48E000A; Wed, 26 Sep 2018 07:54:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 68DB78E0003; Wed, 26 Sep 2018 07:54:56 -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 531B28E000A; Wed, 26 Sep 2018 07:54:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 0ABD78E0003 for ; Wed, 26 Sep 2018 07:54:56 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id w18-v6so10684780plp.3 for ; Wed, 26 Sep 2018 04:54:56 -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=+pldmGqd3JjO/U8GcilPsAczLWXeONB6ja/7zhAvKSU=; b=gB+sjy9IFO5IPCLHUiBmXXV/UrFojLlpLZt36lHfeFIEt7m1kF5hk6SqJem4rApnvT 8c1O/O24/UcKf0W/inMh97TLsdYF+SHp2bJg00fvu9vQP0i/uwOozbqc8Fn/MSlWigLF 4iEFNpdFkKIIn6WzeJ71dtCcD5Ro9sApZ228U2P150SBsu5xUakBq1o1CxaSvQVgDJcA lrHHoXmIoKnLWumwk6VUzuCS7IRosJ7QetUUFG4bwrD3AiclAIy28x46N5GU4qyXMH04 NY1Lm5xJJ8IOWAZoZ7ADXq7NxsnsleXO7m3k4jDsYPVeA7oamhNbb+Kp4FRqie9H45hl BP0w== X-Gm-Message-State: ABuFfojcowy5+0T1AQGmsEyiLLP+9ptE3Icx0n891CawAtOlSus78YvT IuC7VAtBwZ8Rfwbb2Q1gP4KlPGzvzKFaNLYybpELyuyfa94iyj3QmERIpKV8qXsbgMNkoHkLkT7 0AIvLa0qARUQt9gvdTOgRn/3jNfsqkriZQUN2TAAMKnF/xKBBC/7Qaq0kWHfiNPbX+g== X-Received: by 2002:a17:902:b212:: with SMTP id t18-v6mr5896869plr.136.1537962895691; Wed, 26 Sep 2018 04:54:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV63iDinbexaRQqElvZGDCZNP2s97B9PINUMf6rUsoPingCi+ZK8+/ijLlSSWtJR5DPbgkB/x X-Received: by 2002:a17:902:b212:: with SMTP id t18-v6mr5896786plr.136.1537962894554; Wed, 26 Sep 2018 04:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537962894; cv=none; d=google.com; s=arc-20160816; b=yeTvNpyW/SX2H//wmFXo39gWfzOwAxqw3zjYZhRqoyDVQb/JdA8kAbb4ln2FIwcfP6 28WfoVp61yzNx2cMafCZeK78F54Ued7zlTBPKrl/97QWydNAupdt/BprdyJxXsIxekXX DjjgHtYnjZ4jh+vDTbCz8Ql/I3xmC0XvhZtkhXQap/CwHNzgnmma2MKPUh5snHfuLtIG BHsUdkCmPPDZmQF2w7jZGCiSU9yX0YgNs2MX61cZ6PuDf/xbsrhEeJfflPQWbFqrPxzK naJ5x5VXI0906ScS+eLwld1cbSVptLVp7C1Ur68SmDTZoiR7/C/JfXll+Zy4L7QBEHib V6xQ== 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; bh=+pldmGqd3JjO/U8GcilPsAczLWXeONB6ja/7zhAvKSU=; b=UbXWmPPJtVplNMGDh4fLSRU3lA8bAbKQa/tR/ph1ARwv83uP5zFFkakHdURPLC9SzD 2fTdgUQzKN8D9+kn40gxriQyKu0IsPO27MaysrRFWxCkK1gMxHqEEZr1xvMBDdYdjiZV /+I2buTE3nExhL/iKtkvzavn6QyK0S37OwTOMBAukv6hAVmvBpPJYCtHaLViQTGwcj19 JdsBMIaxQzZKIU7jx5ivnIoj7UIIF+GowTSpqA9lCA0Bwqip09SIbylngukGksq+2yFT tPlXrpBIU0pzDU5baYYFp366yDCRskgLv7TagFHzvCUbnURJyy22Ey2ZeCdLYk5XUS5P YsDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Y2DnjqfM; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=peterz@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q61-v6si5116763plb.231.2018.09.26.04.54.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 04:54:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of peterz@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Y2DnjqfM; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 2607:7c80:54:e::133 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=bombadil.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=+pldmGqd3JjO/U8GcilPsAczLWXeONB6ja/7zhAvKSU=; b=Y2DnjqfMTbp9shgseYYmzfFKUc JOxDUcVKeeDmUkBtPNcNEOp5ex2rzz1BhXLBNgjbZPc4DKoQEqY1itSR8a8JmCrnG6SSrj/ImAjYM jdSHDN9zx9tBQEJC0fzexTubhryRSoUHg/tuu+STAipkqbh9Wk4xQckyXhbFzyGpmgwL+A9xSypZx peqZxaWhMXuycKSnEFp84/MEhexrd1lQT88tkqETKrOgJhCAG+SO4ve7Z+rRTWGx7qbMbY6XJ1bvS Fx3rkA4Cy5oebDhYzMk6/1gvSSRdwxvS/XVR6k1On+8FBQbF51En9R8PLR73r31pzvshPPNxphkep 1R4+kamA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1g58Og-00062J-R9; Wed, 26 Sep 2018 11:54:42 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id AD924206F181E; Wed, 26 Sep 2018 13:54:04 +0200 (CEST) Message-ID: <20180926114801.260918352@infradead.org> User-Agent: quilt/0.65 Date: Wed, 26 Sep 2018 13:36:37 +0200 From: Peter Zijlstra To: will.deacon@arm.com, aneesh.kumar@linux.vnet.ibm.com, akpm@linux-foundation.org, npiggin@gmail.com Cc: linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, peterz@infradead.org, linux@armlinux.org.uk, heiko.carstens@de.ibm.com, riel@surriel.com, Linus Torvalds , Martin Schwidefsky Subject: [PATCH 14/18] s390/tlb: convert to generic mmu_gather References: <20180926113623.863696043@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 From: Martin Schwidefsky Cc: npiggin@gmail.com Cc: heiko.carstens@de.ibm.com Cc: will.deacon@arm.com Cc: aneesh.kumar@linux.vnet.ibm.com Cc: akpm@linux-foundation.org Cc: Linus Torvalds Cc: linux@armlinux.org.uk Signed-off-by: Martin Schwidefsky Signed-off-by: Peter Zijlstra (Intel) Link: http://lkml.kernel.org/r/20180918125151.31744-3-schwidefsky@de.ibm.com --- arch/s390/Kconfig | 2 arch/s390/include/asm/tlb.h | 128 +++++++++++++------------------------------- arch/s390/mm/pgalloc.c | 63 --------------------- 3 files changed, 42 insertions(+), 151 deletions(-) --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -157,10 +157,12 @@ config S390 select HAVE_MEMBLOCK select HAVE_MEMBLOCK_NODE_MAP select HAVE_MEMBLOCK_PHYS_MAP + select HAVE_MMU_GATHER_NO_GATHER select HAVE_MOD_ARCH_SPECIFIC select HAVE_NOP_MCOUNT select HAVE_OPROFILE select HAVE_PERF_EVENTS + select HAVE_RCU_TABLE_FREE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RSEQ select HAVE_SYSCALL_TRACEPOINTS --- a/arch/s390/include/asm/tlb.h +++ b/arch/s390/include/asm/tlb.h @@ -22,98 +22,39 @@ * Pages used for the page tables is a different story. FIXME: more */ -#include -#include -#include -#include -#include -#include - -struct mmu_gather { - struct mm_struct *mm; - struct mmu_table_batch *batch; - unsigned int fullmm; - unsigned long start, end; -}; - -struct mmu_table_batch { - struct rcu_head rcu; - unsigned int nr; - void *tables[0]; -}; - -#define MAX_TABLE_BATCH \ - ((PAGE_SIZE - sizeof(struct mmu_table_batch)) / sizeof(void *)) - -extern void tlb_table_flush(struct mmu_gather *tlb); -extern void tlb_remove_table(struct mmu_gather *tlb, void *table); - -static inline void -arch_tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, - unsigned long start, unsigned long end) -{ - tlb->mm = mm; - tlb->start = start; - tlb->end = end; - tlb->fullmm = !(start | (end+1)); - tlb->batch = NULL; -} - -static inline void tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) -{ - __tlb_flush_mm_lazy(tlb->mm); -} - -static inline void tlb_flush_mmu_free(struct mmu_gather *tlb) -{ - tlb_table_flush(tlb); -} - +void __tlb_remove_table(void *_table); +static inline void tlb_flush(struct mmu_gather *tlb); +static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, + struct page *page, int page_size); -static inline void tlb_flush_mmu(struct mmu_gather *tlb) -{ - tlb_flush_mmu_tlbonly(tlb); - tlb_flush_mmu_free(tlb); -} +#define tlb_start_vma(tlb, vma) do { } while (0) +#define tlb_end_vma(tlb, vma) do { } while (0) -static inline void -arch_tlb_finish_mmu(struct mmu_gather *tlb, - unsigned long start, unsigned long end, bool force) -{ - if (force) { - tlb->start = start; - tlb->end = end; - } +#define tlb_flush tlb_flush +#define pte_free_tlb pte_free_tlb +#define pmd_free_tlb pmd_free_tlb +#define p4d_free_tlb p4d_free_tlb +#define pud_free_tlb pud_free_tlb - tlb_flush_mmu(tlb); -} +#include +#include +#include /* * Release the page cache reference for a pte removed by * tlb_ptep_clear_flush. In both flush modes the tlb for a page cache page * has already been freed, so just do free_page_and_swap_cache. */ -static inline bool __tlb_remove_page(struct mmu_gather *tlb, struct page *page) -{ - free_page_and_swap_cache(page); - return false; /* avoid calling tlb_flush_mmu */ -} - -static inline void tlb_remove_page(struct mmu_gather *tlb, struct page *page) -{ - free_page_and_swap_cache(page); -} - static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, struct page *page, int page_size) { - return __tlb_remove_page(tlb, page); + free_page_and_swap_cache(page); + return false; } -static inline void tlb_remove_page_size(struct mmu_gather *tlb, - struct page *page, int page_size) +static inline void tlb_flush(struct mmu_gather *tlb) { - return tlb_remove_page(tlb, page); + __tlb_flush_mm_lazy(tlb->mm); } /* @@ -121,8 +62,17 @@ static inline void tlb_remove_page_size( * page table from the tlb. */ static inline void pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, - unsigned long address) + unsigned long address) { + __tlb_adjust_range(tlb, address, PAGE_SIZE); + tlb->mm->context.flush_mm = 1; + tlb->freed_tables = 1; + tlb->cleared_ptes = 1; + /* + * page_table_free_rcu takes care of the allocation bit masks + * of the 2K table fragments in the 4K page table page, + * then calls tlb_remove_table. + */ page_table_free_rcu(tlb, (unsigned long *) pte, address); } @@ -139,6 +89,10 @@ static inline void pmd_free_tlb(struct m if (tlb->mm->context.asce_limit <= _REGION3_SIZE) return; pgtable_pmd_page_dtor(virt_to_page(pmd)); + __tlb_adjust_range(tlb, address, PAGE_SIZE); + tlb->mm->context.flush_mm = 1; + tlb->freed_tables = 1; + tlb->cleared_puds = 1; tlb_remove_table(tlb, pmd); } @@ -154,6 +108,10 @@ static inline void p4d_free_tlb(struct m { if (tlb->mm->context.asce_limit <= _REGION1_SIZE) return; + __tlb_adjust_range(tlb, address, PAGE_SIZE); + tlb->mm->context.flush_mm = 1; + tlb->freed_tables = 1; + tlb->cleared_p4ds = 1; tlb_remove_table(tlb, p4d); } @@ -169,19 +127,11 @@ static inline void pud_free_tlb(struct m { if (tlb->mm->context.asce_limit <= _REGION2_SIZE) return; + tlb->mm->context.flush_mm = 1; + tlb->freed_tables = 1; + tlb->cleared_puds = 1; tlb_remove_table(tlb, pud); } -#define tlb_start_vma(tlb, vma) do { } while (0) -#define tlb_end_vma(tlb, vma) do { } while (0) -#define tlb_remove_tlb_entry(tlb, ptep, addr) do { } while (0) -#define tlb_remove_pmd_tlb_entry(tlb, pmdp, addr) do { } while (0) -#define tlb_migrate_finish(mm) do { } while (0) -#define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ - tlb_remove_tlb_entry(tlb, ptep, address) - -static inline void tlb_change_page_size(struct mmu_gather *tlb, unsigned int page_size) -{ -} #endif /* _S390_TLB_H */ --- a/arch/s390/mm/pgalloc.c +++ b/arch/s390/mm/pgalloc.c @@ -288,7 +288,7 @@ void page_table_free_rcu(struct mmu_gath tlb_remove_table(tlb, table); } -static void __tlb_remove_table(void *_table) +void __tlb_remove_table(void *_table) { unsigned int mask = (unsigned long) _table & 3; void *table = (void *)((unsigned long) _table ^ mask); @@ -314,67 +314,6 @@ static void __tlb_remove_table(void *_ta } } -static void tlb_remove_table_smp_sync(void *arg) -{ - /* Simply deliver the interrupt */ -} - -static void tlb_remove_table_one(void *table) -{ - /* - * This isn't an RCU grace period and hence the page-tables cannot be - * assumed to be actually RCU-freed. - * - * It is however sufficient for software page-table walkers that rely - * on IRQ disabling. See the comment near struct mmu_table_batch. - */ - smp_call_function(tlb_remove_table_smp_sync, NULL, 1); - __tlb_remove_table(table); -} - -static void tlb_remove_table_rcu(struct rcu_head *head) -{ - struct mmu_table_batch *batch; - int i; - - batch = container_of(head, struct mmu_table_batch, rcu); - - for (i = 0; i < batch->nr; i++) - __tlb_remove_table(batch->tables[i]); - - free_page((unsigned long)batch); -} - -void tlb_table_flush(struct mmu_gather *tlb) -{ - struct mmu_table_batch **batch = &tlb->batch; - - if (*batch) { - call_rcu_sched(&(*batch)->rcu, tlb_remove_table_rcu); - *batch = NULL; - } -} - -void tlb_remove_table(struct mmu_gather *tlb, void *table) -{ - struct mmu_table_batch **batch = &tlb->batch; - - tlb->mm->context.flush_mm = 1; - if (*batch == NULL) { - *batch = (struct mmu_table_batch *) - __get_free_page(GFP_NOWAIT | __GFP_NOWARN); - if (*batch == NULL) { - __tlb_flush_mm_lazy(tlb->mm); - tlb_remove_table_one(table); - return; - } - (*batch)->nr = 0; - } - (*batch)->tables[(*batch)->nr++] = table; - if ((*batch)->nr == MAX_TABLE_BATCH) - tlb_flush_mmu(tlb); -} - /* * Base infrastructure required to generate basic asces, region, segment, * and page tables that do not make use of enhanced features like EDAT1.