Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1066418rdb; Fri, 16 Feb 2024 04:34:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWwfm6u0EMrlVxrAPt6KsrF5oG45tlGW9+Ts+K0hudVBGD/01nelKkGe+F66Ys2z7MRm4swEh+B3KEg5s19vHAddMka14tS7cOCSJzX8w== X-Google-Smtp-Source: AGHT+IH+spdEpalSYN7V8gxNdZLsm87zAaTsF/euJGjLTq9g8YERqBtrcazjy40L+NazRwOzJQD7 X-Received: by 2002:a17:906:4146:b0:a3c:ed94:7672 with SMTP id l6-20020a170906414600b00a3ced947672mr3636285ejk.64.1708086857926; Fri, 16 Feb 2024 04:34:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708086857; cv=pass; d=google.com; s=arc-20160816; b=xXzUVQLcZzoN4VzTzLNDWwgwqnaKHE8DLFVNB30RhST1WaK/aWmLQlQUXG6uzVCbtU JyPIZ+09tjkQ/SPcpXzfX0tqCbyGq5e1vKKVD+3T7RXg+bo/7MCkN1lHSb5gUga4ckiY LwfyUoI+ARF9gBVda9Bc2ngf5c1P6K6TMWpEd5KVNXXVdNSSXrZfkKwcz5vDhUsq4CZF 4eq2L7c2LpDn+4pd/kg880xAWcUZ5VA7+LA0Mi1cZyyBfuoSxq8QxQLCrqSO2IJg0zmo gAB9IJdWIno6aofFY/cjX2UpepEmgwmhz4Z2RjEcYOFzpWFB0kQZdAkleJNdR4PmkSdd AxaA== 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=+szfn7FTsCeayUieX57QJgh0t4LRwBC3rP//HGUA5Ho=; fh=r8G2JENgcRo/RTe4xvZO7IzPLZ7yvHykzgF2Da/HHrw=; b=KoLYEDL9NRb6skVdP54i0LJD8v9DCeBGtRcQoQTIuimKCDvXWpFkFGhnSNO7zVY1x/ 5LPQ+8JiS9r+wRfDYjo5+YBWA7yPH1CQsJdX66CLgDv9vGDnXPsjW5apOvvveTaQVNaY QioOFwRR4nuelblB/PZNBrexBPv6yURaKrtWeBwvHpq4AL/K+Lcp3hodA2suXtWkUyt3 wotp6j2u8L3/e2DGNT2QyjOgByB/gpFh9plvklrNYyUCFM8dA+Aaow59/clf986fSA3L 3HaBkS1VEMagZyNZnaV+NJvIqgW/JOUwv8rOonjOdOIQT8aR8QEMRC9gHoBG5o7Ls6fa Jeqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-68575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68575-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n18-20020a170906119200b00a3d2dedf4c2si1560976eja.1025.2024.02.16.04.34.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 04:34:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68575-linux.lists.archive=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 (google.com: domain of linux-kernel+bounces-68575-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68575-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AC1541F2354B for ; Fri, 16 Feb 2024 12:34:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E7E6339A1; Fri, 16 Feb 2024 12:34:10 +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 AD24531A6B for ; Fri, 16 Feb 2024 12:34:09 +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=1708086849; cv=none; b=petQU57PHVty1bgqlWeVXhMpLC80QlkpQ5QWpx4hIyoaFSxfDuTJzkgLhyTUbCqqEKdFE7HZkerb33eWyXVAqBmjLhYByeO/LUiTQeRy8kbLtP3NlPpEA9NtPMyIzsgFRz5rHz0L8RtpO7bzeo3sD5wGCML6Dl32pbA/xIghQo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708086849; c=relaxed/simple; bh=U+Nd0Nrku3Vnfy7PcrItv1vzYsXp20qJMpnqhVTVlVw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IoBzIykqz95mw5LahABNDNqUPyTUg362Glxq5mduoNSxIQ6czi2qARYiZUpCTyBoVpGyrSE9Naj5qRkIWtrAs09tnaVGDw3kfC8XoLIK3tezxT0og8l6CM6UlTye7VrZYq4lZtxAfdpoyZ+aK/NhP+vMeEGgFCQ2gPTKVNZjYps= 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 4F9B9C433C7; Fri, 16 Feb 2024 12:34:04 +0000 (UTC) Date: Fri, 16 Feb 2024 12:34:02 +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 16/18] arm64/mm: Implement pte_batch_hint() Message-ID: References: <20240215103205.2607016-1-ryan.roberts@arm.com> <20240215103205.2607016-17-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-17-ryan.roberts@arm.com> On Thu, Feb 15, 2024 at 10:32:03AM +0000, Ryan Roberts wrote: > When core code iterates over a range of ptes and calls ptep_get() for > each of them, if the range happens to cover contpte mappings, the number > of pte reads becomes amplified by a factor of the number of PTEs in a > contpte block. This is because for each call to ptep_get(), the > implementation must read all of the ptes in the contpte block to which > it belongs to gather the access and dirty bits. > > This causes a hotspot for fork(), as well as operations that unmap > memory such as munmap(), exit and madvise(MADV_DONTNEED). Fortunately we > can fix this by implementing pte_batch_hint() which allows their > iterators to skip getting the contpte tail ptes when gathering the batch > of ptes to operate on. This results in the number of PTE reads returning > to 1 per pte. > > Acked-by: Mark Rutland > Reviewed-by: David Hildenbrand > Tested-by: John Hubbard > Signed-off-by: Ryan Roberts Acked-by: Catalin Marinas