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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC9F2CCF9E3 for ; Tue, 11 Nov 2025 09:40:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 352788E0011; Tue, 11 Nov 2025 04:40:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 303268E0002; Tue, 11 Nov 2025 04:40:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F2128E0011; Tue, 11 Nov 2025 04:40:10 -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 058BA8E0002 for ; Tue, 11 Nov 2025 04:40:10 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B761C12D294 for ; Tue, 11 Nov 2025 09:40:09 +0000 (UTC) X-FDA: 84097830138.29.354121E Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf01.hostedemail.com (Postfix) with ESMTP id 030FD4000D for ; Tue, 11 Nov 2025 09:40:07 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GCiWpRgX; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1762854008; 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=yl4+gwf8QOtt9hN7qj5CGIv/iNxBo8//09K9iSurOVQ=; b=rky8MLyuXZ+0OyztyJbxBOnCAcvsmZwGavaqOdRjx0/8Z5P5GkE630aHot35tITXHF1QIw ZJBCPq1486VSJR8rJIpUAMOH26AyHoDAC0zcdtjlSEyWf9zeuhjmsnMrivTAp/Ek4JKJrQ 21qlXV/MlAXfL0ydJlLSV4KF6V/WDQU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GCiWpRgX; spf=pass (imf01.hostedemail.com: domain of rppt@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1762854008; a=rsa-sha256; cv=none; b=5ddyKQf5fWdr4N/4fdO3g/L3DKuRK6Zs8hDKHQecE9SAYF8CoBMK6eQRohoGDclc190NJB CNhu/6zq1KAZJTuR+kaxCCSnAvqqVytlivuaob7N8ocLW7y02WqF8Y/1/fE3FHpkg1g7/I WN7LQ6sYy5P10+08HTbFW+cpUKXPUGw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id EE69B43954; Tue, 11 Nov 2025 09:40:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55E4CC4CEF7; Tue, 11 Nov 2025 09:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762854006; bh=tV63J7taBdyVxD5Onk+zak6F3ctliG+Q3nAMch/i9HU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GCiWpRgXryUr0YiOuRCqFKMHFElrFfOJGLeX13fDzQhzdLeEMfA68uzI2EJFfxVhm 0MUDm4yk8dcgPkbCGQ9mByaYozbzGtDDR+dxx7BYEgVrFiJ8SZ2pdALZBfQboS0gvo mHVFJX+o1gZPTNTphPXA9WbgGYWk9nlExIF62mZ73WXnbIrDTiR4NqRFsQaQL8Dvkw S1IFcQzK7HMyEOdAdOb32M0+zECDPIh+yvtjXasK0QRuj70XQpLdc9540fG5C8LyLy GOdJphkYB7U4gWmOkayWv8GOEYQl0T5F0efMNLKo7WjK4EvGrJauQ6RDtyW294LDmB ZpUDNt59CcokQ== Date: Tue, 11 Nov 2025 11:39:43 +0200 From: Mike Rapoport To: Lorenzo Stoakes Cc: Andrew Morton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Sven Schnelle , Peter Xu , Alexander Viro , Christian Brauner , Jan Kara , Arnd Bergmann , Zi Yan , Baolin Wang , "Liam R . Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Muchun Song , Oscar Salvador , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Axel Rasmussen , Yuanchu Xie , Wei Xu , Kemeng Shi , Kairui Song , Nhat Pham , Baoquan He , Chris Li , SeongJae Park , Matthew Wilcox , Jason Gunthorpe , Leon Romanovsky , Xu Xin , Chengming Zhou , Jann Horn , Miaohe Lin , Naoya Horiguchi , Pedro Falcato , Pasha Tatashin , Rik van Riel , Harry Yoo , Hugh Dickins , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, damon@lists.linux.dev Subject: Re: [PATCH v3 01/16] mm: correctly handle UFFD PTE markers Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam05 X-Rspamd-Que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L8dUiJsG RB1ZPtmnXMRyEdCEGUyd4Anjh+k3dybOdazZpUNpvZ2knUrUvR2ORjIl0IIXBzAkpv0f4Ojp+fFoajRXlEK7RnihyiYwuT9bXTi4VUh1fxLFrWfPM12N0pvYZlNZEqIgcCRaXy7qwEIGtpt7Xvh4RKcJTdmkH8mvCwL0Y/Mm8cWqd2M3XhhdfSAtR/7FzrXqfiQEbTLT35WGtVLnzWVVYBSeJvD3Q/PJNQlvYoIgY72sZG8Qg7Mt6/LvRfa0jMdyhX9N2Shye+8kWwFIynRNvAnl+MWwT2b9J/sCeloIVK40M0Ya6zJkDfieXxwFmoeoq0r53c0sBnGuK/iekyO9DCRQTbnws3Z6WxfPKQRrypNj1QGl9Joj9BGG2NQ== 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 Mon, Nov 10, 2025 at 10:21:19PM +0000, Lorenzo Stoakes wrote: > PTE markers were previously only concerned with UFFD-specific logic - that > is, PTE entries with the UFFD WP marker set or those marked via > UFFDIO_POISON. > > However since the introduction of guard markers in commit > 7c53dfbdb024 ("mm: add PTE_MARKER_GUARD PTE marker"), this has no longer > been the case. > > Issues have been avoided as guard regions are not permitted in conjunction > with UFFD, but it still leaves very confusing logic in place, most notably > the misleading and poorly named pte_none_mostly() and > huge_pte_none_mostly(). > > This predicate returns true for PTE entries that ought to be treated as > none, but only in certain circumstances, and on the assumption we are > dealing with H/W poison markers or UFFD WP markers. > > This patch removes these functions and makes each invocation of these > functions instead explicitly check what it needs to check. > > As part of this effort it introduces is_uffd_pte_marker() to explicitly > determine if a marker in fact is used as part of UFFD or not. > > In the HMM logic we note that the only time we would need to check for a > fault is in the case of a UFFD WP marker, otherwise we simply encounter a > fault error (VM_FAULT_HWPOISON for H/W poisoned marker, VM_FAULT_SIGSEGV > for a guard marker), so only check for the UFFD WP case. > > While we're here we also refactor code to make it easier to understand. > > Reviewed-by: Vlastimil Babka > Signed-off-by: Lorenzo Stoakes Reviewed-by: Mike Rapoport (Microsoft) with a small nit below > --- > > - ret = false; > + /* > + * A race could arise which would result in a softleaf entry such a ^ such as > + * migration entry unexpectedly being present in the PMD, so explicitly > + * check for this and bail out if so. > + */ -- Sincerely yours, Mike.