move_pages() on Linux increadibly slow [closed]

14 hours ago 2
ARTICLE AD BOX

What’s happening is that move_pages() moves 4 KB pages one at a time. Each move needs memory copying, page locks, and TLB shootdowns, and if the pages are being touched it may have to wait or retry. The real bottleneck is NUMA memory traffic and kernel locking, not CPU, so it runs for minutes while the CPU looks idle.

The fix is to avoid migrating if possible: allocate memory on the right NUMA node from the start (mbind / set_mempolicy). If you must migrate, use huge pages, and make sure the memory isn’t being accessed during the move. move_pages() just isn’t meant for fast bulk migration of hot memory

Read Entire Article