v4
2026-11-04
休眠 swap 槽不进入 swap cache · v4
重构 swap 缓存与休眠槽:仅允许换出槽进入 swap cache,并为休眠槽引入独立 swap table 类型。
原始补丁链接
子 Patch(3)
1/3
mm, swap: only allow swapped-out slots into the swap cache
让 __swap_cache_add_check() 要求 shadow entry,拒绝 SWP_TB_BAD 等非换出槽;否则 cluster readahead 会把坏槽当 COUNT_MAX,分配 folio 并发设备 I/O,覆盖坏标记。
2/3
mm, swap: give hibernation swap slots their own swap table entry type
为休眠槽新增独立 swap table 类型(bit4 及以上置位、count 为 0),使其不再伪装 shadow,被 __swap_cache_add_check() 拒绝进入 swap cache;误 put 可触发 count underflow。
3/3
mm, swap: drop the swap cache guard and reclaim in swap_free_hibernation_slot()
因休眠槽已有独立类型且无 swap count,readahead 不会把它放入 swap cache;删除 swap_free_hibernation_slot() 中多余的 swap cache 防护和 reclaim 调用,简化释放。