Bug 262595 - Swap on ZFS doesn't work properly.
Summary: Swap on ZFS doesn't work properly.
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-16 14:00 UTC by dmilith
Modified: 2022-10-12 13:13 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dmilith 2022-03-16 14:00:00 UTC
On one of my FreeBSD hosts I use swap on ZFS configured this way:

```
zfs create -V 64gb -o org.freebsd:swap=on -o checksum=off -o compression=off -o dedup=off -o sync=disabled -o primarycache=none zroot/swap
swapon /dev/zvol/zroot/swap
```

The thing is… the swap is used in 1% there but I get OOMs from the kernel with Influxdb using a bit over 50G RSS.

Had exactly the same issue on one arm64 machine also with ZFS, crashing the same way… having gigabytes of free swap available.

Seems like swap on ZFS is not a real thing, or it simply doesn't work well?
Comment 1 Graham Perrin freebsd_committer freebsd_triage 2022-03-17 16:46:30 UTC
(In reply to dmilith from comment #0)

> … crashing …

FYI <https://github.com/openzfs/zfs/issues/7734>

>> Swap deadlock in 0.7.9 · Issue #7734 · openzfs/zfs
Comment 2 crest 2022-10-12 13:13:32 UTC
Swapping to ZFS volumes isn't reliable because writing to ZFS can require further allocations. The common safe configuration uses GEOM mirrored swap partitions for disk redundancy and GELI for encryption. Of course this doesn't help you if you've already allocated all your disk space to ZFS.