From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.188 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796557131; b=PScnQ+WK+Oc+E4mHT5pBWnTzBFLMb+KNI7WoffW0ekfCq81DVh0ic3iCXjfz4yZsEMLT Hsdf3WAnsjlCPwYy5PFvvRwERGfG6yjjJ/H15te0igEc4FndTwnOeij1nfAqEnaU+wsL7 c568IFcbCQlvHzMfNNT1HHEzx4ESx/NhatG6zkGJerO+wxmNDwYWyt+9owoKoiVLxVr44 YAYYzw9rZ8wgWddztw5ZzF+kwycWRYThu2oaFbCSRHPqONuN9/ByUcOZVTrabU1jU0CpH /LyYEtVaYmjx5pWEunOoh3qbanAnzV8kHqWy/xOMUe8bt1UMDHoTBkAFhCtwX5uWRrQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796557131; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Subject:Date:Message-Id: MIME-Version:Content-Type:Content-Transfer-Encoding:X-B4-Tracking:To: Cc:X-Mailer; bh=YS1evtXL3xBMMj+WXEbCHu02RxmkZTyVHliDYPaBUpI=; b=A44bvVD41d1xbFSepf0YJXk0TQH2lhyLV6ccQFjQfMaiAuKaVSjTnEkWJS0aigm8qoPk UTZ5G/4Vpr8THZ9R5ZzL9hlh9kAzydfhyRkTz38HGlzp1/I1H80tfIguYWllb5+Kc2fpX kZiXVHqEUJrWvLXHI0pXS4Pu9P9peaBTbM+5RrtDAt6kbiQoKqvwvjUEfPYjbk0SzjDCW 1IDxf2d+NTxxMtvrjdtUquklCUMypD4zf4Le/vv40k0otHDSRSsps4W/dGdekVWvlNBkD TR6ciVDh0dsD3wv1xdGXu5zDUImWIETG+aKjMgt7NdMWz6NyHG7HPQLE9y+NovuH15Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=sPeb1soR; arc=none smtp.remote-ip=91.218.175.188 Received: from mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACCC4606A33F for ; Sun, 6 Dec 2026 11:38:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ACCC4606A33F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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=sPeb1soR X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=ze8a8We7eFl4LSH9eWauSsj2Dj+C7kXvcvloAH4MJWs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796557126; v=1; x=1797161926; b=sPeb1soRToyRmjttMfbyInL2Upfxv128uPejYX7RDHcT0FCkCpGKpxqIGNiGnLKngxdvq9i2 70/GygoF/PPBLSsxdHKBpYdH/2h/tC3s+nWFRto8dwtwEEsptEp5yE037PZBiEQ8nr5/JuQxO1A HeFW7nje2zD7tTp+hjrxVkF8= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 661171ca58590d01; Sun, 06 Dec 2026 11:38:46 +0000 X-Mizu-Trace-ID: 661171ca58590d01 X-Migadu-Flow: FLOW_OUT From: Qiliang Yuan Subject: [PATCH 0/8] sched/numa: Placement signal for memory that NUMA balancing cannot migrate Date: Sun, 06 Dec 2026 06:38:37 -0500 Message-Id: <20261206-feat-numab-series-v1-0-2af21ad24718@linux.dev> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAD1JFWsC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIzNDIwND3bTUxBLdvNLcxCRdiFZdU7MkSxPjtDQjgzRTJaC+gqLUtMwKsJn RsbW1ANEuVbtjAAAA To: Peter Zijlstra , Ingo Molnar , Juri Lelli , Vincent Guittot , Mel Gorman , K Prateek Nayak , David Hildenbrand , Andrew Morton Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Valentin Schneider , Zi Yan , Gregory Price , Ying Huang , Kefeng Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qiliang Yuan X-Mailer: b4 0.13.0 NUMA balancing finds out where the memory of a task lives through hinting faults, so it has nothing to go on for memory it never makes fault: DMA pinned folios (VFIO, RDMA, io_uring registered buffers), hugetlb pages and DAX mappings. A task working on such memory gets no preferred node from it, and the load balancer moves it wherever CPUs are idle, often to the other package, where every access stays remote because the memory cannot follow. This matters most on machines with several NUMA nodes per package, where every die has its own memory controller (SLIT 10/15/25/27 for 2 packages of 4 dies), and for workloads that pin or use hugetlb memory by design: VMs with hugetlb and VFIO, RDMA and io_uring users, DAX. Patches 1-4 sample the accessed bits of such memory from task_numa_work() instead of making it fault: no hinting PTE is installed and nothing is migrated, which keeps the reason for commit 03aa8e4f2732 ("mm: mprotect: always skip dma pinned folio in prot_numa_skip()"), and the accessed pages are accounted as faults on their node. Secondary MMUs are tested, not cleared. Patches 5-7 record when most faults of a task hit memory that cannot move, and keep such tasks inside the lowest NUMA domain around their preferred node, in NUMA placement and in load balancing alike; within that domain they are still spread as usual. Patch 8 shares the samples between the threads of a process, so that all of them get the signal and the protection, not only the one that ran the scan. Tested in a VM with 2 packages of 4 nodes (8 vCPUs and 4 LLCs per node, SLIT 10/15/25/27, guest memory on host huge pages), all numbers from one run alternating the kernels. Single tasks copying within 3-4 GiB of pinned, hugetlb or DAX memory on another node (patches 1-3) settle on it in every run, and the slowest of 6-9 runs copies 43-52% faster. A nested guest copying in the part of its hugetlb memory on the other package follows it there in every run and copies 35% faster (patch 4). Patches 5-7 act only on threads that have samples of their own, so in multi-threaded processes their effect shows together with patch 8. For processes where each thread pins 1 GiB on node 0 or maps it from hugetlb and times 2^20 dependent loads through it starting from node 4, the table compares mainline with the whole series: median (range) of per-thread means over 3 alternating rounds of 25 s, cache-aware scheduling off; "worst" is the slowest thread. Copy loops over the same memory, bound by bandwidth, change by -14% to +0%, and hackbench with 16 groups takes 0.957 s against 0.959 s. With cache-aware scheduling on, the medians change by -34%, -38%, -9% and -26% and the worst threads by -49%, -36%, -43% and -42%, with 92-95% of run time on the package: before after median worst on package (%) threads chase (ms) chase (ms) change change before after pinned 4 211 (111-229) 122 (117-130) -42% -43% 31 96 pinned 8 212 (122-231) 142 (131-149) -33% -35% 41 94 hugetlb 4 126 (115-222) 115 (113-125) -9% -44% 62 96 hugetlb 8 132 (116-223) 124 (116-130) -6% -42% 61 92 Cache-aware scheduling (CONFIG_SCHED_CACHE) aggregates the threads of a process in one LLC by their CPU time and steps aside for processes whose footprint exceeds the LLC; this series is about which node holds DRAM the task uses, typically gigabytes. They meet in can_migrate_task(), where migrate_strands_memory() is checked before migrate_degrades_llc(). Tried and dropped: - Packing such tasks onto the memory node by allowing an imbalance up to imb_numa_nr instead of NUMA_IMBALANCE_MIN. On top of this series it leaves pointer chasing within 2% and makes copy loops 10-19% slower. - Clearing accessed bits of secondary MMUs instead of testing them: the same placement and copy times (133 ms against 134 ms) when the L1 memory is backed by huge pages, but with a 4K-backed L1 copy rounds of about 285 ms in the L2 guest took 406-841 ms every 2.5-4.8 s. - Device memory mappings (VM_IO/VM_PFNMAP, e.g. VFIO BARs) through a new vm_operations_struct callback: implemented, not pursued. Limitations: - Measured in VMs only, on an AMD host; same-package remote latency there is 5-13% over local. - Threads that share pinned memory cannot be told apart, so the samples are split evenly: when each thread uses memory on a different node, every thread gets the same mixed signal. Signed-off-by: Qiliang Yuan --- Qiliang Yuan (8): sched/numa: Sample the accessed bits of pinned memory sched/numa: Cover hugetlb mappings with accessed-bit sampling sched/numa: Extend accessed-bit sampling to DAX mappings mm/mempolicy: consult secondary MMUs when sampling accessed bits sched/numa: Track whether the memory of a task can follow it sched/numa: Keep tasks near memory that cannot follow them sched/fair: Avoid pulling tasks away from memory that cannot follow them sched/numa: Share sampled accesses between the threads of a process include/linux/mm.h | 3 + include/linux/mm_types.h | 10 ++ include/linux/sched.h | 11 ++ include/linux/sched/numa_balancing.h | 1 + kernel/fork.c | 7 ++ kernel/sched/fair.c | 218 ++++++++++++++++++++++++++++++++++- mm/mempolicy.c | 154 +++++++++++++++++++++++++ 7 files changed, 400 insertions(+), 4 deletions(-) --- base-commit: 19cc08c1a6a650f8e54c0461ff198be6448f425d change-id: 20261201-feat-numab-series-56b943ff20f5 Best regards, -- Qiliang Yuan