Talk:Swappiness

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Untitled[edit]

See comment below first. I have gone ahead and reverted the change which introduced the concept of 'linux 3.5 setting swappiness to zero disabled swap'. This is not true, as can be seen in the following RedHat bug ticket: https://bugzilla.redhat.com/show_bug.cgi?id=1148414 Also see the comments on the 'cited' blog post here, where it is noted the blogger is incorrect: http://www.percona.com/blog/2014/04/28/oom-relation-vm-swappiness0-new-kernel/#comment-6299389 217.68.250.19 (talk) 14:25, 7 November 2014 (UTC)[reply]


A recent change to this page is factually inaccurate: "Version 3.5 and over: disables swapping" -- this is not true, the citation is just a blog post, and if you look on the comments of the blog someone explains in detail why the statement is false. The setting controls the kernels preference for choosing to swap application memory vs filesystem caching. Even with the changes in the new 3.5 kernel, a setting of zero does *not* indicate that swapping is disabled, it merely indicates that filesystem pages will be swapped before any application memory pages. When there are no further filesystem pages to swap, application memory may still be swapped in order avoid OOM situations. I'll leave this comment here for now to get feedback, then go ahead and make a page edit to correct the error. This misunderstanding seems to be getting very widespread, and having it on wiki is causing issues. 217.68.250.19 (talk) — Preceding undated comment added 12:35, 7 November 2014 (UTC)[reply]

"setting it to 100 may help to improve overall performance" this is totally wrong. See: http://lwn.net/Articles/100978/ — Preceding unsigned comment added by Xose.vazquez (talkcontribs) 10:23, 12 May 2012 (UTC)[reply]

-- I think the article is written in a biased way for setting swappiness to 0 is always best - in certain situations it is. If it is, why is the option there? Suggestion for improvement is to find justification for the default of 60, and what workloads would benefit from a 100 setting. — Preceding unsigned comment added by 192.55.54.36 (talk) 19:35, 28 May 2013 (UTC)[reply]

You want swappiness whenever you have a mix of cold and hot processes — ie, almost always. An example: you're on a crap laptop, you have Thunderbird as a glorified biff (you're reading mail via mutt like $DEITY intended, Thunderbird only for that html from business critters), on desktop 4 there's an open PDF viewer you haven't switched to in four days. You're running a big compile. It's certainly better to let that compile have some cache, even if returning to Thunderbird or the PDF viewer will then take a second or two to bring them back from swap.
The obvious answer, "buy more RAM", is not always doable, and when resources scale up, needs tend to go up as well. When that 64TB RAM server of yours gets low on memory, swapping to those four 160MB/sec disks will effectively stop the world, you want writeout to start when the situation gets bad but not yet critical.
As for swappiness 100: if your swap device if very slow (like, eMMC, or, Cthulhu save us, a SD card) yet the CPU decent, a sudden memory pressure will exhaust memory faster than the kernel can compensate. Userland processes will eat into the reserve, once its gets below vm.min_free_kbytes the kernel will start to aggressively swap but will still serve allocations even from that tiny scrap. Then if a kernel worker which hasn't been teached how to sleep (yay __alloc_skb) wants memory ʀɪɢʜᴛ ɴᴏᴡ, you'll get an OOM despite having gobs of available swap. I just had this with default vm.swappiness=60, at the time of OOM only 40MB of swap space was used.
-KiloByte (talk) 22:13, 20 March 2017 (UTC)[reply]
Of course, by "almost always", I meant ... on machines that are expected to sometimes run out of RAM. If such a condition is considered an error, and you don't care about performance in cases it happens, you're obviously better off with swap effectively off. KiloByte (talk) 09:30, 22 June 2017 (UTC)[reply]

Explanations for 0 and 1 look arbitrary[edit]

The explanation for swappiness 0 has a reference to the official docs, but the official docs say something different.

The explanation for swappiness 1 has no reference at all --Pot (talk) 14:14, 2 May 2018 (UTC)[reply]