v3
2026-08-13
zswap 设备消失返回 -ENOENT · v3
zswap_writeback_entry() 在 get_swap_device() 返回 NULL 时改为返回 -ENOENT,避免被 shrinker 误认为 -EEXIST 而完全停止扫描,使陈旧条目被跳过并继续回收。
原始补丁链接
子 Patch(15)
1/15
mm: zswap: return -ENOENT when the swap device is gone
zswap_writeback_entry()对swap device消失返回-EEXIST,被shrinker误认为页已在swap cache而停止扫描;改返回-ENOENT使其跳过stale entry继续。
2/15
mm: xswap support for zswap
新增xswap虚拟交换设备,无后端存储,bdev置NULL,写失败,标记SSD;当系统全为xswap时禁用zswap回写,避免无后端可写。
3/15
mm, swap: add CONFIG_XSWAP and xswap fields to swap_info_struct
为xswap增加CONFIG_XSWAP及swap_info_struct字段cluster_vm/nr_clusters/nr_clusters_mapped,支持基于VM_SPARSE的懒cluster管理。
4/15
mm, swap: refactor free_swap_cluster_info to take swap_info_struct
重构free_swap_cluster_info()为接收swap_info_struct*,内部提取cluster_info/maxpages,swapoff中清理顺序调整,为xswap路径复用做准备。
5/15
mm, swap: add xswap cluster grow via VM_SPARSE vmalloc
引入xswap_map/unmap_clusters(),基于VM_SPARSE vmalloc懒映射cluster_info数组,grow时分配物理页映射,teardown时unmap并释放,用xswap_lock串行化。
6/15
mm, swap: add sysfs create interface for xswap
新增/sys/kernel/mm/xswap/create sysfs接口创建xswap设备,初始nr_clusters按totalram_pages百分比设置,设备显示为xswap。
7/15
mm, swap: add xswap grow trigger on cluster allocation
cluster分配失败时xswap自动增长:调用xswap_map_clusters()映射更多cluster并加入free_clusters,因SWP_SOLIDSTATE无需释放global_cluster_lock,然后重试。
8/15
mm, swap: add xswap_try_shrink and shrink trigger on cluster free
新增xswap_try_shrink()在__free_cluster()后触发,从尾部反向扫描连续空闲cluster,达到阈值时unmap,实现xswap动态收缩。
9/15
mm, swap: free backing pages in xswap_unmap_clusters
修复xswap_unmap_clusters()只unmap页表未释放backing pages的问题:先用apply_to_existing_page_range()收集pte_page(),vunmap后__free_page()释放。
10/15
mm, swap: add nr_free_tail for O(1) xswap shrink detection
用si->nr_free_tail维护尾部连续空闲cluster计数,alloc/free/grow路径更新,使xswap_try_shrink()的收缩检测从扫描变为O(1)阈值判断。
11/15
mm, swap: add adjustable runtime ceiling (nr_clusters) for xswap
Split the xswap cluster limit into two fields: - nr_clusters_max: immutable hard limit set at device creation - nr_clusters: current growth ceiling, adjustable at runtime (≤ nr_clusters_max) The grow
12/15
mm, swap: add debugfs knob for xswap per-device cluster limit
Add a per-device debugfs file for runtime adjustment of xswap cluster limit: /sys/kernel/debug/xswap/type_cluster_limit Reading shows the current ceiling (in clusters); writing sets it (clamped
13/15
mm, swap: defer xswap shrink to workqueue to avoid lock recursion
xswap_try_shrink() was called directly from __free_cluster() while holding ci->lock. The shrink path calls xswap_unmap_clusters() which unmaps vmalloc pages backing cluster_info, and on return swap_c
14/15
mm, swap: refactor swapoff + add xswap_destroy
Extract __swapoff() from sys_swapoff(): the core teardown logic now lives in __swapoff(), shared by sys_swapoff() and the new xswap_destroy(). swap_file operations are guarded with NULL chec
15/15
mm, swap: require zswap for xswap devices
xswap has no backing storage: swapped-out pages live only in zswap. Without zswap, swapout always bounces back, so the device would consume swap entry space without ever freeing memory. Refuse to cre