v3
2026-08-13
休眠 swap 槽不进入 swap cache · v3
修复休眠 swap 槽被集群预读当作普通槽覆盖:引入独立槽类型,修正释放逻辑。
原始补丁链接
子 Patch(4)
1/4
mm, swap: don't free a hibernation slot that is in the swap cache
swap_free_hibernation_slot() 释放前检查槽上是否还有 swap cache folio,防止 cluster readahead 放入的 folio 失去映射,后续 reclaim 覆盖已分配表项。
2/4
mm, swap: only allow swapped-out slots into the swap cache
收紧 __swap_cache_add_check():只有 shadow entry 对应的槽才能进 swap cache,防止 cluster readahead 把 SWP_TB_BAD 坏槽当换出页读入并覆盖坏标记。
3/4
mm, swap: give hibernation swap slots their own swap table entry type
hibernation 槽改用独立类型:bit4 及以上置位且 count=0,不再是 shadow;swap cache 拒绝之,count 读取者不会误判为 SWP_TB_COUNT_MAX,错误 put 触发下溢检查。
4/4
mm, swap: drop the swap cache guard and reclaim in swap_free_hibernation_slot()
删除 swap_free_hibernation_slot() 中针对 readahead 放入 folio 的 swap cache 保护与 reclaim;新 hibernation 槽非 shadow 且无 count,swap cache 不会接受,防御已无必要。