Avatar of peter
peter
Flag for United States of America asked on

swap question and free buffers

I was wondering why would RHEL use swap , when there are Free buffers (shown in free command)
In our case when we see free memory in top command getting exhausted, The server is using SWAP even though I see the Free buffers.

top - 16:57:41 up 26 days, 15:44,  3 users,  load average: 1.28, 1.91, 2.20
Tasks: 1477 total,   1 running, 1474 sleeping,   0 stopped,   2 zombie
Cpu(s):  0.2%us,  1.5%sy,  0.0%ni, 93.3%id,  5.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  126011368k total, 120899848k used,  5111520k free,     1216k buffers
Swap: 781411152k total, 14705180k used, 766705972k free, 42577308k cached

   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   181 root      20   0     0    0    0 D 20.4  0.0   2959:04 kswapd0
101309 oracle    20   0 16192 2168  664 S  1.3  0.0   0:29.11 top
 58546 oracle    20   0 50.2g 3.9g 3.8g S  1.0  3.2   9:39.78 oracle
108427 xxx-user  20   0 16104 2420 1000 R  1.0  0.0   0:00.16 top
    73 root      20   0     0    0    0 S  0.3  0.0   4:36.71 events/6
  2589 root      20   0  195m 2600 1140 S  0.3  0.0 128:49.36 snmpd
 34482 oracle    20   0 50.2g  89m  80m S  0.3  0.1  42:57.32 oracle
 34488 oracle    20   0 50.2g  14g  14g S  0.3 11.8  29:04.97 oracle
 34490 oracle    20   0 50.2g  14g  14g S  0.3 11.7  28:52.22 oracle
 34492 oracle    20   0 50.2g  14g  14g S  0.3 11.8  29:13.85 oracle
 34494 oracle    20   0 50.2g  13g  13g S  0.3 11.5  28:47.19 oracle
 45764 oracle    20   0 50.2g 3.1g 3.1g S  0.3  2.5   2:45.73 oracle
 89881 oracle    20   0 50.3g  12g  12g S  0.3 10.1  56:44.77 oracle
112926 oracle    20   0 50.3g 3.5g 3.5g S  0.3  2.9   5:27.46 oracle
Linux

Avatar of undefined
Last Comment
peter

8/22/2022 - Mon
Seth Simmons

by default, the kernel will swap out unused memory pages
there is a setting called swappiness; the default is 60
you can verify by doing cat /proc/sys/vm/swappiness
you can change it by doing echo 0 > /proc/sys/vm/swappiness which will cause the system to keep more in physical memory.  this is actually a recommended setting by oracle which i have used in the past
to make it permanent, add a line vm.swappiness = 0 to /etc/sysctl.conf

what version of RHEL?  your swap partition seems huge; should really need much
little to no swap usage is ideal in a system like that.  you can use vmstat to monitor the realtime usage
columns si and so (swap in and swap out) you want to pay attention to.  if these are constantly non-zero then you have a bottleneck that could affect oracle performance
peter

ASKER
thanks Seth,
we are using RHEL 6.5, Can this be because we are not using hugepages?
we recently disabled THP

#SWAP
vm.swappiness = 15 <<<<<this was originally 0
vm.dirty_background_ratio = 5
vm.dirty_ratio = 10  <<<<<this was originally 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
[root@EGS-ORACLEPROD-01 ec2-user]#

 vmstat 5 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 3  1 12084124 1208464    788 45135084   33   21  1678   748    0    0 11  4 82  3  0
 3  2 12073976 1192172    888 45144792 2070  211 61896 47374 26706 17685 15  6 73  6  0
 6  0 12075904 1580260    772 45144320 3427 3968 15995 24783 30457 21892 12  8 73  7  0
 9  2 12067204 1657068   1032 45157736 1745   63 12306  9830 31609 24469 12  9 73  6  0
 3  0 12072836 1719692   1064 45143564 1380 2388  5535 15386 29756 22788  9 10 76  5  0
ASKER CERTIFIED SOLUTION
Seth Simmons

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
peter

ASKER
ok, we did that,

I am setting hugepages to

vm.nr_hugepages = 25604

per this helpful article, lets see what happens : )
https://docs.oracle.com/cd/E11882_01/server.112/e10839/appi_vlm.htm#UNXAR396
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy