From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752607AbdHBJCX (ORCPT ); Wed, 2 Aug 2017 05:02:23 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50402 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752139AbdHBJCV (ORCPT ); Wed, 2 Aug 2017 05:02:21 -0400 Date: Wed, 2 Aug 2017 10:02:21 +0100 From: Will Deacon To: Peter Zijlstra Cc: Benjamin Herrenschmidt , torvalds@linux-foundation.org, oleg@redhat.com, paulmck@linux.vnet.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, linux-kernel@vger.kernel.org, mingo@kernel.org, stern@rowland.harvard.edu, Mel Gorman , Rik van Riel Subject: Re: [RFC][PATCH 1/5] mm: Rework {set,clear,mm}_tlb_flush_pending() Message-ID: <20170802090220.GE15219@arm.com> References: <20170801121419.a365inyyk5hghb6w@hirez.programming.kicks-ass.net> <20170801163903.wuwrk6ysyd52dwxm@hirez.programming.kicks-ass.net> <20170801164414.GB12027@arm.com> <20170801164820.s46g2325kjjrymom@hirez.programming.kicks-ass.net> <20170801225912.c23e6xave7qy5kzt@hirez.programming.kicks-ass.net> <1501636992.2792.139.camel@kernel.crashing.org> <20170802081106.kdl4grcb6sicqa3v@hirez.programming.kicks-ass.net> <20170802081523.GB15219@arm.com> <20170802084350.GC15219@arm.com> <20170802085111.iupsx6s3hw42a52b@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170802085111.iupsx6s3hw42a52b@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 02, 2017 at 10:51:11AM +0200, Peter Zijlstra wrote: > On Wed, Aug 02, 2017 at 09:43:50AM +0100, Will Deacon wrote: > > On Wed, Aug 02, 2017 at 09:15:23AM +0100, Will Deacon wrote: > > > > I really think we should avoid defining TLB invalidation in terms of > > > smp_mb() because it's a lot more subtle than that. > > > > Another worry I have here is with architectures that can optimise the > > "only need to flush the local TLB" case. For example, this version of 'R': > > > > > > P0: > > WRITE_ONCE(x, 1); > > smp_mb(); > > WRITE_ONCE(y, 1); > > > > P1: > > WRITE_ONCE(y, 2); > > flush_tlb_range(...); // Only needs to flush the local TLB > > r0 = READ_ONCE(x); > > > > > > It doesn't seem unreasonable to me for y==2 && r0==0 if the > > flush_tlb_range(...) ends up only doing local invalidation. As a concrete > > example, imagine a CPU with a page table walker that can snoop the local > > store-buffer. Then, the local flush_tlb_range in P1 only needs to progress > > the write to y as far as the store-buffer before it can invalidate the local > > TLB. Once the TLB is invalidated, it can read x knowing that the translation > > is up-to-date wrt the page table, but that read doesn't need to wait for > > write to y to become visible to other CPUs. > > > > So flush_tlb_range is actually weaker than smp_mb in some respects, yet the > > flush_tlb_pending stuff will still work correctly. > > So while I think you're right, and we could live with this, after all, > if we know the mm is CPU local, there shouldn't be any SMP concerns wrt > its page tables. Do you really want to make this more complicated? It gives us a nice performance lift on arm64 and I have a patch...[1] Will [1] https://git.kernel.org/pub/scm/linux/kernel/git/will/linux.git/commit/?h=aarch64/devel&id=1c7cf53658f0fa16338d1f8406285ae28fd5f616