Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1064616rdb; Fri, 16 Feb 2024 04:31:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWwEmCYRnbQ8aS+bOnNs72buXnpv3nZclh+opEe4DR36JL9CpLfWm0tLL4PEvYb2ZB6xAjZMeWWOfdeCcTFnZjkR5cpB5KkIM+ETy2m+g== X-Google-Smtp-Source: AGHT+IEOPjq75DEdoxWXmBqKuO5nvTmkV/gFWrBAhA3TIBuQVg/k/FwV762oitss6uD2wx1Q2hGR X-Received: by 2002:a1f:ccc4:0:b0:4c0:1cb7:1ba9 with SMTP id c187-20020a1fccc4000000b004c01cb71ba9mr4270693vkg.9.1708086671462; Fri, 16 Feb 2024 04:31:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708086671; cv=pass; d=google.com; s=arc-20160816; b=iSquzI52nMpdviEjJJCGn/2nAVtmRV4EGtuHwC168k+TfpviknZ4/NYkR2W/14aNeB 8nno1mGAfJ9XLcgZ2ZnsCj2VkVmgLm21we3Taev9g9uzMVHd1hYe+J3E+/y8IQjg7QvR PTERjwKtyDQ7cZjLx3pRRo+sO9NDufVvBcAJ5kxndoDqfe96ORSNx2m8rAwe1pyHSzWJ AcUJFpX8Xr6KzQoaG55m6LdYlpiCXLa7HYCVKzhJ5oSEXjHEqGWbpYJIo7k4mrfSxm5R xiHOoHMQ6A5AqaLVrb8iPUoW1ijgXV6j8V0mjJHSyzAwjpalXQVHrkgGKFtcPbrgLM2O 9Odw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=GU/7J+2npw48+k/rcVZTZp/Av0qudjFYnO2RtLIGt0Q=; fh=r8G2JENgcRo/RTe4xvZO7IzPLZ7yvHykzgF2Da/HHrw=; b=LQsZCNyqT/WoU6Vh+9S9dRHauinc0SCFg9rBsRmb3fAyn7ulRav6XoOdynfn0X9zGi Z0HjHn0xU80WRKwmb6jPwkjKAOrgI4P2yYw8UbENQfTwz6nyFTuuf9tyqn0I+r+Jc3uY +4MJ33zH2i6GFrxL8z2eyV/PUr5qiD1G2grrLszhkuGGH9suw/qUi3fbKwWxTQFYPZF8 3t/z0rd4vwD7Xnk0o20I/8U+gsXbfnfgWoScWUmHe5iAEnmcwexC5ALMJQhjyKAPtiTN A489gecWHVKsZMAfRBzcseE4yB5vch9eAJqNz8Ep1wg8vD2AYACugy8gzWBpSL3hGPhu GkGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-68569-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68569-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fc28-20020a0561224b1c00b004c04d3b77edsi684926vkb.262.2024.02.16.04.31.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 04:31:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68569-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-68569-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68569-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5940C1C23AAF for ; Fri, 16 Feb 2024 12:30:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 659207C09B; Fri, 16 Feb 2024 12:30:20 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDF607C08C for ; Fri, 16 Feb 2024 12:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708086619; cv=none; b=KlKUqnnaZzBhOLS34vzd0OxveFR/tdDjcCLR3yI4KClpm/tM45W82Rey4TRpfL8xq5AwCcqY7WNBTkkQ9uuYCFoQdsq12zkokU/hGZ8VtJiguRXzv6ht6Bg5wlC7TORTuG9913f6iKC2ArvZNODBjBuSDfnEV1fWbfgl45xACoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708086619; c=relaxed/simple; bh=hSagM66nHqohc3xjadNSn1DAfQnHgteN0S/fJC2fuTo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Vpr7yczOdmJukTHnlX0gLzt3D2YEMUR79q6fTdKX48g06U2+XY8nShkkd2gGTmXqD4Zo06jwjvifajBcmypdE+CWtMikw4As7mPK3sg9gt0gxI1Wrfk7FLzbl/gOxit4oKGOmeTyktXxep/JxtEZAY2ZPjQ3WTks4y6xAPcn37A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA0D8C433C7; Fri, 16 Feb 2024 12:30:14 +0000 (UTC) Date: Fri, 16 Feb 2024 12:30:12 +0000 From: Catalin Marinas To: Ryan Roberts Cc: 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" , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 13/18] arm64/mm: Implement new wrprotect_ptes() batch API Message-ID: References: <20240215103205.2607016-1-ryan.roberts@arm.com> <20240215103205.2607016-14-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240215103205.2607016-14-ryan.roberts@arm.com> On Thu, Feb 15, 2024 at 10:32:00AM +0000, Ryan Roberts wrote: > Optimize the contpte implementation to fix some of the fork performance > regression introduced by the initial contpte commit. Subsequent patches > will solve it entirely. > > During fork(), any private memory in the parent must be write-protected. > Previously this was done 1 PTE at a time. But the core-mm supports > batched wrprotect via the new wrprotect_ptes() API. So let's implement > that API and for fully covered contpte mappings, we no longer need to > unfold the contpte. This has 2 benefits: > > - reduced unfolding, reduces the number of tlbis that must be issued. > - The memory remains contpte-mapped ("folded") in the parent, so it > continues to benefit from the more efficient use of the TLB after > the fork. > > The optimization to wrprotect a whole contpte block without unfolding is > possible thanks to the tightening of the Arm ARM in respect to the > definition and behaviour when 'Misprogramming the Contiguous bit'. See > section D21194 at https://developer.arm.com/documentation/102105/ja-07/ > > Tested-by: John Hubbard > Signed-off-by: Ryan Roberts Acked-by: Catalin Marinas