[GH-ISSUE #3698] [Engine] Linux: start hangs/freezes the host at the prompt-path init when pinned memory lands on KHO scratch (CMA) - MemAvailable over-reports by ~17 GiB on Ubuntu 26.04 kernel 7.0 #1534

Closed
opened 2026-11-04 01:52:03 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @q8atnight on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3698

Summary

On Ubuntu 26.04 (kernel 7.0) about 17 GiB of RAM is reserved as kexec-handover (KHO) scratch and is handed to the page allocator as CMA. MemAvailable counts those pages as free, but pinned host memory (cudaHostRegister / cudaHostAlloc) cannot be placed there. With UD-Q5_K_XL, every expert in RAM and --kv fp16, the pinned total crosses the non-CMA capacity: the engine does not get an allocation error, the host stalls in direct reclaim and compaction, systemd-oomd kills the desktop, and two runs froze the PC hard. The engine's memory guard saw 116.3 GiB available and let the start through. This also corrects my report in #3278, which blamed "does not fit 121 GiB".

Setup

  • Ubuntu 26.04.1, kernel 7.0.0-31-generic (Ubuntu 7.0.14), NVIDIA driver 595.84, engine in Docker (--ulimit memlock=-1).
  • Ryzen 9 3950X, 128 GB DDR4 (MemTotal 121.4 GiB), 2x RTX 3090 24 GB (sm_86) with NVLink, 56 GB swap on NVMe.
  • v0.2.0-beta (engine 0.1.45.3), our tree = tag 3d1fb480 + #1937 + #1525 + #3022 + #3280 + the decode half of #1099. All runs below used this tree.
  • unsloth UD-Q5_K_XL native pack, all experts fixed in RAM (91.61 GiB arena, cudaHostRegister PORTABLE ok, buffered read), --layer-split 24 --trim-stage-weights --kv fp16 --kv-resident 20480 --max-context 262144 --prefill auto --spec 4 --mtp ... --vision (CPU) --pipeline-windows 2 --pcie-frac 0.2 --ple-gguf <Q8_0 shard 3> --ple-io direct --conversation-cache-mib 4096 --conversation-disk-dir ...

Symptom

Reproduced 7 times (10-20 00:05; 10-22 08:08, 08:40, 09:13, 10:02, 10:20, 10:35). The start runs through the arena load and the GPU expert caches. The last lines (STRATA_TRACE=1 STRATA_RSS_TRACE=1) are always:

strata serve: the prompt path borrows 1390 CUDA0 cache slots (5.20 GiB)
strata serve:   CUDA1 prompt path borrows 1397 of its 4695 slots (5.20 GiB)
strata rss: the prompt path set up: RssFile 0.15 GiB
strata trace: 674 MiB free after before the prompt path init

Then the whole host stalls: PSI memory some/full 81-97 %, systemd-oomd kills GNOME, dbus and user services, the SSH banner times out. Two of the runs hard-froze the PC (reset needed). docker rm -f first answers "did not receive an exit event" and the container exits (137) about 30 s later.

Snapshot during the hang (read as root, 10-22 10:08 and 10:50):

  • Engine: RSS 92 GiB, VmSwap 1.0 GiB, 44 threads (39 in futex wait, 1 running).
  • /proc/vmstat: allocstall_normal 171,567; compact_stall 3,377; pswpout 996,833 pages (~3.8 GiB); PSI io about 0, so it is not disk-bound.
  • /proc/meminfo: MemFree 18,591,564 kB, MemAvailable 18,048,232 kB, CmaFree 17,767,616 kB (CmaTotal reads 0 kB, a counter quirk). Of the ~18.6 GB "free", ~17.8 GB is CMA-type; non-CMA free is under 1 GB.

The memory guard at the same start said: limit 121.4 GiB (source: meminfo) ... available 116.3 GiB (MemAvailable 116.3 GiB), floor 2560 MiB.

What was ruled out

  • VRAM headroom: both cards had VRAM free at the hang. With 1.49 / 1.11 GiB free (--vram-reserve-mib 1200 --vram-reserve-later-mib 1000): same hang.
  • THP: STRATA_NO_ARENA_THP=1, same hang.
  • Prompt chunk size: --prefill 4096 (loan 3.70 GiB per card), same hang.
  • Chat cache size: 4096 vs 8192 MiB, same.
  • STRATA_PF_STEP_SYNC=1 prints nothing (it covers prompts, not this init).
  • Same box, same flags: Q5 + int8 KV starts and runs daily; UD-Q4_K_XL + fp16 starts fine. fp16 costs 1.45 GiB more pinned RAM (K/V in 3.00 GiB of pinned RAM vs 1.55 GiB int8); MemAvailable once ready was 38.1 GiB (Q4, int8) and 36.6 GiB (Q4, fp16). Q5 + int8 live (10-22 10:57): MemAvailable 16.6 GiB, CmaFree 7.6 GiB.

Root cause (as far as traced)

  • Kernel config: CONFIG_KEXEC_HANDOVER=y, CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y, CONFIG_MEMBLOCK_KHO_SCRATCH=y. The boot command line has no kho= and no cma= (only crashkernel=...,128G-:4096M). dmesg says "0K cma-reserved" and /sys/kernel/mm/cma/ is empty, so it does not look like a normal CMA area.
  • /sys/kernel/debug/kho/out/scratch_len and scratch_phys: 0.70 GiB @0x7a600000, 12.32 GiB @0x1b93400000, 4.21 GiB @0x1a86000000 = 17.23 GiB.
  • /proc/pagetypeinfo: 8,464 CMA pageblocks in Normal and 357 in DMA32 (2 MiB each, about 17.2 GiB). /proc/zoneinfo Normal: cma 4333568 pages. nr_free_cma was 4,147,664 on an idle box.
  • Kernel docs: "By default, size of the scratch region is calculated based on amount of memory allocated during boot ... The scratch regions are declared as CMA when page allocator is initialized ... CMA enforces that only movable pages can be located inside." (core-api/kho, read 2026-10-22). kho_scratch= sets the sizes (admin-guide/mm/kho).
  • Pinned memory is a long-term pin and cannot live in movable CMA pageblocks, so about 17 GiB of what MemAvailable reports is unusable for the arena, KV and pinned buffers. With Q5 + fp16 the pinned total crosses the non-CMA capacity, which gives the reclaim/compaction storm instead of an error.

I have not yet changed anything on the kernel side to confirm this; see Workaround.

Suggested engine-side fix

  1. The memory guard / pin guard (STRATA_PIN_GUARD, the memory guard: ... available ... (MemAvailable ...) line) should subtract CmaFree from /proc/meminfo (or count only non-CMA free pages from /proc/pagetypeinfo / zoneinfo) when it budgets pinned memory, and refuse the start with a clear message instead of letting the host freeze.
  2. docs/TROUBLESHOOTING.md: kernels with CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y (Ubuntu 26.04, kernel 7.0) hide about 13-17 % of RAM from pinned memory here. Check with grep CmaFree /proc/meminfo; workaround kho=off.

Workaround

Planned, not tested yet: boot with kho=off, or with a small kho_scratch=. Expected: about 17 GiB more usable for pinned memory, and Q5 + fp16 should start. I will report the result in this issue.

Originally created by @q8atnight on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3698 ### Summary On Ubuntu 26.04 (kernel 7.0) about 17 GiB of RAM is reserved as kexec-handover (KHO) scratch and is handed to the page allocator as CMA. `MemAvailable` counts those pages as free, but pinned host memory (`cudaHostRegister` / `cudaHostAlloc`) cannot be placed there. With UD-Q5_K_XL, every expert in RAM and `--kv fp16`, the pinned total crosses the non-CMA capacity: the engine does not get an allocation error, the host stalls in direct reclaim and compaction, systemd-oomd kills the desktop, and two runs froze the PC hard. The engine's memory guard saw 116.3 GiB available and let the start through. This also corrects my report in #3278, which blamed "does not fit 121 GiB". ### Setup - Ubuntu 26.04.1, kernel 7.0.0-31-generic (Ubuntu 7.0.14), NVIDIA driver 595.84, engine in Docker (`--ulimit memlock=-1`). - Ryzen 9 3950X, 128 GB DDR4 (MemTotal 121.4 GiB), 2x RTX 3090 24 GB (sm_86) with NVLink, 56 GB swap on NVMe. - `v0.2.0-beta` (engine 0.1.45.3), our tree = tag `3d1fb480` + #1937 + #1525 + #3022 + #3280 + the decode half of #1099. All runs below used this tree. - unsloth UD-Q5_K_XL native pack, all experts fixed in RAM (91.61 GiB arena, `cudaHostRegister PORTABLE ok`, buffered read), `--layer-split 24 --trim-stage-weights --kv fp16 --kv-resident 20480 --max-context 262144 --prefill auto --spec 4 --mtp ... --vision` (CPU) `--pipeline-windows 2 --pcie-frac 0.2 --ple-gguf <Q8_0 shard 3> --ple-io direct --conversation-cache-mib 4096 --conversation-disk-dir ...` ### Symptom Reproduced 7 times (10-20 00:05; 10-22 08:08, 08:40, 09:13, 10:02, 10:20, 10:35). The start runs through the arena load and the GPU expert caches. The last lines (`STRATA_TRACE=1 STRATA_RSS_TRACE=1`) are always: ``` strata serve: the prompt path borrows 1390 CUDA0 cache slots (5.20 GiB) strata serve: CUDA1 prompt path borrows 1397 of its 4695 slots (5.20 GiB) strata rss: the prompt path set up: RssFile 0.15 GiB strata trace: 674 MiB free after before the prompt path init ``` Then the whole host stalls: PSI memory some/full 81-97 %, systemd-oomd kills GNOME, dbus and user services, the SSH banner times out. Two of the runs hard-froze the PC (reset needed). `docker rm -f` first answers "did not receive an exit event" and the container exits (137) about 30 s later. Snapshot during the hang (read as root, 10-22 10:08 and 10:50): - Engine: RSS 92 GiB, VmSwap 1.0 GiB, 44 threads (39 in futex wait, 1 running). - `/proc/vmstat`: allocstall_normal 171,567; compact_stall 3,377; pswpout 996,833 pages (~3.8 GiB); PSI io about 0, so it is not disk-bound. - `/proc/meminfo`: MemFree 18,591,564 kB, MemAvailable 18,048,232 kB, **CmaFree 17,767,616 kB** (CmaTotal reads 0 kB, a counter quirk). Of the ~18.6 GB "free", ~17.8 GB is CMA-type; non-CMA free is under 1 GB. The memory guard at the same start said: `limit 121.4 GiB (source: meminfo) ... available 116.3 GiB (MemAvailable 116.3 GiB), floor 2560 MiB`. ### What was ruled out - VRAM headroom: both cards had VRAM free at the hang. With 1.49 / 1.11 GiB free (`--vram-reserve-mib 1200 --vram-reserve-later-mib 1000`): same hang. - THP: `STRATA_NO_ARENA_THP=1`, same hang. - Prompt chunk size: `--prefill 4096` (loan 3.70 GiB per card), same hang. - Chat cache size: 4096 vs 8192 MiB, same. - `STRATA_PF_STEP_SYNC=1` prints nothing (it covers prompts, not this init). - Same box, same flags: Q5 + int8 KV starts and runs daily; UD-Q4_K_XL + fp16 starts fine. fp16 costs 1.45 GiB more pinned RAM (`K/V in 3.00 GiB of pinned RAM` vs 1.55 GiB int8); MemAvailable once ready was 38.1 GiB (Q4, int8) and 36.6 GiB (Q4, fp16). Q5 + int8 live (10-22 10:57): MemAvailable 16.6 GiB, CmaFree 7.6 GiB. ### Root cause (as far as traced) - Kernel config: `CONFIG_KEXEC_HANDOVER=y`, **`CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y`**, `CONFIG_MEMBLOCK_KHO_SCRATCH=y`. The boot command line has no `kho=` and no `cma=` (only `crashkernel=...,128G-:4096M`). dmesg says "0K cma-reserved" and `/sys/kernel/mm/cma/` is empty, so it does not look like a normal CMA area. - `/sys/kernel/debug/kho/out/scratch_len` and `scratch_phys`: 0.70 GiB @0x7a600000, 12.32 GiB @0x1b93400000, 4.21 GiB @0x1a86000000 = **17.23 GiB**. - `/proc/pagetypeinfo`: 8,464 CMA pageblocks in Normal and 357 in DMA32 (2 MiB each, about 17.2 GiB). `/proc/zoneinfo` Normal: `cma 4333568` pages. `nr_free_cma` was 4,147,664 on an idle box. - Kernel docs: "By default, size of the scratch region is calculated based on amount of memory allocated during boot ... The scratch regions are declared as CMA when page allocator is initialized ... CMA enforces that only movable pages can be located inside." ([core-api/kho](https://docs.kernel.org/core-api/kho/index.html), read 2026-10-22). `kho_scratch=` sets the sizes ([admin-guide/mm/kho](https://docs.kernel.org/admin-guide/mm/kho.html)). - Pinned memory is a long-term pin and cannot live in movable CMA pageblocks, so about 17 GiB of what `MemAvailable` reports is unusable for the arena, KV and pinned buffers. With Q5 + fp16 the pinned total crosses the non-CMA capacity, which gives the reclaim/compaction storm instead of an error. I have not yet changed anything on the kernel side to confirm this; see Workaround. ### Suggested engine-side fix 1. The memory guard / pin guard (`STRATA_PIN_GUARD`, the `memory guard: ... available ... (MemAvailable ...)` line) should subtract `CmaFree` from `/proc/meminfo` (or count only non-CMA free pages from `/proc/pagetypeinfo` / `zoneinfo`) when it budgets pinned memory, and refuse the start with a clear message instead of letting the host freeze. 2. `docs/TROUBLESHOOTING.md`: kernels with `CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y` (Ubuntu 26.04, kernel 7.0) hide about 13-17 % of RAM from pinned memory here. Check with `grep CmaFree /proc/meminfo`; workaround `kho=off`. ### Workaround Planned, **not tested yet**: boot with `kho=off`, or with a small `kho_scratch=`. Expected: about 17 GiB more usable for pinned memory, and Q5 + fp16 should start. I will report the result in this issue.
Author
Owner

@q8atnight commented on GitHub (Oct 22, 2026):

Follow-up: the kho=off workaround is confirmed on this box.

  • Added kho=off to GRUB_CMDLINE_LINUX_DEFAULT, update-grub, reboot (Ubuntu 26.04, kernel 7.0.0-31-generic).
  • After boot: CmaFree: 0 kB (was ~16.6 GiB on an idle box), /proc/cmdline shows kho=off.
  • UD-Q5_K_XL + --kv fp16 with every expert in RAM (91.61 GiB arena) now starts on the first try, same flags as in the report. Warm: MemAvailable ~12 GiB, no reclaim storm, no oomd kills.

So for anyone on a CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y kernel who pins most of their RAM: check grep CmaFree /proc/meminfo; if it is large, kho=off gives it back to pinned memory.

A separate, smaller thing seen right after that first successful start (not KHO-related): with only ~50-190 MiB of VRAM left per card (--vram-reserve-mib 400), the first long prompt crashed the engine with prefill gemm: cublasGemmEx f16: cuBLAS status 14; the server restarted it on the next request. With the values the engine's own start-up warning suggests (--vram-reserve-mib 727 --vram-reserve-later-mib 999) it runs clean (now 363 / 620 MiB free after warm-up). The start-up warning is therefore right to call it LOW; maybe the reserve could default to that figure on a layer split with fp16 KV.

<!-- gh-comment-id:6337242981 --> @q8atnight commented on GitHub (Oct 22, 2026): Follow-up: the `kho=off` workaround is confirmed on this box. - Added `kho=off` to `GRUB_CMDLINE_LINUX_DEFAULT`, `update-grub`, reboot (Ubuntu 26.04, kernel 7.0.0-31-generic). - After boot: `CmaFree: 0 kB` (was ~16.6 GiB on an idle box), `/proc/cmdline` shows `kho=off`. - UD-Q5_K_XL + `--kv fp16` with every expert in RAM (91.61 GiB arena) now starts on the first try, same flags as in the report. Warm: MemAvailable ~12 GiB, no reclaim storm, no oomd kills. So for anyone on a `CONFIG_KEXEC_HANDOVER_ENABLE_DEFAULT=y` kernel who pins most of their RAM: check `grep CmaFree /proc/meminfo`; if it is large, `kho=off` gives it back to pinned memory. A separate, smaller thing seen right after that first successful start (not KHO-related): with only ~50-190 MiB of VRAM left per card (`--vram-reserve-mib 400`), the first long prompt crashed the engine with `prefill gemm: cublasGemmEx f16: cuBLAS status 14`; the server restarted it on the next request. With the values the engine's own start-up warning suggests (`--vram-reserve-mib 727 --vram-reserve-later-mib 999`) it runs clean (now 363 / 620 MiB free after warm-up). The start-up warning is therefore right to call it LOW; maybe the reserve could default to that figure on a layer split with fp16 KV.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6659633990 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1534
No description provided.