Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5947975rwr; Tue, 9 May 2023 08:16:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oQeDIR9/YElU2fnRtf8m7A45v45nCGEDN/X1hzf7fs6WrIbWtrplpJv/wH9ZveyKaUmBK X-Received: by 2002:a17:90b:17d0:b0:23d:15d8:1bc3 with SMTP id me16-20020a17090b17d000b0023d15d81bc3mr14244379pjb.39.1683645377576; Tue, 09 May 2023 08:16:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683645377; cv=none; d=google.com; s=arc-20160816; b=QWvi3qVoaL4qbBfObPfs2JELLV3IPC+FjdmmxsGaLS8NSO0qXlgk6E0vXV7qqH2fH5 xxFzD1qgilS3xufOGZg0sdhOm9Cwm5kd+Ghla1tZs1GXGv1jreZowd0i+Xss7K5rot4S 6Q11Upxt/IQC2XgtkHN6nZ781F3VYa6Wu1z9AJyzuLqP2q5wzirT7vZBwl46DOr/weWE ci3UtPHEDjpa9ZtJxsn6ZAZMR0F+Oau+duWcBsmhNhOhbOmZLr6mFadLqQsmq9ha7D3E IuMAJ3nu+PhNI/kUDm6lhRY8jo4fSuhlSRoV1yl2+YZB58OA04ocIuzao+2YPSwIjDJC uj0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Z6nO3XU26VATyMLdwYRrkCD73stL0u/gZVqTwlbD714=; b=sQRycCmUshjgzM3yboNEXBsD7ynJd8QpIc8lmKoy2UKpA+3ad6gBEzOgXnQy6vWzQk v5OXkhGFK440HEGSl5KtQowDvZB/i2Q3LeWuuKGlq1itDPvJ82PAl3+dBv/9ZMfcJpzX puKmzBeXOnNU4QCUZtK1N+kijnQ6YqIsAlWWVWaGaoAxxMCTSQF/SfmCA+tNUf1U+My7 OPhieBBy131W4iWnqtdtXcuqwFp4z9MwhO4Eszdw5q2ZnzsI+/MS6hSEkdl9Ogp+If77 /sYMIw4S+/0dPXifb6QbQC89YYPKFwnK+acmwd+QwC3/ICzLjwX9GVNaFIVL4ZzaZorK yTHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc12-20020a17090b3b8c00b00246596483a3si22786832pjb.37.2023.05.09.08.16.03; Tue, 09 May 2023 08:16:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235605AbjEIOab (ORCPT + 99 others); Tue, 9 May 2023 10:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235392AbjEIOaa (ORCPT ); Tue, 9 May 2023 10:30:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B910C170B for ; Tue, 9 May 2023 07:30:28 -0700 (PDT) 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 F16D3FEC; Tue, 9 May 2023 07:31:12 -0700 (PDT) Received: from FVFF77S0Q05N.cambridge.arm.com (FVFF77S0Q05N.cambridge.arm.com [10.1.34.150]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3B1C73F663; Tue, 9 May 2023 07:30:27 -0700 (PDT) Date: Tue, 9 May 2023 15:30:24 +0100 From: Mark Rutland To: Gang Li Cc: Will Deacon , Catalin Marinas , Ard Biesheuvel , Anshuman Khandual , Kefeng Wang , Feiyang Chen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [QUESTION FOR ARM64 TLB] performance issue and implementation difference of TLB flush Message-ID: References: <2eb026b8-9e13-2b60-9e14-06417b142ac9@bytedance.com> <369d1be2-d418-1bfb-bfc2-b25e4e542d76@bytedance.com> <9d976db8-b800-ad84-9c67-0afb942934d9@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9d976db8-b800-ad84-9c67-0afb942934d9@bytedance.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 06, 2023 at 10:51:23AM +0800, Gang Li wrote: > Hi, > > On 2023/4/28 17:27, Mark Rutland wrote:> The architecture allows a CPU to > allocate TLB entries at any time for any > > reason, for any valid translation table entries reachable from the root > > in TTBR{0,1}_ELx. That can be due to speculation, prefetching, and/or other > > reasons. > > TLB will be allocated due to prefetching or branch prediction. Will it > be invalidated when the prediction fails? No; once allocated they're allowed to remain until explicitly invalidated. See below for more detail. > > Due to that, it doesn't matter whether or not a CPU explicitly accesses a > > memory location -- TLB entries can be allocated regardless. > > Consequently, the > > spinlock doesn't make any difference. > > And is there any kind of ARM manual or guide that explains these details to > help us programming better? There's no guide that I am aware of, but this is described in the ARM ARM. The current relase (ARM DDI 0487J.a) can be found at: https://developer.arm.com/documentation/ddi0487/ja ... and in future, the latest version should be available at: https://developer.arm.com/documentation/ddi0487/latest In the latest release (ARM DDI 0487J.a) relevant information can be found in section D8 "The AArch64 Virtual Memory System Architecture", with key information in D8.13 "Translation Lookaside Buffers" and D8.14 "TLB maintenance". For example, early in D8.13 we have the rule: | R_SQBCS | | When address translation is enabled, a translation table entry for an | in-context translation regime that does not cause a Translation fault, an | Address size fault, or an Access flag fault is permitted to be cached in a | TLB or intermediate TLB caching structure as the result of an explicit or | speculative access. Thanks, Mark.