Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2765267ybi; Mon, 17 Jun 2019 10:12:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpL1XVA4h6GEwwqrnW+zEwRZsWzHBs0eSfhnWwhOX3wxXIjYUhB4Yjmy/CGWcytAzeXXLX X-Received: by 2002:a17:902:e211:: with SMTP id ce17mr27255128plb.193.1560791095790; Mon, 17 Jun 2019 10:04:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560791095; cv=none; d=google.com; s=arc-20160816; b=oaFz9E0ooH2gCQZyBU/Qfy5rsN+uoA1V+lX6eSaUNpEnynzRocB5kEyluAOOaZBVLP 5GUfFEa7DHSuE3G5HubJ8shHUFskxRBGy2N0kbtCPKb5FXEqD5sKISlGVt9a+M41bLz9 hrjFScFlqJgH0P+LGPbORVBlakNgstbP6Cm5JrfsqKxHXrNNNfS5C9IfJ8dCWq6/Q/Zj NFpmTpcNg0cnDaIa5vVtm3rPFmRNkiyuhGb0oY7Xapy2g47zDNRnzOpYHE/JUu3dbB/I rzS43TTt93J7bD+a8GdiN9/2q8mwZ1XLlmv5L1JPW0P/j++YQVz7L8swsUEveZpGNJRA +yZg== 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; bh=L+YorRHHLgYirp0jm4b9x4gb3hOogMgss398hEOxkkM=; b=cfG6mHi7wOY/wOjo85d8+GeEC27mahZ+6P0Vjmd9xT+VOeaZkQrkkckyg5yjnHgWOy Fa5o8fmn1XJw9zyS3OVIredpCxeTh8M49XZgIZjOfOiIqdOLDgdxqRVKHB6S6FfOqz5w 2t6sSowek93JPBhuVsdlBwcDz/dmqRXXO/d3yAq+FO+GGmHseGjGEGyTvEDam4EWWJuA szawNZ/05nappZuwMQlVzVx1d4GYK+80kuI/7+y6zF6/E2W/a7O75r1P7TeJPmOjtbFK WGnPQBeXpu3STo0AR6NypvkaPWbiwVNp4EMqvBf9+Vj877/IUpdPXl3SeHIHENAsHEGv vj6Q== 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 62si9979914pff.216.2019.06.17.10.04.40; Mon, 17 Jun 2019 10:04:55 -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 S1727821AbfFQRDc (ORCPT + 99 others); Mon, 17 Jun 2019 13:03:32 -0400 Received: from foss.arm.com ([217.140.110.172]:56634 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727121AbfFQRDc (ORCPT ); Mon, 17 Jun 2019 13:03:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 77CAA28; Mon, 17 Jun 2019 10:03:31 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3C2A03F738; Mon, 17 Jun 2019 10:03:30 -0700 (PDT) Date: Mon, 17 Jun 2019 18:03:28 +0100 From: Will Deacon To: Takao Indoh Cc: Jonathan Corbet , Catalin Marinas , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, QI Fuli , Takao Indoh , peterz@infradead.org Subject: Re: [PATCH 0/2] arm64: Introduce boot parameter to disable TLB flush instruction within the same inner shareable domain Message-ID: <20190617170328.GJ30800@fuggles.cambridge.arm.com> References: <20190617143255.10462-1-indou.takao@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190617143255.10462-1-indou.takao@jp.fujitsu.com> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Takao, [+Peter Z] On Mon, Jun 17, 2019 at 11:32:53PM +0900, Takao Indoh wrote: > From: Takao Indoh > > I found a performance issue related on the implementation of Linux's TLB > flush for arm64. > > When I run a single-threaded test program on moderate environment, it > usually takes 39ms to finish its work. However, when I put a small > apprication, which just calls mprotest() continuously, on one of sibling > cores and run it simultaneously, the test program slows down significantly. > It becomes 49ms(125%) on ThunderX2. I also detected the same problem on > ThunderX1 and Fujitsu A64FX. This is a problem for any applications that share hardware resources with each other, so I don't think it's something we should be too concerned about addressing unless there is a practical DoS scenario, which there doesn't appear to be in this case. It may be that the real answer is "don't call mprotect() in a loop". > I suppose the root cause of this issue is the implementation of Linux's TLB > flush for arm64, especially use of TLBI-is instruction which is a broadcast > to all processor core on the system. In case of the above situation, > TLBI-is is called by mprotect(). On the flip side, Linux is providing the hardware with enough information not to broadcast to cores for which the remote TLBs don't have entries allocated for the ASID being invalidated. I would say that the root cause of the issue is that this filtering is not taking place. > This is not a problem for small environment, but this causes a significant > performance noise for large-scale HPC environment, which has more than > thousand nodes with low latency interconnect. If you have a system with over a thousand nodes, without snoop filtering for DVM messages and you expect performance to scale in the face of tight mprotect() loops then I think you have a problem irrespective of this patch. What happens if somebody runs I-cache invalidation in a loop? > To fix this problem, this patch adds new boot parameter > 'disable_tlbflush_is'. In the case of flush_tlb_mm() *without* this > parameter, TLB entry is invalidated by __tlbi(aside1is, asid). By this > instruction, all CPUs within the same inner shareable domain check if there > are TLB entries which have this ASID, this causes performance noise. OTOH, > when this new parameter is specified, TLB entry is invalidated by > __tlbi(aside1, asid) only on the CPUs specified by mm_cpumask(mm). > Therefore TLB flush is done on minimal CPUs and performance problem does > not occur. Actually I confirm the performance problem is fixed by this > patch. Other than my comments above, my overall concern with this patch is that it introduces divergent behaviour for our TLB invalidation flow, which is undesirable from both maintainability and usability perspectives. If you wish to change the code, please don't put it behind a command-line option, but instead improve the code that is already there. However, I suspect that blowing away the local TLB on every context-switch may have hidden costs which are only apparent with workloads different from the contrived case that you're seeking to improve. You also haven't taken into account the effects of virtualisation, where it's likely that the hypervisor will upgrade non-shareable operations to inner-shareable ones anyway. Thanks, Will