Skip to content

Numabalance 流程代码#6

Draft
jackYoung0915 wants to merge 2 commits into
masterfrom
cursor/numabalance-2afa
Draft

Numabalance 流程代码#6
jackYoung0915 wants to merge 2 commits into
masterfrom
cursor/numabalance-2afa

Conversation

@jackYoung0915
Copy link
Copy Markdown
Owner

Create a comprehensive analysis document for the Linux kernel's NUMA Balancing flow.

This document provides a deep dive into the NUMA balancing mechanism, detailing its five-stage process (periodic scan, PTE marking, NUMA hint fault handling, fault statistics, and task migration), core data structures, NUMA Group coordination, adaptive scan period adjustment, and Memory Tiering support.


Open in Cursor Open in Web

Detailed code-level analysis of the Linux kernel's Automatic NUMA
Balancing mechanism, covering:

- Overall architecture and data flow
- Core data structures (task_struct, mm_struct, vma_numab_state, numa_group)
- Periodic scan triggering (task_tick_numa)
- VMA scanning and PTE marking (task_numa_work / change_prot_numa)
- NUMA hint fault handling (do_numa_page / numa_migrate_check)
- Fault statistics and placement decisions (task_numa_fault / task_numa_placement)
- Task migration execution (task_numa_migrate / task_numa_compare)
- NUMA Group mechanism for shared memory workloads
- Adaptive scan period adjustment (update_task_scan_period)
- Memory migration decision (should_numa_migrate_memory with two-stage filter)
- Memory Tiering support (NUMA_BALANCING_MEMORY_TIERING)
- Key sysctl parameters reference
- Complete flow diagrams

Co-authored-by: Slim6882 <jackYoung0915@users.noreply.github.com>
@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 12, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Root cause analysis for why programs configured to use remote NUMA
node memory may see uneven distribution:

1. MPOL_BIND vs MPOL_INTERLEAVE confusion (BIND follows zonelist order)
2. NUMA Balancing auto-migrating pages back to local node (MPOL_F_MORON)
3. THP allocation bias toward local node
4. Zonelist fallback ordering in buddy allocator
5. Kernel internal allocations ignoring user mempolicy
6. First-touch allocation before mempolicy is set

Includes diagnostic methods (numastat, numa_maps, vmstat),
correct usage examples with code, and a decision tree for
choosing the right memory policy.

Co-authored-by: Slim6882 <jackYoung0915@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants