On Sunday, 20 October 2019 00:35:56 BST Wol's lists wrote: > The original swap algorithm NEEDED twice ram as swap. And when Linus > ripped out all the "optimisation", the vanilla kernels only needed to > touch swap, and if they didn't have twice ram they would crash.
Was this also the time when the default swappiness was set at 60?
> At that point, the recommendation changed to "no swap is fine, twice or
> more is fine, just don't have swap less than twice ram".
Are you sure of this? At least on current kernels (I'm currently on 4.19.72-
gentoo) the overcommit_accounting kernel mechanism using a heuristic over-
commit memory handling is set at 0, which refuses wilder over commits, but
allows more measured over commits to use swap space.
$ cat /proc/sys/vm/overcommit_memory
0
When set at 2, where no over-commit of memory is allowed, the mechanism will
be informed by the overcommit_ratio by default set at 50%, to calculate how
much RAM will be used by malloc. In this case, all swap will be used but only
50% of RAM.
$ cat /proc/sys/vm/overcommit_ratio
50
Unless someone has purposefully set their overcommit_memory to 1, where
potentially wild over commits are allowed and the risk of OOM increases, the
kernel will not allow over-committing of RAM without checking how much RAM +
swap is available.
On my system with default overcommit_memory settings I have:
$ free --kilo
total used free shared buff/cache available
Mem: 15975043 1359884 13849407 22528 765751 14126170
Swap: 17179865 0 17179865
but only 24577524 is reported as the commit limit:
$ grep CommitLimit /proc/meminfo
CommitLimit: 24577524 kB
This is all swap and a percentage of RAM:
24577524 - 17179865 = 7397659 of RAM, or 46.3%.
>From the above and without further experimentation I assume having a swap
slightly larger than my RAM is more than adequate for a desktop, including
hibernating on swap.
> My personal rule is to take the motherboard's max ram, double it, and
> create a swap partition that size on every disk. So my current desktop
> system has 80GB of ram/swap - 4x4GB slots times 2 disk drives. And my
> new system has 4x8GB so that'll be 160GB!!! HOWEVER - Richard Brown of
> SUSE said that's dangerous - if somebody fork-bombs you it'll take a
> long time to fill that much swap and regaining control of your system
> could well be a big red switch job.
>
> Cheers,
> Wol
Each to their own, but I tend to think this huge amount of swap is probably
excessive, unless you're running some scientific applications which require
big over commits for their calculations.
--
Regards,
Mick
signature.asc
Description: This is a digitally signed message part.

