From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE69AC6FD20 for ; Fri, 24 Mar 2023 17:23:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A78B6B0072; Fri, 24 Mar 2023 13:23:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 559376B0075; Fri, 24 Mar 2023 13:23:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 478D06B0072; Fri, 24 Mar 2023 13:23:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 383116B0072 for ; Fri, 24 Mar 2023 13:23:29 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id AB5A7140819 for ; Fri, 24 Mar 2023 17:23:28 +0000 (UTC) X-FDA: 80604463296.08.A6C99E7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id D8716A001B for ; Fri, 24 Mar 2023 17:23:26 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LsKVbaD2; spf=pass (imf25.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1679678607; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+uc46QioDVL46mYUbWJH7KJ+B6j9c1FknWpVIQ6sEbA=; b=odZb0Ce1v9gQVWcfsw1JLtQVqMo55EBNN/eHwDG0eaqvNbN+uFQ0ua/v7O1I7RZBMhiYAD xgFA8kIQvSHFOvY/i0/47mYL8sezXF6uqSefvTllTPx4aOfb/N7pF34lQfEACmjDQq1Cjx GOz745jKv/LLd+qCJbTGCl0PNDNHxjc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LsKVbaD2; spf=pass (imf25.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679678607; a=rsa-sha256; cv=none; b=U/aVqdLIkposy9n+RuJupi2W+54MA3o2rFDntI270WQzCoyFPUnMsbND7xEqAsWURmJq/+ QQu5QotLDNCsJqTpzaKX+1LWC/Bqpu7NFgjZecJk5qXuHWf+0UjPk6+s3+pWW+KXVbs1qq 2IGdevYEob66GrU8ses9zFXjiXucQ6o= 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 dfw.source.kernel.org (Postfix) with ESMTPS id C8BD762C01; Fri, 24 Mar 2023 17:23:25 +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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D8716A001B X-Rspam-User: X-Stat-Signature: degqjq4b5rxh14u3x53ddyujkxfq8yq1 X-HE-Tag: 1679678606-804392 X-HE-Meta: U2FsdGVkX1+6d9B21+8w7Gbt5yKkl52BTpLhyIo9+gsynxuH5vQ1gw1K1KXrOFdbeltgqDTYksLPf/3Dufiz2ndNB78Cg561I3PUEXIr1Zj9TzrG5nNXFHq72At8cbNC1uUOWT2VXNMxPSb1ztphMqhby7+77mU7FMJ3mMSx5XHOtj0jBK4fwywtQqOglkg0/KEriypebnlAOKRoF5Zy9flX/EGhlpoIurjw5wgmEx0vx548fg3fuPBRYu+g9dLDEpw4XoIz4e3yzHFCysrkZboH9fChmf4blZpbpGAgbrULNOsMj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KYp6QwnCLGSLHND1A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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