From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F699606A322 for ; Sat, 5 Dec 2026 06:37:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=E5LkvQks Received: by kanga.kvack.org (Postfix) id C67946B00EF; Sat, 5 Dec 2026 01:37:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C18376B05B1; Sat, 5 Dec 2026 01:37:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B55346B05B2; Sat, 5 Dec 2026 01:37:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9557A6B00EF for ; Sat, 5 Dec 2026 01:37:50 -0500 (EST) Received: from smtpin30.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0E5F5405F4 for ; Sat, 5 Dec 2026 06:37:50 +0000 (UTC) X-FDA: 85508973900.30.25B6DB0 Received: from mta1.migadu.com (out-239.mta1.migadu.com [95.215.58.239]) by imf05.hostedemail.com (Postfix) with ESMTP id D95BD100004 for ; Sat, 5 Dec 2026 06:37:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=E5LkvQks; spf=pass (imf05.hostedemail.com: domain of lance.yang@linux.dev designates 95.215.58.239 as permitted sender) smtp.mailfrom=lance.yang@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796452668; b=WkEMgqgQwnqBqCLa3P+8iECdTB/vuh8o20PDtnDouKJW6IgYFvw/kQoq0jMJsaLVTUhAZe 5t9QdRz+3PZj33/meRPNB7sn94TX+mhZLk64Y6grw27CYh7wDbLRBVbbCBCgRo5sV3I478 tv4/W8UUBK88/xXuVEVLzKkFmS2E15k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796452668; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EzYSrO5jkIRlR07d6Wqfxm/dtlkDvnF3y9DExltp7Es=; b=SDIPzaNGYigP6AInX+HzdPpHD6nuF8dNtaLrqhNGJKeMt5a5gYqqOhB5S1WK6MibcIvzPo kn/i465/QZN81fRpN5v/VUYMn0dltzKWYQQo3nQGYhOACjl+cRT1vq6ywLvsLkq5QSb7ue ZkfQtaHCu6JGhdbtARUZcDSg5w3rrTU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=E5LkvQks; spf=pass (imf05.hostedemail.com: domain of lance.yang@linux.dev designates 95.215.58.239 as permitted sender) smtp.mailfrom=lance.yang@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Envelope-To: linux-mm@kvack.org DKIM-Signature: a=rsa-sha256; bh=DxFEXCtl/9v+zqQvUMTQrBawRWLxj8xPclleJc+QkA0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796452666; v=1; x=1797057466; b=E5LkvQkseNkwlH+XXWop/9176R4f90E1twfjFZR93wo9hdbnYyq4KIJZxZ3hbCWuquECVcXs HQ/qDd5wcqZ00KptBTl1ms175av9ypRHtJBFJwhqukxmqqloHbGwBJVh9y2G/ZxqpogEszIPfdv A83D18mJmKri1Fnh2E8K5Y8s= X-Envelope-To: linux-mm@kvack.org Received: by smtp.migadu.com with ESMTPS id fb1215550b27e3e2; Sat, 05 Dec 2026 06:37:45 +0000 X-Mizu-Trace-ID: fb1215550b27e3e2 X-Migadu-Flow: FLOW_OUT From: Lance Yang To: david@kernel.org Cc: liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, mhocko@suse.com, akpm@linux-foundation.org, mgorman@suse.de, peterz@infradead.org, riel@surriel.com, ying.huang@linux.alibaba.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, gourry@gourry.net, joshua.hahnjy@gmail.com, rakie.kim@sk.com, linux-mm@kvack.org, simon.inizan@arm.com Subject: Re: [PATCH] mm/memory: don't clear the last cpupid in wp_page_reuse() Date: Sat, 5 Dec 2026 14:37:39 +0800 Message-ID: <20261205063739.19315-1-lance.yang@linux.dev> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20261204-wp_reuse_cpupid-v1-1-c56ab5b5d79f@kernel.org> References: <20261204-wp_reuse_cpupid-v1-1-c56ab5b5d79f@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D95BD100004 X-Stat-Signature: 6xqprk6qrmf6dte9mjojc5agrxn17pji X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796452667-334033 X-HE-Meta: U2FsdGVkX19tnfjCjS8pcWyHKIzhuycgVE7EzHidscalCRhA9eeP1BcRuFHzH+rNsSrRWh/M+/ds02SPN2pp5ZGbaMYeQ+zj01XtbQbrPVqjNqVdAYf0N2ifnOrZ8wTIyV1Vxqt8kzyDqenxoiJcH5mwTIpzhnb1yO6wSkIU4fesnNqIqh/d22L8RHH9th2SP9B7oQXpQtGyMBWVNgoSEuyKc+0Mn9G4LS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6qyGaYro4ZeOuX634w4+7ewq1+QECQHz5CMC3WZLCKvGE+eZ9L3PqXhUNJ8czdKOv5nP8cxk9u0vR+rsAHRVIsPiAlOWeExXBET/M5igbusW0sue14w3oD/X07K1ithYpSNxzUtBKilRwLp8y5I2S4aN+Q84ajUn/8hVOWMaEAiDho6YHbgf3CwyGdtknPMP28Z9DxMaQTnJnvtyEditigGFXwGC7+RpssNkWHd4rKjcA+Sxlx3+x5Q0El4jgBTpGVx94rjMw5LFDTPfNTeAsGt7RIe+c91YX4ubwaQuXWT9M8dWbfTv8R9nsgWRIKcCh7xEp1/bfEFOIh6EkcQ/qmI9x3D54NME0w== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Fri, Dec 04, 2026 at 02:29:52PM +0100, David Hildenbrand (Arm) wrote: >NUMA balancing remembers the lower PID bits of the task that last triggered >a NUMA hinting fault on a folio alongside the CPU. > >Since 2013 through commit 8c8a743c5087 ("sched/numa: Use {cpu, pid} to >create task groups for shared faults"), we reset that folio information >when reusing a folio during a write fault. > >That can result in some suboptimal behavior especially for anon folios: > > (a) NUMA balancing records the task+CPU and decides to migrate the folio. > > (b) Migration code maps the folio R/O, and on next write access we > reset that information. > > (c) The next NUMA hinting fault then looks like a first access, > so a single access from another node can be enough to trigger the > NUMA balancing migration machinery again. > >As Simon Inizan reports, that can result in some unexpected folio >migration back and forth between NUMA nodes for some workloads. > >The original reasoning why we added that NUMA-hinting information reset was >that the folio might now belong to an unrelated task. For example, after >fork() a child might reuse an anonymous folio that its parent last >accessed, and we don't want to group both tasks. > >However, since commit dabe1d992414 ("sched/numa: Be more careful about >joining numa groups"), task_numa_group() only groups tasks that share the >MM or that share the folio through a MAP_SHARED mapping, so a stale cpupid >can no longer group tasks that merely shared an anonymous folio after >fork(). > >The child's first NUMA hinting fault might still see the stale information, >such that we treat it as a shared fault and delay migration until a later >fault. CoW-reuse in the child is less common, so it shouldn't move the >needle. If we ever care, we could decide based on whether we likely saw >fork() before, because then we have to set PageAnonExclusive again. > >Further: > > (1) do_huge_pmd_wp_page() doesn't reset that metadata, so our handling > is inconsistent. > (2) there are other valid cases where we run into wp_page_reuse() > without ever involving fork(), where that information is still > perfectly fine. > (3) In the context of pte-mapped THPs where we reuse individual pages, > it doesn't quite make sense. > >So let's just stop resetting that information in wp_page_reuse(). Cool! Also stops wp_page_reuse() from clobbering the page access time of folios on slow memory nodes in memory tiering mode :) >Note that task_numa_group() will now also see accesses from different >tasks that we previously treated as private first accesses, which is how >it is supposed to work. > >While at it, convert the VM_BUG_ON() to a VM_WARN_ON_ONCE(). > >Cc: Simon Inizan >Signed-off-by: David Hildenbrand (Arm) >--- Nice work! Reviewed-by: Lance Yang