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 06BCFC021B8 for ; Wed, 26 Feb 2025 16:28:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9700B28000B; Wed, 26 Feb 2025 11:28:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 91F1328000A; Wed, 26 Feb 2025 11:28:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80E8A28000B; Wed, 26 Feb 2025 11:28:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5B55B28000A for ; Wed, 26 Feb 2025 11:28:21 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1FC26161C5C for ; Wed, 26 Feb 2025 16:28:21 +0000 (UTC) X-FDA: 83162628402.25.CF8D2C7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf11.hostedemail.com (Postfix) with ESMTP id 4591640003 for ; Wed, 26 Feb 2025 16:28:19 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=o8FrW8zE; dmarc=none; spf=none (imf11.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=1740587299; a=rsa-sha256; cv=none; b=jkQ2cwSJYwgbNugpSgnCoQ4TXqtwWb//WGZn5B4pNmDeoH4fbwtXp4cq5K/tC8pdqmsGli 8QQ0XY0c9F2mqBWdFcTJdzR2Phdet2tJd2/Q5JEQOAApoAgnKmDO+RUaGmPYtzvx0wEwZe gWN94uaP7UM+LOkB/n8b4mz5n83Wt5c= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=o8FrW8zE; dmarc=none; spf=none (imf11.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=1740587299; 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=4RmUbpiZrPYzsk4xFenBE/pyKt10j/v0QGOy+nm2ZO0=; b=NcGSignEnPT67CH+CoBKat2a1RnBs0TilPBKhL6oYEbEc6iPQ24HXfutoYuL43FTHUX9cZ nrUoz8d+N7e7VmUtMmX5k0a140v/iNLG9KWsiA5zhy63Mk9SDgme/1oDj4UqN5TM5bBE2+ 4hrogW7z29C5hG6Ao5IbksCc/eHSC5o= 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=4RmUbpiZrPYzsk4xFenBE/pyKt10j/v0QGOy+nm2ZO0=; b=o8FrW8zE8bGYGDdg7xo7Qyk7OI gfB4DGIvFjlHlatRVJjFyihgwvj3lLUR+Jx9pG2RB9Xukf5r13j4BaW6Q4dYqwYvK/Ru3xbT/ABku 0EIHZZT7ZVxNsuHnliwSShaVuxknQMUXF/9SSGwxlcNNxNH4pKKoKAWjWbQ4EVdLcugnAbAwLroxe 67hHiaYqYkN8uyTExhXN6wMnu/zwE324JT5yvclKZkUFAVtF85hs3Zrk/wEaha3z/IdRSnLx7shqt wQ9OyxHXYfOG8k5Gr+HtRyVDR+GIsDaxhpHTHxYAYz5jZfKNYWauHzfsEb8nC4zb+47dRARQAtqAu eSpyro6Q==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tnKGb-0000000Fv81-0qEB; Wed, 26 Feb 2025 16:28:13 +0000 Date: Wed, 26 Feb 2025 16:28:13 +0000 From: Matthew Wilcox To: David Hildenbrand Cc: Brian Geffon , Andrew Morton , Zi Yan , Kefeng Wang , Suren Baghdasaryan , linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Baolin Wang , Hugh Dickins , Marek Maslanka Subject: Re: [PATCH] mm: fix finish_fault() handling for large folios Message-ID: References: <20250226114815.758217-1-bgeffon@google.com> <121abab9-5090-486b-a3af-776a9cae04fb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <121abab9-5090-486b-a3af-776a9cae04fb@redhat.com> X-Rspam-User: X-Rspamd-Queue-Id: 4591640003 X-Rspamd-Server: rspam12 X-Stat-Signature: yhfhq837fqfsst94o6brbc5q7nbje93z X-HE-Tag: 1740587299-170171 X-HE-Meta: U2FsdGVkX1+TMiN3AYvIAmtaRnZJYlhRB6usvHDqf/hr+P40sxi4TKp1qWvO3M8ZbtiT8ZKviRRHQb2HscVH8wZbTSrMvHKFRdPHz0JkZuxUZCmPaxL2XL1OIwLBARgZW9OBGj4+fdL677BZ3PEXgXYC9TgAP7mD7srqAobDxAronYH0X6h/iWl6HjPu0VCKCm8S4iYPTR4PKs4ZdfduWlPsrJWC252ybtDlx1iS+lug73wg/k9ZfknR7xRVOC3CVkLNyJoUnoIuyYu4ok9wC9VVCvAJyqm55XWEwkJR7A/2cgzqsupLT+sTCpjLGoFe41VDlh4gBHPGOpi/nvrrXfCfZd0QKX7tknySweGHKvRe6KZC1IRVkrkcsjhOeo/I52Udk5L9LFqpWIw93RsY/8SjD0rktmGCoz/KxL0qwqhYXaoR+Aa6xJmelzZKvLrEcRplRe9ooeY4LTQLdvvuA4aEIla0Jpf40ebYCahbSxOzRxIPkSQz9rr60oP1dpUCmL09hZ6OENbT7v8/cSA3XLt+45u6QQyhvrzOV6pUB7XkUyOzs4L7zLgnuAhSYz6cDOxC8wzIP5+VSqsf5j5COJmWp0LrNm2wfCSVAdHNqTQZihqLpj52dCbBSe1EyIjz1RNkVwzp+h6+Nn90TPobaSVRRgYx0Qb9eU5AABQJwSJ70nNHXiYB+56djVxtAF8jt2HbXFwGEfAVOZnAjSfy4c3TqLpNvJD9Nd+3BvOWWz48wLBWzhCkezF9qJjFphsYTsVzNNPyIMv0khITRQrbuaJhUH54AFevqrhEFBnENIQ7CONFNs0fnQWJSNjB9St2JSd4KBnb3PdK/k+3X03VjvNVAxVZrYVfEidxqVS61hpHJU6+YPoK1ocPNcO3eX29EeTKpF14MRvF56HP2b8XJI110I7UBnSXNGyubIjv1CkAeS4GfJUd6cLgtTu1WFiYxY5oy0tHwhg5anERDNe SPzfroJc /nH/wqTPSlCm3+JULMFzscm4QS04r2IWIdnVLF6moZOv66mVLnAuqebM72bm1CZNld6Aupo4Bbu1t1QUBMWpuVihQ7HffRFPIG+ji1oYHGbjQhnnK/9rvABBerQBRrCIgD3B7rSzO9TkYH2wbsthTr7zyRaPRo1E4rcdqpiiqgk0g4LH+qDz7LW4s4QEGhViYVuxsWNFcQRzEbakgxIrlHwyvrd7YvjlJHFkKWXVV9todYx7xZ1qfw3G2pg3aQ38fS4yk4+XjcpDQMJvFLnXYwO+4Jw== 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: List-Subscribe: List-Unsubscribe: On Wed, Feb 26, 2025 at 04:42:46PM +0100, David Hildenbrand wrote: > On 26.02.25 15:03, Matthew Wilcox wrote: > > On Wed, Feb 26, 2025 at 06:48:15AM -0500, Brian Geffon wrote: > > > When handling faults for anon shmem finish_fault() will attempt to install > > > ptes for the entire folio. Unfortunately if it encounters a single > > > non-pte_none entry in that range it will bail, even if the pte that > > > triggered the fault is still pte_none. When this situation happens the > > > fault will be retried endlessly never making forward progress. > > > > > > This patch fixes this behavior and if it detects that a pte in the range > > > is not pte_none it will fall back to setting just the pte for the > > > address that triggered the fault. > > > > Surely there's a similar problem in do_anonymous_page()? > > I recall we handle it in there correctly the last time I stared at it. > > We check pte_none to decide which folio size we can allocate (including > basing the decision on other factors like VMA etc), and after retaking the > PTL, we recheck vmf_pte_changed / pte_range_none() to make sure there were > no races. Ah, so then we'll retry and allocate a folio of the right size the next time? Rather than the shmem case where the folio is already allocated and we can't change that?