Repository navigation
Description
Part of #14.
rukernel has swapon and swapoff, and it keeps the active swap areas, but it does not move pages to swap (core/rk-syscall/src/swap.rs). Memory reclaim takes back only clean page cache. A cgroup at memory.max first drops clean cache, and then the kernel kills a task (core/rk-cgroup). Anonymous memory never goes to swap, and the pgscan and pgsteal counters of memory.stat and /proc/vmstat stay at 0.
systemd-oomd needs these counters. It kills in a cgroup only when the pgscan rate of that cgroup is above 0 (oomd_kill_by_pgscan_rate and oomd_kill_by_swap_usage in src/oom/oomd-util.c). So in TEST-55-OOMD of the systemd boot test, oomd never kills, and stress-ng ends at its own timeout. A kill test case passes or fails only by timing. See #536, item 2.
Scope
- Reclaim counts its work: each scan and each freed page of the page cache adds to
pgscan_*,pgsteal_*,pgscan_fileandpgsteal_filein/proc/vmstat, and topgscanandpgstealinmemory.statof the cgroup that owns the page, for direct reclaim, formemory.highand formemory.max. Test: a unit test in rk-cgroup, and a check in thecgroupboot test thatpgscangrows when a cgroup with a smallmemory.highreads a large file. Exit: the counters match the rules of Linux mm/vmscan.c. mm: count the reclaim of the page cache in memory.stat and /proc/vmstat #765: done, the page cache reclaim counts in /proc/vmstat and memory.stat, and the boot test checks pass. - Anonymous pages go to swap: a swap entry in the page table for a page that is out, the swap cache, write of a page to the swap area at reclaim, and read back at the page fault. Reclaim of a cgroup over
memory.highormemory.maxtakes anonymous pages when a swap area is active, andmemory.swap.current,memory.swap.maxand theswaplines ofmemory.statand/proc/meminfoare correct. Test: LTP swapon01 to swapon03, swapoff01 and swapoff02, a newswapboot test that fills more memory than the VM has with a swap file active and checks the data, and the memory cgroup tests of LTP (memcg_) that use swap. Exit: these pass on x86_64 and arm64, apart from listed exceptions. Exception: the memcg_ tests of LTP need cgroup v1 and give TCONF. mm: swap slots and the I/O of a page to a swap area #771, mm: MADV_PAGEOUT writes anonymous pages to swap, and a fault reads them back #780, mm: the reclaim of a memory cgroup writes anonymous pages to swap #785, mm: swapoff of an area with used pages reads the pages back #791, mm: a transparent huge page goes to swap as 4 KiB pages, and the swap boot test fills more memory than the VM has #800: done, the swap boot test fills more memory than the VM has and the data comes back on x86_64, arm64 and corten, and LTP swapon01 to swapon03, swapoff01 and swapoff02 pass on x86_64 and arm64. - systemd-oomd: TEST-55-OOMD of the
systemdboot test. Exit: all its test cases pass 3 times of 3 at a load average under 10, on x86_64. mm: memory pressure and reclaim for systemd-oomd, TEST-55-OOMD part 1 (#752) #829: part 1. systemd-oomd kills now, and all 5 test cases pass in about 1 run of 3. Open: the test does not seetestchillin the 15 s before the next kill.
Activity
tamnd commentedon Nov 16, 2026
Item 1 (the reclaim counters) is in #765.
memory.statgivespgscan,pgstealand the kswapd and direct counts of the subtree./proc/vmstatgivespgscan_*andpgsteal_*. A cgroup overmemory.highnow reclaims its page cache at the return to user mode, and a write ofmemory.maxreclaims before the OOM kill. The reclaim covers only the page cache. Anonymous pages to swap (item 2) come next, in the parts of the plan.tamnd commentedon Nov 17, 2026
Item 2, part 1 of 4 is in #771: the slots of a swap area, the I/O of a page to swap and back,
/proc/swapsUsed,SwapFree, and the newswapboot test. Nothing writes to swap yet, so item 2 stays open. Part 2 (swap entries in the page table,MADV_PAGEOUTand the read at a fault) comes next.tamnd commentedon Nov 17, 2026
Item 2, part 2 of 4 is in #780: swap entries in the page table,
MADV_PAGEOUTwrites private anonymous pages to swap, and a fault reads them back.fork,mremapandmunmapkeep or free the entries.pswpin,pswpout,VmSwapand smapsSwaphave values. Theswapboot test passes on x86_64, arm64 and corten x86_64. Item 2 stays open. Part 3 (the reclaim of anonymous pages for a memory cgroup,memory.swap.*,memory.reclaim) comes next.tamnd commentedon Nov 17, 2026
Item 2, part 3 of 4 is in #785: the reclaim of a memory cgroup writes anonymous pages to swap after the page cache, at
memory.high, atmemory.max, before the OOM killer, and formemory.reclaim, which now frees memory.memory.swap.current,memory.swap.peak,memory.swap.max,memory.swap.events, andpswpinandpswpoutofmemory.statwork. Theswapboot test passes on x86_64, arm64 and corten x86_64. Item 2 stays open. Part 4 (swapoffwith used pages reads them back) comes next.tamnd commentedon Nov 17, 2026
Item 2, part 4 of 4 is in #791:
swapoffof an area with used pages reads the pages back into the processes that have them, astry_to_unuseof Linux. No new page goes to the area while it reads, and the call givesENOMEMif the pages do not fit in the free memory. Theswapboot test passes on x86_64, arm64 and corten x86_64. Item 2 is complete with #771, #780, #785 and #791.tamnd commentedon Nov 17, 2026
Item 2 stays open for now. The code of the four parts is merged (#771, #780, #785, #791), but two tests of the exit did not run yet:
swapboot test does not fill more memory than the VM has with a swap file active. It uses a swap disk,MADV_PAGEOUTand the reclaim of a memory cgroup.The memcg_* scripts of LTP test cgroup v1, and they give TCONF because rukernel mounts the memory controller on cgroup v2 (tools/ltp/controllers.md). memcontrol01 to memcontrol04 (cgroup v2) pass. Item 2 gets the tick after the two tests above pass on x86_64 and arm64.
tamnd commentedon Nov 18, 2026
#800: the swap boot test fills more memory than the VM has, with a swap file active, and the data comes back. It passes on x86_64, on arm64 and with corten. A transparent huge page now goes to swap as 4 KiB pages. LTP swapon01 to swapon03, swapoff01 and swapoff02 pass on x86_64 and arm64 with the release kernel (load 7 to 13). Item 2 is complete now with #771, #780, #785, #791 and #800. The exception is the memcg_* tests of LTP: they need cgroup v1 and give TCONF.
mm: memory pressure and reclaim for systemd-oomd, TEST-55-OOMD part 1 (…
tamnd commentedon Nov 23, 2026
Item 3 (TEST-55-OOMD), part 1: #829.
What #829 fixes:
memory.high,memory.maxand a short system, and the read of a page back from swap, count as memory stalls inmemory.pressure. Before, systemd-oomd did not kill.stress-ngworker walked all 200 MiB, and PID1 did not get a CPU for 25 s.memory.highworks in batches of 64 pages, and a thread takes back only the pages that its cgroup charged over the limit.Counted runs on server1 (x86_64, release kernel, 2 vCPUs, 1 GiB) with the final kernel: f1 duration_override fails (load 2.02), f2 all 5 pass (load 2.57), f3 basic_user and preference_avoid fail with exit 24 (load 2.37). The runs with the earlier kernels also gave 1 pass of 3 (c1 to c3, load 2.31 to 2.41; e1 to e3, load 2.05 to 2.52).
What still fails, so the item stays open:
testmunchcorrectly, and 15 s later it looks at the pressure of the workload slice again.testbloatkeeps that pressure high, so it then killstestchill(exit 24, or exit 23 in duration_override). The test must see thattestmunchstopped and then seetestchillin those 15 s. On rukernel the killed workers took up to 8 s to exit and onesystemctl statustook 20 s, while the 10 workers oftestbloatkept both vCPUs busy.testmunchfor its own pressure before the secondoomctlof duration_override.The next step is the latency of user tasks when about 20 threads reclaim: the kernel is not preemptive, so a thread in the reclaim keeps its CPU, and there is no group scheduling of the CPU.