From patchwork Thu Feb 15 10:31:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 201347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp304250dyb; Thu, 15 Feb 2024 02:37:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWO7153WXP+Rni+Wtdj0UtulgVxzToUZ2limVBAGGNsjv3vele8LpHL/SdyLKDWkPlEA/OTIG7+E1pCAHkVjE1Cb4ZeDQ== X-Google-Smtp-Source: AGHT+IFs7gUktw4pBlIoSqcb22aGa2k3QfbccdecXp6vG3U2YoanZovUsujiMVEvpIgzSiYn+1Uo X-Received: by 2002:a19:9143:0:b0:511:8763:bb63 with SMTP id y3-20020a199143000000b005118763bb63mr1004839lfj.41.1707993479675; Thu, 15 Feb 2024 02:37:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707993479; cv=pass; d=google.com; s=arc-20160816; b=sMt/9pVkC//N4QMfdmbnD0aqoi4YRD5uev80crSzoZh1fqwSYCNfpylhJpOjSMn7hZ VnlRf+0poZTxq+pRHnK/FbafkhRlVYeoi0TOHYRRuagiy/iiO2FmdzG6c2dz4em+gCDo t4ms+p328JtX8dfSm0gywc5nq1WUB9GG62DqbQh/rR1W7625+7dX9KLF1aUrYA0Asbcf 6MO6Ee/8iik7kNwk3hKSWWnNnD93mA1DXdTV9hTZzio+/YOzoxGejCXcAoTJKxSFZ3d6 oyrmmnuFWUlvPUfSBGxRtZUbH87HUt7cUzaIWwrfe7vvgzqXF1P79U9GTmOd4+d+aFPr iELQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=4J1dTrrIzJ+DpallLluT2b35txLH0YV5OvrN+DtNofk=; fh=Heagowc1O8zVDXTyU76nJjOwDjz9r3Gi+0zmhF4ZELQ=; b=vXOE26ITSmS+jPAlzGI7ucc21FgoX7Nw6/W3CHFvgQvurWvJGbiHboSRYlVGEMLu0b /4F1zuiLteS0b/KJEbF3InU7yEc4KCdgmK7vHAFx0RLxMQRkc5fpJkOt9RX6MAiyp5A9 QKwqXxEK4UibtJ7vqI19vU1ItJBmhhwknbm+chDgQKp+BtQbNcIr94ygwyDi75HRcpH/ rSULuY+j5WXrdJjv0L6z5GiaRV0ch876Ivhawj3g/ifstP/hzMfg4Zq1myd4Z1+cWA0m o4uFxzLm4T72bRFBQOAFhmTspZNbKsaqQzjrSsksd1zsV6sGPJrVvMulsTyEhZbXMXLp Fawg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66648-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66648-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a4-20020a1709062b0400b00a3d6cc63d45si532457ejg.135.2024.02.15.02.37.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 02:37:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66648-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-66648-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66648-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 472061F207C1 for ; Thu, 15 Feb 2024 10:37:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CA0D12FB04; Thu, 15 Feb 2024 10:33:02 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E50F012F38D for ; Thu, 15 Feb 2024 10:32:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993180; cv=none; b=MKTveGHENdRDJAb3iZsXJrfwGTAKvxLIm7uiXMK4ZkzQH9hk47NdVOfpqHbcscktIaMECtNU4lfyWBfULH+N3B+mzBFSMA8Mf4EWMRDWveTeX0FO0g7ujsTUAjLhJ9ZYMhjw07Vt60TgQq7IKMFCLp0Fp0/Gis02IzgByFgtF7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707993180; c=relaxed/simple; bh=7hm98Uy4uzJ8moWfBkXOKwgSvNFZT6zUX8a/wpE/3D8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FhZCIDTh/YoMke6UJr7oV0TobnPA9odORjdckqVvniytUCwJCtlT9Rux8bTm8G3gLmP5X9IqYocQInQtErFkOw7HnAhsmm4OJ6KRT89J9UWKshYPsHTmtU9VAWNF5cPcJhE13Kq6cjJ6we2DkYtYErqJYSIZ82gf8P+rXu15Ug0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 79677DA7; Thu, 15 Feb 2024 02:33:38 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E5073F7B4; Thu, 15 Feb 2024 02:32:54 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 11/18] arm64/mm: Split __flush_tlb_range() to elide trailing DSB Date: Thu, 15 Feb 2024 10:31:58 +0000 Message-Id: <20240215103205.2607016-12-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240215103205.2607016-1-ryan.roberts@arm.com> References: <20240215103205.2607016-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790960970714181459 X-GMAIL-MSGID: 1790960970714181459 Split __flush_tlb_range() into __flush_tlb_range_nosync() + __flush_tlb_range(), in the same way as the existing flush_tlb_page() arrangement. This allows calling __flush_tlb_range_nosync() to elide the trailing DSB. Forthcoming "contpte" code will take advantage of this when clearing the young bit from a contiguous range of ptes. Ordering between dsb and mmu_notifier_arch_invalidate_secondary_tlbs() has changed, but now aligns with the ordering of __flush_tlb_page(). It has been discussed that __flush_tlb_page() may be wrong though. Regardless, both will be resolved separately if needed. Reviewed-by: David Hildenbrand Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/tlbflush.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h index 1deb5d789c2e..3b0e8248e1a4 100644 --- a/arch/arm64/include/asm/tlbflush.h +++ b/arch/arm64/include/asm/tlbflush.h @@ -422,7 +422,7 @@ do { \ #define __flush_s2_tlb_range_op(op, start, pages, stride, tlb_level) \ __flush_tlb_range_op(op, start, pages, stride, 0, tlb_level, false, kvm_lpa2_is_enabled()); -static inline void __flush_tlb_range(struct vm_area_struct *vma, +static inline void __flush_tlb_range_nosync(struct vm_area_struct *vma, unsigned long start, unsigned long end, unsigned long stride, bool last_level, int tlb_level) @@ -456,10 +456,19 @@ static inline void __flush_tlb_range(struct vm_area_struct *vma, __flush_tlb_range_op(vae1is, start, pages, stride, asid, tlb_level, true, lpa2_is_enabled()); - dsb(ish); mmu_notifier_arch_invalidate_secondary_tlbs(vma->vm_mm, start, end); } +static inline void __flush_tlb_range(struct vm_area_struct *vma, + unsigned long start, unsigned long end, + unsigned long stride, bool last_level, + int tlb_level) +{ + __flush_tlb_range_nosync(vma, start, end, stride, + last_level, tlb_level); + dsb(ish); +} + static inline void flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) {