4

I'm trying to use Redis for production services and trying to avoiding swapping, which is bad for performance.

I had learn that swap is triggered by swap_tendency which is depending on

swap_tendency = mapped_ratio/2 + swappiness + distress

How can I get mapped_ratio/distress from /proc/meminfo for my monitor script?

Or anything parameter that can info me that system is going to swap pages?

3

mapped_ratio

mapped_ratio can be calculated like so:

mapped ratio = (nr mapped * 100) / total memory;

Source: https://www.cs.columbia.edu/~smb/classes/s06-4118/l19.pdf

nr_mapped

The value, nr_mapped can be read from /proc/vmstat:

$ grep nr_mapped /proc/vmstat
nr_mapped 47640

distress

According to this article, titled: Linux Memory - Implementation Notes

“This is a measurement of how much difficulty the VM is having reclaiming pages. Each time the VM tries to reclaim memory, it scans 1/nth of the inactive lists in each zone in an effort to reclaim pages. Each time a pass over the list is made, if the number of inactive clean + free pages in that zone is not over the low water mark, n is decreased by one. Distress is measured as 100 >> n” 5

In researching much of the docs make it sounds as though "distress" is a kernel counter but it is not. Rather it's a value that's used when each zone of memory is being scanned, that is progressively increased as page frames of memory are scanned by the kernel in an attempt to reclaim them. Discussion of this is beyond the scope of this Q&A but if you're curious the section of the book "Understanding the Linux Kernel", Chapter 17: Page Frame Reclaiming. The value of "distress" comes from the value "prev_priority" as the zones are scanned.

References

  • Thanks for the answer, I still have one more question about distress: It seems that distress is a counter in the kernel. How can I get distress? – Zhuo.M Jun 3 '14 at 7:16
  • @Zhuo.M - yes it read that way to me as well. I've been searching for it and have yet to find it exposed under /proc or /proc/sys which leads me to believe that it isn't exposed directly. Will take a cursory look at the source which might be more revealing. – slm Jun 3 '14 at 11:56
  • I had check the Linux 3.12 source code but I can't find anything about distress. Instead I found vmpressure, it appears that it will try to reclaim pages while alloc free pages. – Zhuo.M Jun 4 '14 at 9:52
  • @Zhuo.M - me neither. There is a VM pressure setting that you can get/set, I wonder if that's it? – slm Jun 4 '14 at 11:05
  • I got the answer from "Understanding the Linux Kernel", distress came from prev_priority – Zhuo.M Jun 9 '14 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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