freenode
Kernel & Low-Level

Linux MM series lets folios linger on per-CPU batches

Hugh Dickins's 26-patch rework drops most lru_add_drain calls after years of attempts, aiming to ease lruvec contention and watchdog stalls.

Hugh Dickins has posted a 26-patch series for the Linux memory management subsystem that lets folios remain on per-CPU batches with the LRU flag set and no extra reference held, matching their state on a real LRU. The change removes most calls to the local and global drain helpers that have long forced those batches onto the lists before other code could safely touch the pages.

The work was prompted by the global drain showing up in watchdog backtraces: not as the fault itself, but blocked waiting for an unresponsive CPU to run its workqueue item. That all-CPU drain is heavyweight. Even the lighter local drain can worsen the lruvec lock contention that per-CPU batches exist to reduce.

With batched folios treated as isolatable LRU residents, many paths no longer need to drain first. The series strips drains from compaction, transparent huge page collapse, KSM, memfd pin waiting, page migration including mbind and move_pages, CMA contiguous allocation, block device invalidation, drop_caches, s390 UV folio splitting, and related helpers. A few drains stay where reclaim truly needs pages on an actual LRU, or where bulk operations want fresh stats pushed promptly. LRU cache disable around migration is narrowed as well, kept mainly where memory hot-remove must scrub stale batch pointers.

No new locking appears. The design reuses accepted speculative folio references, try-get and clear-LRU tests against the add batch, and cmpxchg on spare pointer bits. Dickins presents the series chiefly as a developer cleanup that should make life easier, while expecting mixed performance: some loads better, some possibly worse. He is offline for three weeks and released the work early so others can shepherd it toward 7.4 if the direction is welcome; otherwise he can resume for 7.5.