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 B37B0C6FD1F for ; Thu, 16 Mar 2023 17:53:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28AFB900004; Thu, 16 Mar 2023 13:53:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21425900002; Thu, 16 Mar 2023 13:53:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0DCE7900004; Thu, 16 Mar 2023 13:53:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EEBE8900002 for ; Thu, 16 Mar 2023 13:53:03 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B640A4014D for ; Thu, 16 Mar 2023 17:53:03 +0000 (UTC) X-FDA: 80575507446.30.61FF93F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id D2DFD40017 for ; Thu, 16 Mar 2023 17:53:01 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="rj/4Gv1G"; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678989182; 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=hFPx9TUNmTQG74RYarcXKwNrKhnz4iqXeYksYgX+F24=; b=UT8OLnVM6dsqB3Zm+jZSLxUHDvfCB7DAubph0YGnPS47hdWpx/nHQquNIz0GpjxSWjHwhi ksH5dgOpsPuWiyioVTl9LFbsCtromxkBNhj/Mptz+Tum8lsU2w3KONLzstai1H2p2M/LpT xbkwhJm5P450HTPJ0gloDQ2whnm7MGM= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="rj/4Gv1G"; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678989182; a=rsa-sha256; cv=none; b=cLkON7OSir7RIDKCgoYV2bXViymusICXFeVoi4QrJIzYo/LWtQi4JHGudGlTIwMNIaqBGo 3MKkhF9fhfy+DEiAm5szH4w96Nb05uDExsx7m6ZGVY4nxizb+eIEjTVB4ps2U6jsVTz3e4 5dEYbwXTiPTFZfXyBUG9s7zuscH7KOc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hFPx9TUNmTQG74RYarcXKwNrKhnz4iqXeYksYgX+F24=; b=rj/4Gv1GK+hzFTvQLUVmniIiK2 uKg8NvI/KXXTbHaYomzmgaFWtcFSbqMWHZqCUhAGD3OpMUylncQqv2m3NPAz5EWnPlHOaItIGphxr JDdr8SP6jeGCRzIR9aVM6PhHMZCLKyDQZMSq/wyzFYb7nVhCvHjh4KXnSnlW7VYeomkdwIfH0CtzU r5dbYMUrKL3TeVhK/qlfS5xuhHephALmPvHDiKuW3qKsAyUVElwBF0cp9zY2nYHF7z1fHNX2Za/YV mp6ddhoh/M2zs0zHzohBYNXAWG4XLTSMaXuUUSn0oc+ncqcykYR2gT5HHqFlWpvcqlUF9drYd6KZD 1sBqB4+g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pcrmV-00F3N7-0b; Thu, 16 Mar 2023 17:52:51 +0000 Date: Thu, 16 Mar 2023 17:52:50 +0000 From: Matthew Wilcox To: Ryan Roberts Cc: "Yin, Fengwei" , linux-arch@vger.kernel.org, will@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: References: <20230315051444.3229621-1-willy@infradead.org> <20230315051444.3229621-36-willy@infradead.org> <6dd5cdf8-400e-8378-22be-994f0ada5cc2@arm.com> <2fa5a911-8432-2fce-c6e1-de4e592219d8@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2fa5a911-8432-2fce-c6e1-de4e592219d8@arm.com> X-Rspamd-Queue-Id: D2DFD40017 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: h87gr1sdu36u3kmox7xht1n164qp3feh X-HE-Tag: 1678989181-138328 X-HE-Meta: U2FsdGVkX1+xTZ3K5I2eAjnIZJd/xAu9jmw1C3JyfYEFhtC4xy8KokXXvjTwhDxCB+XXnzeP1ys1B0qZUxI7z1puI9fNw86Yn7RzBdRrZPP9DgDb0SEAZaH9y0oMqS/GVdFRweWyABDoS3U2WKnGfxnLyCAUrLBYc34APmkNcf/5uCC0X6XyzN+U7u0LZs7/18eqqvi87AewF/g33BEAcLbCQ2oMfgghDO6GGdZz3pbLe5h9laBG/1oHOiB+YHgFSLDufH7TbqtrK6LRvfITC0K9OP2MOC7ClLCWS5bWlUZLiqaNIMeuaaqPqgmrDhCrxVmgTm6+ZDtclm98tK8UhDqubZfx4F4n6rgLsZjHXDWNR/HMWZnrMPGCPB8cW0IrJupttFdxewjrzYHJrso18lnNsS2PiV+AvqBaJLBfAjN+jBaAgRVF5t/H+BhzMClqSJEWuUfp+uImZHTUk1022F4MwnRJhoTISiMgBer6cjXdutDWE8ebitfyNBydVkwCnzza2o0DC1Q9hdbl8m92fN74wFGBMM5ZoXtBZcqwWyEEqXRgmsl61OGHfiAy3q1HEzuYM7RXLe5EH+9sDqEinWwdC4giPZCqW/a24pdhUJouTvpQpxl7Sd5W4CHx9T+MPjo8D8flueWvvplu51dwrgXkftQH9gXK5ic1qm0jo6g0XwVUKmK3HfAdaA26lmmftf8ZHBqNkFoz9xVygP3S55P1felNitqAlBiNGdN2KqjP/QX9nSykCG22AGjPC3mYvVPmsNxjAKHZi135Lc80E0vN1I/nOupDi5M5vwVDAxiB8/fQjHgebQC5ar2iRNY6aSTV7p79Ez/nnr70YnriTJsHU3jUmhOXhlJdwRYEQh1dFWgcofgYg53gNYn4nV/sOJ2LRVzmepOSCbeh7/5Ad0/gaHUOg0PP/vZM58FJk4CbYd1yQ+qHkUVapNTbrmIigo2ZIfS4miJPFG0M/wM IIN2ZDmJ 280lanGCYMGhiw6YCf1ENQSoL99QNWJoAfw4jsEzU/tZ+zFOUrPrcTKmVKbi0QbPtILk0icVm1PlLSi01m0jfOKjXe0x6CFdAsf63UjxHUkyBw/3jYS3/9zODmTv5A07I5IhtfaGvjnm5dTwMm/sGNj8MrbaZECn0zxFH/LoWOtlNjizAMxj1J2sR5Nq7ovVr3ABVzoSj+WXlWpM= 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 Thu, Mar 16, 2023 at 04:38:58PM +0000, Ryan Roberts wrote: > On 16/03/2023 16:23, Yin, Fengwei wrote: > >> I think you are changing behavior here - is this intentional? Previously this > >> would be evaluated per page, now its evaluated once for the whole range. The > >> intention below is that directly faulted pages are mapped young and prefaulted > >> pages are mapped old. But now a whole range will be mapped the same. > > > > Yes. You are right here. > > > > Look at the prefault and cpu_has_hw_af for ARM64, it looks like we > > can avoid to handle vmf->address == addr specially. It's OK to > > drop prefault and change the logic here a little bit to: > > if (arch_wants_old_prefaulted_pte()) > > entry = pte_mkold(entry); > > else > > entry = pte_sw_mkyong(entry); > > > > It's not necessary to use pte_sw_mkyong for vmf->address == addr > > because HW will set the ACCESS bit in page table entry. > > > > Add Will Deacon in case I missed something here. Thanks. > > I'll defer to Will's response, but not all arm HW supports HW access flag > management. In that case it's done by SW, so I would imagine that by setting > this to old initially, we will get a second fault to set the access bit, which > will slow things down. I wonder if you will need to split this into (up to) 3 > calls to set_ptes()? I don't think we should do that. The limited information I have from various microarchitectures is that the PTEs must differ only in their PFN bits in order to use larger TLB entries. That includes the Accessed bit (or equivalent). So we should mkyoung all the PTEs in the same folio, at least initially. That said, we should still do this conditionally. We'll prefault some other folios too. So I think this should be: bool prefault = (addr > vmf->address) || ((addr + nr) < vmf->address);