From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A956C32788 for ; Thu, 11 Oct 2018 15:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2574D20841 for ; Thu, 11 Oct 2018 15:06:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Gkyt5Xi1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2574D20841 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728446AbeJKWeO (ORCPT ); Thu, 11 Oct 2018 18:34:14 -0400 Received: from merlin.infradead.org ([205.233.59.134]:51708 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbeJKWeM (ORCPT ); Thu, 11 Oct 2018 18:34:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9Qg+mRxSs68jZftvWXk66psSHf2issgdL/rZd+qWYjA=; b=Gkyt5Xi1ohxInU87YYXqWvscE /OkbqR60/o58Z7eIVKC84gheOf+pKMrS5IE7pmxXteyXhadQJCWUOYZ0u2pcbhSqa7pQXAMENfP3P lCGvBtN7JT9SF4cvbqQRdDMkJw6EW2+BRv2TgEu+REl0N+gWXRE80WI0moC9D3epMwO5koNzf9kUv xPAx7XE04+rwbUWFLlp5OZbqLBGPSbrgPCCRUqt6nbmSNMORICxJFPq8YdoRgroOx1QstAr4uu3vY pQgWQZ5FSOsq/ZlLqSNE1VmKTdK/94EZ6vBh7KRJbgTwH/1Zo7McXubNBajDQZGjzGnpRwZu35Llb carrkafcg==; 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 1gAcVV-0004Qf-3S; Thu, 11 Oct 2018 15:04:09 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id B5FDC20277343; Thu, 11 Oct 2018 17:04:06 +0200 (CEST) Date: Thu, 11 Oct 2018 17:04:06 +0200 From: Peter Zijlstra To: Vineet Gupta Cc: "will.deacon@arm.com" , "aneesh.kumar@linux.vnet.ibm.com" , "akpm@linux-foundation.org" , "npiggin@gmail.com" , "linux-arch@vger.kernel.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "linux@armlinux.org.uk" , "heiko.carstens@de.ibm.com" , "riel@surriel.com" , Richard Henderson , Mark Salter , Richard Kuo , Michal Simek , Paul Burton , Greentime Hu , Ley Foon Tan , Jonas Bonn , Helge Deller , "David S. Miller" , Guan Xuetao , Max Filippov Subject: Re: [PATCH 12/18] arch/tlb: Clean up simple architectures Message-ID: <20181011150406.GL9848@hirez.programming.kicks-ass.net> References: <20180926113623.863696043@infradead.org> <20180926114801.146189550@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 03, 2018 at 05:03:50PM +0000, Vineet Gupta wrote: > On 09/26/2018 04:56 AM, Peter Zijlstra wrote: > > There are generally two cases: > > > > 1) either the platform has an efficient flush_tlb_range() and > > asm-generic/tlb.h doesn't need any overrides at all. > > > > 2) or an architecture lacks an efficient flush_tlb_range() and > > we override tlb_end_vma() and tlb_flush(). > > > > Convert all 'simple' architectures to one of these two forms. > > > > --- a/arch/arc/include/asm/tlb.h > > +++ b/arch/arc/include/asm/tlb.h > > @@ -9,29 +9,6 @@ > > #ifndef _ASM_ARC_TLB_H > > #define _ASM_ARC_TLB_H > > > > -#define tlb_flush(tlb) \ > > -do { \ > > - if (tlb->fullmm) \ > > - flush_tlb_mm((tlb)->mm); \ > > -} while (0) > > - > > -/* > > - * This pair is called at time of munmap/exit to flush cache and TLB entries > > - * for mappings being torn down. > > - * 1) cache-flush part -implemented via tlb_start_vma( ) for VIPT aliasing D$ > > - * 2) tlb-flush part - implemted via tlb_end_vma( ) flushes the TLB range > > - * > > - * Note, read https://urldefense.proofpoint.com/v2/url?u=http-3A__lkml.org_lkml_2004_1_15_6&d=DwIBaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=c14YS-cH-kdhTOW89KozFhBtBJgs1zXscZojEZQ0THs&m=5jiyvgRek4SKK5DUWDBGufVcuLez5G-jJCh3K-ndHsg&s=7uAzzw_jdAXMfb07B-vGPh3V1vggbTAsB7xL6Kie47A&e= > > - */ > > - > > -#define tlb_end_vma(tlb, vma) \ > > -do { \ > > - if (!tlb->fullmm) \ > > - flush_tlb_range(vma, vma->vm_start, vma->vm_end); \ > > -} while (0) > > - > > -#define __tlb_remove_tlb_entry(tlb, ptep, address) > > - > > #include > > #include > > LGTM per discussion in an earlier thread. However given that for "simpler" arches > the whole series doesn't apply can you please beef up the changelog so I don't go > scratching my head 2 years down the line. It currently describes the hows of > things but not exactly whys: shift_arg_pages missing tlb_start_vma, > move_page_tables look dodgy, yady yadda ? Right you are. Thanks for pointing out the somewhat sparse Changelog; typically I end up kicking myself a few years down the line. I think I will in fact change the implementation a little and provide a symbol/Kconfig to switch the default implementation between flush_tlb_vma() and flush_tlb_mm(). That avoids some of the repetition. But see here a preview of the new Changelog, does that clarify things enough? --- Subject: arch/tlb: Clean up simple architectures From: Peter Zijlstra Date: Tue Sep 4 17:04:07 CEST 2018 The generic mmu_gather implementation is geared towards range tracking and provided the architecture provides a fairly efficient flush_tlb_range() implementation (or provides a custom tlb_flush() implementation) things will work well. The one case this doesn't cover well is where there is no (efficient) range invalidate at all. In this case we can select MMU_GATHER_NO_RANGE. So this reduces to two cases: 1) either the platform has an efficient flush_tlb_range() and asm-generic/tlb.h doesn't need any overrides at all. 2) or an architecture lacks an efficient flush_tlb_range() and we need to select MMU_GATHER_NO_RANGE. Convert all 'simple' architectures to one of these two forms. alpha: has no range invalidate -> 2 arc: already used flush_tlb_range() -> 1 c6x: has no range invalidate -> 2 hexagon: has an efficient flush_tlb_range() -> 1 (flush_tlb_mm() is in fact a full range invalidate, so no need to shoot down everything) m68k: has inefficient flush_tlb_range() -> 2 microblaze: has no flush_tlb_range() -> 2 mips: has efficient flush_tlb_range() -> 1 (even though it currently seems to use flush_tlb_mm()) nds32: already uses flush_tlb_range() -> 1 nios2: has inefficient flush_tlb_range() -> 2 (no limit on range iteration) openrisc: has inefficient flush_tlb_range() -> 2 (no limit on range iteration) parisc: already uses flush_tlb_range() -> 1 sparc32: already uses flush_tlb_range() -> 1 unicore32: has inefficient flush_tlb_range() -> 2 (no limit on range iteration) xtensa: has efficient flush_tlb_range() -> 1 Note this also fixes a bug in the existing code for a number platforms. Those platforms that did: tlb_end_vma() -> if (!fullmm) flush_tlb_*() tlb_flush -> if (full_mm) flush_tlb_mm() missed the case of shift_arg_pages(), which doesn't have @fullmm set, nor calls into tlb_*vma(), but still frees page-tables and thus needs an invalidate. The new code handles this by detecting a non-empty range, and either issuing the matching range invalidate or a full invalidate, depending on the capabilities. Cc: Nick Piggin Cc: "David S. Miller" Cc: Michal Simek Cc: Helge Deller Cc: Greentime Hu Cc: Richard Henderson Cc: Andrew Morton Cc: "Aneesh Kumar K.V" Cc: Will Deacon Cc: Ley Foon Tan Cc: Jonas Bonn Cc: Mark Salter Cc: Richard Kuo Cc: Paul Burton Cc: Max Filippov Cc: Guan Xuetao Signed-off-by: Peter Zijlstra (Intel)