0

This is my Ubuntu version.

# uname -a
Linux psh-VirtualBox 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

I did the same experiment after setting the swappiness values ​​1 and 100.
The test is to fill the cache area and then allocate more than free memory in the new process.

However, none of them used the SWAP area.
Even if the swappiness value is 100, isn't the SWAP area used?

When swappiness = 1

# sysctl -w vm.swappiness=1
vm.swappiness = 1

swapoff -a
swapon -a
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches

# free
              total        used        free      shared  buff/cache   available
Mem:        8152876      995524     7036300       20760      121052     6951560
Swap:       3067108           0     3067108

# dd if=/dev/zero of=./file_1 bs=1024 count=6500000

# free
              total        used        free      shared  buff/cache   available
Mem:        8152876      994732      356972       20760     6801172     6833516
Swap:       3067108           0     3067108

# ./memory_allocate_2G   # Another Session

# free
              total        used        free      shared  buff/cache   available
Mem:        8152876     3055936      129096       20760     4967844     4775416
Swap:       3067108           0     3067108

When swappiness = 100

# sysctl -w vm.swappiness=100
vm.swappiness = 100

swapoff -a
swapon -a
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
 
 
# free
              total        used        free      shared  buff/cache   available
Mem:        8152876      995892     7049160       20760      107824     6957692
Swap:       3067108           0     3067108

# dd if=/dev/zero of=./file_1 bs=1024 count=6500000

# free
              total        used        free      shared  buff/cache   available
Mem:        8152876      995236      366380       20760     6791260     6832984
Swap:       3067108           0     3067108


# ./memory_allocate_2G   # Another Session

# free
              total        used        free      shared  buff/cache   available
Mem:        8152876     3055936      129096       20760     4967844     4775416
Swap:       3067108           0     3067108

Would my test be wrong?
thank you.

And Our Live Server free info ( Why use swap when there is enough free space? )
swappiness is 10.

Linux Server 3.2.0-29-generic #46-Ubuntu SMP Fri Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

$ free
             total       used       free     shared    buffers     cached
Mem:      32901680   29978376    2923304          0     193676    9317964
-/+ buffers/cache:   20466736   12434944
Swap:      7812092    6379492    1432600
P.Lonnie
  • 1
  • 1
  • See the linked question for details. Basically, as long as you have a lot of memory available (the last column in `free`’s output), your system won’t swap. – Stephen Kitt Sep 23 '20 at 04:58
  • @StephenKitt Thanks for the link. I read the post before asking the question. What I was curious about was the value from the real live server. vm.swappiness is 10 of the live server. Here, even though free is sufficient, swap was being used. I didn't understand this part. At the end of the text, information on the memory usage area has been added. – P.Lonnie Sep 23 '20 at 10:06
  • On your server, you’d have to watch the behaviour over a period of time; an instantaneous view like that can’t explain everything. If swap is being used, that means that the kernel determined at some point in the past that some pages were better swapped out than kept in memory; but to understand why that happened, you’d have to know what the memory usage was like at that point in time. Tools like `sar` in the `sysstat` package can help. – Stephen Kitt Sep 23 '20 at 11:10
  • Thank you for answer. Since I am not a server administrator, I don't have permission, so it seems difficult to check the package. We will check the use of swap through an internal test with the server administrator. – P.Lonnie Oct 04 '20 at 15:53

0 Answers0