Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Per the kernel documentation:

This control is used to define how aggressive the kernel will swap
memory pages.  Higher values will increase agressiveness, lower values
decrease the amount of swap.

However this is kind of vague. I'm trying to figure out exactly what the parameter ultimately controls. I know it adjusts how aggressively the kernel tries to swap out pages, but what decision making process in the kernel code does it affect?

Does it adjust how long ago a page must have been accessed before the kernel swaps it out? If so what does the default value of 60 represent? And how much is changed by a increment/decrement of 1 (a forumula would be nice)?
Or does it swap out pages based on their access frequency?
Or something else?

share|improve this question
Yes, swapiness is vague ;-) – ā„¯aphink Feb 22 '12 at 10:21

1 Answer

You can read this or this article... There is a formula, which is used to compute, what page will be swapped.

In vmscan.c you can see this algorithm:

swap tendency = mapped_ratio / 2 + distress + vm_swappiness

Here you can see that swappiness is a scale, which is added in some algorithm and you can control by this parameter how the kernel will behave when it must swap. You can figure it as an percentage of probability, that some inactive memory page will be swapped. If you set swappiness to 100, there is no probability, but a guarantee and if you set it to 0, the kernel will try not to swap at all until it has some empty memory.

share|improve this answer
@Gilles I've edited my post according your note... – Jan Marek Feb 23 '12 at 8:01
@Gilles Thank for edit my answer to improve bad English... – Jan Marek Feb 23 '12 at 10:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.