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 CCCB0606A322 for ; Sat, 5 Dec 2026 12:32:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=gJ1tiZ8P Received: by kanga.kvack.org (Postfix) id E2BB26B00EF; Sat, 5 Dec 2026 07:32:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB4C46B05B1; Sat, 5 Dec 2026 07:32:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7C936B05B2; Sat, 5 Dec 2026 07:32:04 -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 94DA36B00EF for ; Sat, 5 Dec 2026 07:32:04 -0500 (EST) Received: from smtpin17.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 162A41C3E25 for ; Sat, 5 Dec 2026 12:32:04 +0000 (UTC) X-FDA: 85509866568.17.4734CDA Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf15.hostedemail.com (Postfix) with ESMTP id 3675EA000B for ; Sat, 5 Dec 2026 12:32:02 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20260707 header.b=gJ1tiZ8P; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of azpijr@gmail.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=azpijr@gmail.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796473922; b=2tTyMAwpTfntnybHyBpXgVZsCuV+BUYfoi1QMIeuyOBe7ONG9jHYyu9GcGnoDc/3VosjuL hVmFb9j08hLaGi+3zhJ8mNeOyEIWCj5x84ckFMBQ02wfp83qYXF/qgS+a9YPgqWiK67t+m HQArlDW5NsjH7nPtj1whL4Tg4XSONTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796473922; 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=3A8ucKSun90whVPi6uvAX9uDVwb9T2utJ2/bNQz6MHw=; b=lUP021Y/BfGh3hALiVE2CJgIlUaAyatkDIuVdW61Ark46CjnPa5DqL397ijZb0wnRVD5r9 VgY0OCng41azXyAo3SjquZVBdHHoGgbIi4I+LZPLfLjs2/86gbLeliYu4SVGlWEkA2OKgP q881T1o/Ghl5e7KA0I+89Ir4YTmwCI4= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20260707 header.b=gJ1tiZ8P; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of azpijr@gmail.com designates 209.85.221.47 as permitted sender) smtp.mailfrom=azpijr@gmail.com Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-491846221ffso1598950f8f.3 for ; Sat, 05 Dec 2026 04:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796473921; x=1797078721; darn=kvack.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3A8ucKSun90whVPi6uvAX9uDVwb9T2utJ2/bNQz6MHw=; b=gJ1tiZ8PVs3q5mzsaMJPpuMttGjp2RDfUQYiMUZRDpKkBtxL0vByHsof7xZjRZjxfo jTfwoRRZfqnekxUQMXuwXbJDFAhJz3dwMLwiwmxVtn3OcNJbOdVdoqGA38j2UkJvE8Gc VGTexEm5/PG+C4LVcPlCNRNYqqOPDUEm8mUfjVLOsra69LcjcdfLC8iXzdfFuXkhLY/5 brQ2apT3C5LhtvcXrwQko+vsHX2uP/FUY9LpTHrNzoI5J18LHSfjoLKjizowsOv5Lk6l TMRJ8LsX1kpMAvRJlenQPX0jg/slmYg7itmkOgxuT0pMcmhAKPoRiNltmh5+MXY1FJse qy0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796473921; x=1797078721; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3A8ucKSun90whVPi6uvAX9uDVwb9T2utJ2/bNQz6MHw=; b=ZXx2WAoBk21dXIdre8OpRrMayla9UWH0mvgZ0/RNb+0wD2e/qUioJBBvIfD/Wzb2BG GtOQZFyFbURD5Gu/+bC/B6Pf/lyq0iflxFurCfDNrToupanDxZXyHLl+lLu0r8MzO8yE Oo2yVBrevmBqN2a8BKjBSiLj+mKXshAv5f/cHTJYIOrcllEH6u2Wj1g2oAFMh2w6TQ0i ZnHJqDHC285d1kpFYfQz9N/JuEhqCs0PnWBW911+8QpGnl7R9aVZWSdrGUqKLor/Txlp Tkwcntk+39dRMhvb+BMdOP2A1ewOIuttLQNRsVqNrfcKUk/XYrGs3BI58DULt7F8XBzo +ohg== X-Gm-Message-State: AB4q+uFk5ME+yKRdnwrGKH7FbVkyGoTsZ9RyWP0AEtcoCIKwy7CetJz/ +/1mnZdwcat/wPjJeRipAj3CMSsDqnEMzr4dd/ZQkXJVoUGHJy+Yf983 X-Gm-Gg: AZFdTZe4JfGqxvxb2fXNRg026yu+UzWHj8nX5wDiKRUvm1Kib7fnoAZftN4D1AX8es2 9gNwDmbIPLq0LUz7nGlkM2xYAJqS8QZdxcCmM3u7TljfKl8PNUbcxrfJFQV3AaJkXIiMSfl1q9y S0QdzMB8H3NXktAL3KZ+sDv5qqzu8oclNjLLOxVtqhNxU9krtM+uxMM2XqxxM2ZwsYyz7yFffL+ 1/mz6w5wCu8k+8xOxb5iYV1LRsOlMsEuZwWcfoSP3w5y3EyzZcc7hqXD4ALEWnCi+wo74TAuZbq 04bbOZOq4tv9ubTCUqDnhD+cZ2VrjSkgRqLnO9dDEReOgDT10dZKPJimkB4FDnppUbunDwmkz9Y S5lnu8eQJOd2jcBSByHwENpU5lfv1zw1qNLM29jOvbQFdcwCfYuzqlAVKHpd3DHRCtHaFOPw1sT tRiJZcom4H3EWt3PKq5q+qE8TQ6MORL8/UAHCj90QSrrwo8vD6LA2IhK0b5jHUfn5ZXTIpsJx8l Hf3TC10X6hesir+dDqvTpAfpt4y1d0Kb+KEGnhCqy4TMpkQskZWF6NPeqqWB2vY1k9T/0xW7u1s 4GjWROd7zmd09RXfdQqXFFviacF1ByNjUY2voZuFrRIkI1Rj7jtLj+0LBZklETJU2VYlCOajkuk N X-Received: by 2002:a05:6000:1866:b0:4a7:c7bb:5291 with SMTP id ffacd0b85a97d-4d1e89e5bc9mr9126180f8f.19.1796473920706; Sat, 05 Dec 2026 04:32:00 -0800 (PST) Received: from [192.168.1.22] ([83.231.69.9]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4d173ab8e3fsm11611503f8f.42.2026.12.05.04.31.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 05 Dec 2026 04:31:59 -0800 (PST) Message-ID: <09c07ddd-36bf-483b-bb98-7adaf856e1c8@gmail.com> Date: Sat, 5 Dec 2026 13:31:58 +0100 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/memory: don't clear the last cpupid in wp_page_reuse() To: "David Hildenbrand (Arm)" , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Michal Hocko , Andrew Morton , Mel Gorman , Peter Zijlstra , Rik van Riel , Ying Huang , Zi Yan , Baolin Wang , Gregory Price , Joshua Hahn , Rakie Kim Cc: linux-mm@kvack.org, Simon Inizan References: <20261204-wp_reuse_cpupid-v1-1-c56ab5b5d79f@kernel.org> Content-Language: en-US From: "Jose A. Perez de Azpillaga" In-Reply-To: <20261204-wp_reuse_cpupid-v1-1-c56ab5b5d79f@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspam-User: X-Stat-Signature: nnkii7mmi16xfb9oqr7bzmph9adn3dp1 X-Spam-Status: No, score=-9.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Queue-Id: 3675EA000B X-HE-Tag: 1796473922-592448 X-HE-Meta: U2FsdGVkX1/iDe6VitaoNxaNVGgG0WKZJEqJ+Fb+Y+AqT+8oXNfgGmWD1c9hwUvnKZEiy0NkQguUTUBGGkn/1QngFVAc7rVDLzwZ5v5ZJGITUf2EySWMzCeQFzOaC2JA7Ct4bGwKgoZgA3TnqHl0tYN6adnbaCiF+mENTQqipNNdzGWboGgobwgEyTwg70HSdqlUHYXhOXaITli/zHoRDyraKeJWOhwTnGWmCGNZDw9awrtfbdmWQprYxLWWjg0jHev5hbGSoTfIXH/CDjZCYNBNJbbztm2yTVIe4Ft+mofwRTxQUCkr3Ptq/5modSJINkJQLoSaD6PmLmnKW7VxclzifyofcuZeI0Ua7oXU6J48y2vHsnEnn5YlyPOsqC1/pKlAZBrfBoDhPf/CFuxbpNuf5mxx5ERNfwPbeQ6AwxJpW/M5gGUTTneibmBpr4dRReJALdE9vQX9RC/7wrxykQuBp7h9YlQdzPhdM8ojFwj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L66bfMmsEaMTeUpFxduHgDrYlY5tFA2cB0j5DLPucvh7JuSG5bLYdDQXuOTBFuUa8gsUWX1eQgKi9V87PVkYhkMkEaqbPXfz4pWLZlcs0pwMyXpyHP+a5X7Y3NFG2N8Bn/dF/PzE8/Q/5B0qm+yf1xKb16L6xFRLf+EJMTnQ5X8NiiQFfber7psB0sPMADNm8FK3ZN3dB5rKQcAhE/EcSZiD33v9Wz36J5wogwWAcmvxbhDY/eKH1+jSZGnEWLLtH+vdsw+KulPuDFAV7y9LvjbrwlUIdKyrBysDR7YtSyf2dlT7QaewzAPm7AVctblU7 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 12/4/26 2:29 PM, 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(). > > 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) > --- > Hi, > > this was reported internally; I don't really consider it a BUG, so > no Fixes. > > This resolves the issue with repeated migration back and forth that > Simon was seeing. > > I don't really know which benchmarks to run where we could see a > regression through this change. Migration might now be delayed until a > later NUMA hinting fault when a child reuses a folio after fork(), but I > don't expect that to matter in practice. > > I'd assume most performance-sensitive workloads will use plenty of > PMD-mapped THPs where the behavior was always like that. > > So in the end this just makes the handling consistent. LGTM: Reviewed-by: Jose A. Perez de Azpillaga -- cheers, jose a. p-a