Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1829364imm; Thu, 23 Aug 2018 09:24:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzkR1TWqlrAATh6UjRQ/LIuwSodoJyzDh1pyIhIYlcWzewuLuKRyRYmni2rVML+hU436tpT X-Received: by 2002:a63:610:: with SMTP id 16-v6mr24429997pgg.96.1535041472217; Thu, 23 Aug 2018 09:24:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535041472; cv=none; d=google.com; s=arc-20160816; b=E9Bu2QqcIo+Y1FrbNViSBy9BmSLnLebimMfn0h3qej+ZD8bzOMJ07HHnvzxLLH85IV NQC18sPMu25Or6fYVMJCgdjJt1v0oG5+1JesCS9Dtv1jkeNc5Fg1iFAqXtRPCKctM9vt uj8X+xDIKJWfH6B+x/mDo9JdZiubv6bvxyoAa/Szax85TpFz8TC4Io7ya+bVY2i4tY0e mPI//jcFTEBUUr2omi+meSNrmLnRJtMZ7xdTyz76Gl8NOjyvw7nRnHAzLLJxFAGbtsx4 M5RoXjBQBEHwZZlW9bpTYs9NiQ5XZdvLpyQMv6Hotsfk19M6iNwww7n5blCLJ+Lf9lIT 51BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=rivGJOolqPZjvDcQKmkxRx7LoIVa3k6UydRzNbwYDSA=; b=JAOqLXvg+3eFYU+APZ/2p2Ws3sXWpKNoJr0u7NYI0S+mg5looxBVEzXWnlUcInObI3 xqy7SjFBRhXAHJSz1g7wkPVh3CHpESzb81HD/6+vyC34w5IHC+nPl8fF/oONVaRSCMzI nt+cZ8DqZIHaoN9odFGj9pFLBdahuSINT2Kcrr9QCjPnBeHAfyAAd8QHLOgSJObxe4RH gdjUK3tYv196zwdRpHFfbr+JraJmHKdMwNGC81yVkMID8B20mClwiSaFjYPGubk2jMoT Nc982VUAV7CP7qvIZIEJ7xF8wUD3VNtdWmy5kXkVBl9Il2tMSF4nYpvEnUVd9ERoasE5 ow2w== 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 74-v6si3312484pfz.160.2018.08.23.09.24.17; Thu, 23 Aug 2018 09:24:32 -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 S1731281AbeHWRJu (ORCPT + 99 others); Thu, 23 Aug 2018 13:09:50 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46548 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730963AbeHWRJu (ORCPT ); Thu, 23 Aug 2018 13:09:50 -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 D17C0ED1; Thu, 23 Aug 2018 06:40:04 -0700 (PDT) Received: from brain-police (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6C24A3F675; Thu, 23 Aug 2018 06:40:03 -0700 (PDT) Date: Thu, 23 Aug 2018 14:39:59 +0100 From: Will Deacon To: Linus Torvalds Cc: Benjamin Herrenschmidt , Nick Piggin , Peter Zijlstra , Andrew Lutomirski , the arch/x86 maintainers , Borislav Petkov , Rik van Riel , Jann Horn , Adin Scannell , Dave Hansen , Linux Kernel Mailing List , linux-mm , David Miller , Martin Schwidefsky , Michael Ellerman Subject: Re: [PATCH 3/4] mm/tlb, x86/mm: Support invalidating TLB caches for RCU_TABLE_FREE Message-ID: <20180823133958.GA1496@brain-police> References: <20180822153012.173508681@infradead.org> <20180822154046.823850812@infradead.org> <20180822155527.GF24124@hirez.programming.kicks-ass.net> <20180823134525.5f12b0d3@roar.ozlabs.ibm.com> <776104d4c8e4fc680004d69e3a4c2594b638b6d1.camel@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 22, 2018 at 10:11:41PM -0700, Linus Torvalds wrote: > On Wed, Aug 22, 2018 at 9:54 PM Benjamin Herrenschmidt wrote: > > > > > > So we do need a different flush instruction for the page tables vs. the > > normal TLB pages. > > Right. ARM wants it too. x86 is odd in that a regular "invlpg" already > invalidates all the internal tlb cache nodes. > > So the "new world order" is exactly that patch that PeterZ sent you, that adds a > > + unsigned int freed_tables : 1; > > to the 'struct mmu_gather', and then makes all those > pte/pmd/pud/p4d_free_tlb() functions set that bit. > > So I'm referring to the email PeterZ sent you in this thread that said: > > Nick, Will is already looking at using this to remove the synchronous > invalidation from __p*_free_tlb() for ARM, could you have a look to see > if PowerPC-radix could benefit from that too? > > Basically, using a patch like the below, would give your tlb_flush() > information on if tables were removed or not. > > then, in that model, you do *not* need to override these > pte/pmd/pud/p4d_free_tlb() macros at all (well, you *can* if you want > to, for doing games with the range modification, but let's sayt that > you don't need that right now). > > So instead, when you get to the actual "tlb_flush(tlb)", you do > exactly that - flush the tlb. And the mmu_gather structure shows you > how much you need to flush. If you see that "freed_tables" is set, > then you know that you need to also do the special instruction to > flush the inner level caches. The range continues to show the page > range. The only problem with this approach is that we've lost track of the granule size by the point we get to the tlb_flush(), so we can't adjust the stride of the TLB invalidations for huge mappings, which actually works nicely in the synchronous case (e.g. we perform a single invalidation for a 2MB mapping, rather than iterating over it at a 4k granule). One thing we could do is switch to synchronous mode if we detect a change in granule (i.e. treat it like a batch failure). Will