From patchwork Thu Sep 13 09:21:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 10599099 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 6A0B814E5 for ; Thu, 13 Sep 2018 09:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 595B52A457 for ; Thu, 13 Sep 2018 09:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DE9D2A475; Thu, 13 Sep 2018 09:29:45 +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 5D48D2A457 for ; Thu, 13 Sep 2018 09:29:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BBB58E0007; Thu, 13 Sep 2018 05:29:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 056688E000C; Thu, 13 Sep 2018 05:29:28 -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 CB6FA8E0007; Thu, 13 Sep 2018 05:29:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id 39F088E000A for ; Thu, 13 Sep 2018 05:29:28 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id j129-v6so3456541wmj.3 for ; Thu, 13 Sep 2018 02:29:28 -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=Qgx3kgv+AkSn1Y+HQ6cCIZsGaoQ/+n1Kc3v/8+oaveQ=; b=gSD20WxK89mOimGUWzfUxkYZrI4VgXCZUJTHmP/vlOrTGtUiw172AlmMSoTln6c2QU Jgi+WEqp9q3i31jypYn3j77e2IqyrMm5GDiX8ZCox1KVDKYLhXdB7yyigF553B1dGMj/ sNQIQhTqS8cSlCPcqdJd1/maUDrQsv9z3evJKtgdbMKKihN5MuijOSoOXq1bIKSpQNnj /Yb0sCQSdxO19sEdInKflfKeMW7oU2Gv93ndzdWtwCBTGrK9sqV2ogWtWCq0zPxCkGK4 4NkNgjPnNCVWEB6BDNPU+LkmKeJOEdLgdQ/0dz6xgz6kVX2ctiySbk+Bc1Y4beO7gekk EthQ== X-Gm-Message-State: APzg51DU1qY7jGhPuDk6LBesFK0S4GDoJcGq455QLu6jlG8U32QrLV+Y ojltgI3UacbwgVaEmlCDUKFinrwsN2QeTiD4G7/DJrk8iFPZzk86+W+vvRmfVyzyBKUOLZsvUY/ WnLqs7dH6C8u4z3FiB0f4izPf/LPhm/FTk7PNB5REUIcUC/lUSPlCZFPCtiBvsU16HQ== X-Received: by 2002:adf:bacf:: with SMTP id w15-v6mr4962365wrg.203.1536830967625; Thu, 13 Sep 2018 02:29:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbF0R1oA3wAPfhYq0IE6NeICMGLBt04W+gleg96Pwh6994z8pNKGpmbuSNeugpsL+YWWCUU X-Received: by 2002:adf:bacf:: with SMTP id w15-v6mr4962331wrg.203.1536830966972; Thu, 13 Sep 2018 02:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536830966; cv=none; d=google.com; s=arc-20160816; b=R598fj+rqo3fSR5+Sop22D8WUw9E4PsIfm3NkUsTlQYXTk6OqH2Vr3l5r4wY9Up1Yn aUALRtJZ/zZZNM7ipKnrbJtG1xZYdpBC3d/uIsK03UXbJAuLf+SnTMtajZmPYmwPY0ur JcQC8oz2fTVyS8qdl+Frnt1jN3IhiHNhXShu+9a2q6T0vmJL9Vrbv/kea5P2jjzPV5tP IS3BDSIAf1OzFesSTh/lyXhRCcg2rUe/Rks6AOjGEzgSFjp3kNSfNcoPq/7wUuPUYlyn BtxHjmcFYbaBsU9q6SXRp96Ve4J9HGW6AvTQXA/ugJ0YKS8eAsaS0g3seFr6A/5q0Rge 6Tgg== 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=Qgx3kgv+AkSn1Y+HQ6cCIZsGaoQ/+n1Kc3v/8+oaveQ=; b=m83bXEacqQA6waOPHWes8kO+ca0+W6R2yXXstfTUifPNoSIHPksFQMtrD24XBbd/M8 sjP03smghXBT1YDjblwRfNfftTBx/vYAb/XCcmZ8cg9IL8a1bchWIJLSqWKH2t1bZCHP rs2GN8Vcst5DY4DNUOLV8ipoG0KBGtnSy9Qk8f3iltTEX429fxeeZCAkaZ6mor47TAwS pM9kkD2CBwODbafnGLp/M4BAp1sewTlVHVyDEat1+0rKTodosyQPE7W6cIh+eXR3j6Zm MaNIEz9BtLl4ZewoT44EY5ssEDaYU8YFFLKUUdrT3rvTsAsmiDwRU4WcXwEG+f4dq05+ 9qsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=IlzD3+Z5; 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 t11-v6si3514516wre.25.2018.09.13.02.29.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Sep 2018 02:29:26 -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=IlzD3+Z5; 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=Qgx3kgv+AkSn1Y+HQ6cCIZsGaoQ/+n1Kc3v/8+oaveQ=; b=IlzD3+Z56pVL8cES+A72p3j82H gP4ymqf1BioBy99orpB/4pjbLrz0oOIoJXjjrqzSEcEi04pk9/XnotJu/2t+wekHOSwFvXR6c3JB1 u3t0gkOyJZSGc9GI77gKka2q3VGdcGymXuWzcxT0W2rmrjtmM+R/gl/h8wQEqnkyVcZ0jIoz/EV1q DO9kAUNnmu2pjMH7qzA2yVV+Kdt1tpm/dsdgmDSYlJAqCZHIk0jx88jIWkZ+uJsYtGk85xShV5a8L 4ZpAOCUIyfoBBe5PEsh9Ci3ASfkrAUzqtXBEt8ySmaLtm9iHQkmDL+zWzOPdrwZfVVDQhLvo11zpB uNfHtl/A==; 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 1g0Nw2-0000yq-63; Thu, 13 Sep 2018 09:29:14 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 5F9AB20587E67; Thu, 13 Sep 2018 11:29:10 +0200 (CEST) Message-ID: <20180913092812.436341429@infradead.org> User-Agent: quilt/0.65 Date: Thu, 13 Sep 2018 11:21:20 +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, Richard Weinberger Subject: [RFC][PATCH 10/11] um/tlb: Convert to generic mmu_gather References: <20180913092110.817204997@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 Generic mmu_gather provides the simple flush_tlb_range() based range tracking mmu_gather UM needs. Cc: Will Deacon Cc: "Aneesh Kumar K.V" Cc: Andrew Morton Cc: Nick Piggin Cc: Richard Weinberger Signed-off-by: Peter Zijlstra (Intel) --- arch/um/include/asm/tlb.h | 156 ---------------------------------------------- 1 file changed, 2 insertions(+), 154 deletions(-) --- a/arch/um/include/asm/tlb.h +++ b/arch/um/include/asm/tlb.h @@ -2,160 +2,8 @@ #ifndef __UM_TLB_H #define __UM_TLB_H -#include -#include -#include -#include #include - -#define tlb_start_vma(tlb, vma) do { } while (0) -#define tlb_end_vma(tlb, vma) do { } while (0) -#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) - -/* struct mmu_gather is an opaque type used by the mm code for passing around - * any data needed by arch specific code for tlb_remove_page. - */ -struct mmu_gather { - struct mm_struct *mm; - unsigned int need_flush; /* Really unmapped some ptes? */ - unsigned long start; - unsigned long end; - unsigned int fullmm; /* non-zero means full mm flush */ -}; - -static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, - unsigned long address) -{ - if (tlb->start > address) - tlb->start = address; - if (tlb->end < address + PAGE_SIZE) - tlb->end = address + PAGE_SIZE; -} - -static inline void init_tlb_gather(struct mmu_gather *tlb) -{ - tlb->need_flush = 0; - - tlb->start = TASK_SIZE; - tlb->end = 0; - - if (tlb->fullmm) { - tlb->start = 0; - tlb->end = TASK_SIZE; - } -} - -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)); - - init_tlb_gather(tlb); -} - -extern void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start, - unsigned long end); - -static inline void -tlb_flush_mmu_tlbonly(struct mmu_gather *tlb) -{ - flush_tlb_mm_range(tlb->mm, tlb->start, tlb->end); -} - -static inline void -tlb_flush_mmu_free(struct mmu_gather *tlb) -{ - init_tlb_gather(tlb); -} - -static inline void -tlb_flush_mmu(struct mmu_gather *tlb) -{ - if (!tlb->need_flush) - return; - - tlb_flush_mmu_tlbonly(tlb); - tlb_flush_mmu_free(tlb); -} - -/* arch_tlb_finish_mmu - * Called at the end of the shootdown operation to free up any resources - * that were required. - */ -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; - tlb->need_flush = 1; - } - tlb_flush_mmu(tlb); - - /* keep the page table cache within bounds */ - check_pgt_cache(); -} - -/* tlb_remove_page - * Must perform the equivalent to __free_pte(pte_get_and_clear(ptep)), - * while handling the additional races in SMP caused by other CPUs - * caching valid mappings in their TLBs. - */ -static inline int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) -{ - tlb->need_flush = 1; - 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) -{ - __tlb_remove_page(tlb, page); -} - -static inline bool __tlb_remove_page_size(struct mmu_gather *tlb, - struct page *page, int page_size) -{ - return __tlb_remove_page(tlb, page); -} - -static inline void tlb_remove_page_size(struct mmu_gather *tlb, - struct page *page, int page_size) -{ - return tlb_remove_page(tlb, page); -} - -/** - * tlb_remove_tlb_entry - remember a pte unmapping for later tlb invalidation. - * - * Record the fact that pte's were really umapped in ->need_flush, so we can - * later optimise away the tlb invalidate. This helps when userspace is - * unmapping already-unmapped pages, which happens quite a lot. - */ -#define tlb_remove_tlb_entry(tlb, ptep, address) \ - do { \ - tlb->need_flush = 1; \ - __tlb_remove_tlb_entry(tlb, ptep, address); \ - } 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) -{ -} - -#define pte_free_tlb(tlb, ptep, addr) __pte_free_tlb(tlb, ptep, addr) - -#define pud_free_tlb(tlb, pudp, addr) __pud_free_tlb(tlb, pudp, addr) - -#define pmd_free_tlb(tlb, pmdp, addr) __pmd_free_tlb(tlb, pmdp, addr) - -#define tlb_migrate_finish(mm) do {} while (0) +#include +#include #endif