From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DB8C3EBF08; Tue, 14 Apr 2026 14:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776176654; cv=none; b=qETygD8hU8JVH6GbZalnww+wSVN4xH+ktorpBVKJxrWSW94L7mBLHKl0vTgqwSLLf38JeOs31D6yq4ucqO1Zw2LSObT8T/7b7TXzOstNsOML/G139xA/y27WTXXvm1Xkp5Dsjtg/d28BnRM+hUi6bGMIEA3WOfDrN01iXiF7heA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776176654; c=relaxed/simple; bh=oOUfU0VXNyHpbUZg2Wz9Ad/eUIXrqX/a1NFbEQbuFDs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OwlddiS9kqLK4XQKxLFWFE+2R5URqxZDz+w3unrW9Q+THs+ZyT+x4xbt+gQFghrPcy/H3NkroGIN+PLxbvyQKnt4KPBoHOuf/IQtBU9jm5OD28LFKd6wfkDYu8+tZenhyGopTdgZc6zUXVI6jHGMTX/+unUF43Cl3EqtwBFL3Ps= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pvgJbxdT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pvgJbxdT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 729E4C19425; Tue, 14 Apr 2026 14:24:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776176654; bh=oOUfU0VXNyHpbUZg2Wz9Ad/eUIXrqX/a1NFbEQbuFDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pvgJbxdTr0RDMrC3+VgX2thE+rIGjtvnDb3enwSjLfMXMuVopngsjPo4ZiBxtCxwx zsJhdIncow0aTyL63tGjwnR5YTWcV1gopC6pQgfB8BintsS9xTXQwZOen5K3tPWOyF mW3BKMzJOCASL5UsyxhzU869et0u7Xh80dj0PDVPTJwy9HIWvoKWysNUOn/GmhSkru /GaIL8KoBJQEsJYKXdmHWyFGjZcwtu5KXT9N3dE6k7cwYPPiTprjLXIcFeahZZHkS2 81PF5La9qAT7ifZOQp8xRHIdBe8TaH/AUOoxqBKtK9IOwCeMVidRpsEG7U5LfGz2JJ lWy7Oeqoj9gwQ== Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfauth.phl.internal (Postfix) with ESMTP id 9EB9DF40068; Tue, 14 Apr 2026 10:24:12 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Tue, 14 Apr 2026 10:24:12 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdegudefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpedfmfhirhihlhcu ufhhuhhtshgvmhgruhculdfovghtrgdmfdcuoehkrghssehkvghrnhgvlhdrohhrgheqne cuggftrfgrthhtvghrnhephfdujeefvdegkefffedvkeehkeekueevfedtleehgeetlefg feevveeukefhtdetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepkhhirhhilhhlodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqddu ieduudeivdeiheehqddvkeeggeegjedvkedqkhgrsheppehkvghrnhgvlhdrohhrghessh hhuhhtvghmohhvrdhnrghmvgdpnhgspghrtghpthhtohepudelpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopegrkhhpmheslhhinhhugidqfhhouhhnuggrthhiohhnrdhorh hgpdhrtghpthhtohepphgvthgvrhigsehrvgguhhgrthdrtghomhdprhgtphhtthhopegu rghvihgusehkvghrnhgvlhdrohhrghdprhgtphhtthhopehljhhssehkvghrnhgvlhdroh hrghdprhgtphhtthhopehrphhptheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepshhu rhgvnhgssehgohhoghhlvgdrtghomhdprhgtphhtthhopehvsggrsghkrgeskhgvrhhnvg hlrdhorhhgpdhrtghpthhtoheplhhirghmrdhhohiflhgvthhtsehorhgrtghlvgdrtgho mhdprhgtphhtthhopeiiihihsehnvhhiughirgdrtghomh X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 14 Apr 2026 10:24:11 -0400 (EDT) From: "Kiryl Shutsemau (Meta)" To: Andrew Morton Cc: Peter Xu , David Hildenbrand , Lorenzo Stoakes , Mike Rapoport , Suren Baghdasaryan , Vlastimil Babka , "Liam R . Howlett" , Zi Yan , Jonathan Corbet , Shuah Khan , Sean Christopherson , Paolo Bonzini , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, "Kiryl Shutsemau (Meta)" Subject: [RFC, PATCH 09/12] mm/pagemap: add PAGE_IS_UFFD_DEACTIVATED to PAGEMAP_SCAN Date: Tue, 14 Apr 2026 15:23:43 +0100 Message-ID: <20260414142354.1465950-10-kas@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260414142354.1465950-1-kas@kernel.org> References: <20260414142354.1465950-1-kas@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Report deactivated anonymous pages in PAGEMAP_SCAN results. Only set on anonymous VMAs (shmem cold = !PAGE_IS_PRESENT). Both PTE and PMD (THP) levels handled. Signed-off-by: Kiryl Shutsemau (Meta) Assisted-by: Claude:claude-opus-4-6 --- fs/proc/task_mmu.c | 11 ++++++++++- include/uapi/linux/fs.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index e091931d7ca1..fc42cfd5720a 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -2329,7 +2329,7 @@ static int pagemap_release(struct inode *inode, struct file *file) PAGE_IS_FILE | PAGE_IS_PRESENT | \ PAGE_IS_SWAPPED | PAGE_IS_PFNZERO | \ PAGE_IS_HUGE | PAGE_IS_SOFT_DIRTY | \ - PAGE_IS_GUARD) + PAGE_IS_GUARD | PAGE_IS_UFFD_DEACTIVATED) #define PM_SCAN_FLAGS (PM_SCAN_WP_MATCHING | PM_SCAN_CHECK_WPASYNC) struct pagemap_scan_private { @@ -2354,6 +2354,10 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p, categories = PAGE_IS_PRESENT; + if (pte_protnone(pte) && vma_is_accessible(vma) && + vma_is_anonymous(vma) && userfaultfd_minor(vma)) + categories |= PAGE_IS_UFFD_DEACTIVATED; + if (!pte_uffd_wp(pte)) categories |= PAGE_IS_WRITTEN; @@ -2422,6 +2426,11 @@ static unsigned long pagemap_thp_category(struct pagemap_scan_private *p, struct page *page; categories |= PAGE_IS_PRESENT; + + if (pmd_protnone(pmd) && vma_is_accessible(vma) && + vma_is_anonymous(vma) && userfaultfd_minor(vma)) + categories |= PAGE_IS_UFFD_DEACTIVATED; + if (!pmd_uffd_wp(pmd)) categories |= PAGE_IS_WRITTEN; diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 70b2b661f42c..af5b28901800 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -455,6 +455,7 @@ typedef int __bitwise __kernel_rwf_t; #define PAGE_IS_HUGE (1 << 6) #define PAGE_IS_SOFT_DIRTY (1 << 7) #define PAGE_IS_GUARD (1 << 8) +#define PAGE_IS_UFFD_DEACTIVATED (1 << 9) /* * struct page_region - Page region with flags -- 2.51.2