Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1442565rwl; Fri, 24 Mar 2023 10:31:38 -0700 (PDT) X-Google-Smtp-Source: AKy350a3uv0ZDPoI1gt8/Fg5Rll1yy5M4k2c1A09Wyn9LIfJgXrOyxPrtIJQ25I/L9H0znGnnjX2 X-Received: by 2002:aa7:9521:0:b0:628:4a3:f22c with SMTP id c1-20020aa79521000000b0062804a3f22cmr3541295pfp.31.1679679098598; Fri, 24 Mar 2023 10:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679679098; cv=none; d=google.com; s=arc-20160816; b=XAvbWAIpwYp6oQFLeLGW2odgWbehVB7Mpgb/DAMNawe3ptmaFpL63gx7kmDPsACrk5 OAxsHXP8Ya38DPsTdbuzHLW+AwIIgoq4UrF8z3s6m1j4lUawJcktA+TxBtWAfy4gJzdP GA0WDPm/B1827bvTyn+9+EJuTkFRtba2Dkf6n5ZysJ7wndObxqtpQVsKus4T7FzGVi7Y OnnHbkJWo6cDnllIC5bd/RP+k0CYZBmZGZ0wTPh3oW/QInzqLp+QZd9t9XUvw5ti2+BT RzGHfAbzwuHJEKCLJFqDdrSJTF9nSV8bC8sTvUZRowGt+IdQ+Cp4xPCN77gRzH5afEmL LIrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=+uc46QioDVL46mYUbWJH7KJ+B6j9c1FknWpVIQ6sEbA=; b=TbFCEfZeisjPp8q7KfyD3WJx5ahXPmpKzVownddIasdLAT+1cQ93Io/h89hlFw2QDj HoXjyxVAj99XgbIhilzt0T1iLDCyKvTt8DgMYw1U3alBuS+Toi9fV2Ee4IQHsDXaQlTN PilKxVpEIBC/tcos3KhzoxelxovhUEwCPrAnTaWG+a6KMeun1e2h1ZV22LJs7l1/pEBy tsZBtVzbF7Y/tpMcnDyxJsCZZQCTePjHEQ64Z+AGW8/9DFrhntMSuN/N8KCLcNnOToCS FQLDkOyGBb089q56RmkZJ5H7WDkM97Y4Nun4Rbra9/ra9OmwBiGk3+WcZ2F1hTfO1r0g uONA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LsKVbaD2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a3-20020a63e843000000b0050f55427e3dsi18254168pgk.701.2023.03.24.10.31.23; Fri, 24 Mar 2023 10:31:38 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LsKVbaD2; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231447AbjCXRXa (ORCPT + 99 others); Fri, 24 Mar 2023 13:23:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbjCXRX2 (ORCPT ); Fri, 24 Mar 2023 13:23:28 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D795E49E1; Fri, 24 Mar 2023 10:23:27 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 883B8B82542; Fri, 24 Mar 2023 17:23:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03C44C433EF; Fri, 24 Mar 2023 17:23:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679678605; bh=hjmtTNY2LEM4m5fAZV6d3wQ06Jak42bz3CVHjflH8ck=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LsKVbaD2ZK8EjUVu7w7khg4JYE5SqpclxxIVLUnrWJn34t4R4e49IifU3e86N10DU gfROvnCLRVIPVG+pXSK6xtwM/DTdk0VBjgixqiqjR1RdQve2xuPBzM7glDBqEgSZdW 3BkR75UqI208Bccv6DtLQzHS6gwkw1a5agDlKPNo/26kxIrq3Nkt6GBndmTOrkBZY3 am5SRH0xSCRGmxkWptjZbj26Xi4amAwLH5ORkYFp2Jd3vEfWojAJahrjTREnkX6F4w 3HEROgCWhHFgifZ+cRwpULDf07kDyOuRR3qmCSKNHoen3ZRqUNXImBokPz/7MG6hEy qyHsczyCKzXwQ== Date: Fri, 24 Mar 2023 17:23:20 +0000 From: Will Deacon To: Matthew Wilcox Cc: "Yin, Fengwei" , Ryan Roberts , linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 35/36] mm: Convert do_set_pte() to set_pte_range() Message-ID: <20230324172319.GA27842@willie-the-truck> References: <2fa5a911-8432-2fce-c6e1-de4e592219d8@arm.com> <12d7564f-5b33-bdcc-1a06-504ad8487aca@intel.com> <25bf8e75-cc2e-7d08-dbba-41c53ab751b0@arm.com> <20230324145828.GB27199@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Fri, Mar 24, 2023 at 03:11:00PM +0000, Matthew Wilcox wrote: > On Fri, Mar 24, 2023 at 02:58:29PM +0000, Will Deacon wrote: > > Yes, please don't fault everything in as young as it has caused horrible > > vmscan behaviour leading to app-startup slowdown in the past: > > > > https://lore.kernel.org/all/20210111140149.GB7642@willie-the-truck/ > > > > If we have to use the same value for all the ptes, then just base them > > all on arch_wants_old_prefaulted_pte() as iirc hardware AF was pretty > > cheap in practice for us. > > I think that's wrong, because this is a different scenario. > > Before: > > We faulted in N single-page folios. Each page/folio is tracked > independently. That's N entries on whatever LRU list it ends up on. > The prefaulted ones _should_ be marked old -- they haven't been > accessed; we've just decided to put them in the page tables to > speed up faultaround. The unaccessed pages need to fall off the LRU > list as quickly as possible; keeping them around only hurts if the > workload has no locality of reference. > > After: > > We fault in N folios, some possibly consisting of multiple pages. > Each folio is tracked separately, but individual pages in the folio > are not tracked; they belong to their folio. In this scenario, if > the other PTEs for pages in the same folio are marked as young or old > doesn't matter; the entire folio will be tracked as young, because we > referenced one of the pages in this folio. Marking the other PTEs as > young actually helps because we don't take pagefaults on them (whether > we have a HW or SW accessed bit). > > (can i just say that i dislike how we mix up our old/young accessed/not > terminology here?) > > We should still mark the PTEs referencing unaccessed folios as old. > No argument there, and this patch does that. But it's fine for all the > PTEs referencing the accessed folio to have the young bit, at least as > far as I can tell. Ok, thanks for the explanation. So as long as arch_wants_old_prefaulted_pte() is taken into account for the unaccessed folios, then I think we should be good? Unconditionally marking those PTEs as old probably hurts x86. Will