防衛スワップ(Linux):よくある誤解

ご注意 perev。 :この興味深い記事は、Linuxでのスワップの目的を詳しく説明し、この点に関する一般的な誤解に対応するもので、特にFacebookのSRE Chris Downによって書かれました。 そして、彼は簡潔なTLで物語を始めます; DR ...



TL; DR



まえがき


cgroup v2, , , « » .

swap. swap , Linux . — , , , . , , : , , , , swap — - , , .

swap': « » , .

: «Linux », «swap » .. , «» swap , , — .

, Linux- , / swap vm.swappiness, 0.


, swap' — , Linux, , .


Linux , . — , swap .

, («» , 4k), , . , , , . [page cache], [file] .

, , , , malloc MAP_ANONYMOUS mmap. «» — , «», — [anon] .

: , slab-, , , — , , , , .


. «» [reclaim] , , , .

. , [clean], .. , , , - .

, . , [dirty], .. , , . [reclamation], , .

. , , (.. ).

swap'


, swap Linux, RAM . , , , Google «what is swap»:

« swap — ; , - , RAM. «» , , swap, , . [..] RAM , swap-».

, — « », Linux , , swap'. , swap', .

, «», , , — , . … , ?

swap. Swap — , «» [unreclaimable], , . , , ( ), .

Swap — , « ». swap — - .

, « » ? :

  1. . /, «» ( ) . , .
  2. , . - , .

swap


swap. « » cgroup v2.







, swap, ?


, cgroup v2?

, , . , , vm.swappiness. : vm.swappiness , , , .

mlock , LD_PRELOAD, . , , - , mlockall, , .

cgroup v2 cgroup memory.low, . , swapping , . swap' , swap . swap' , , swapper'. , , «».

OOM killer. OOM killer , , , . , OOM killer'.

, Linux. , - , : , .. — , . Facebook, Johannes' , , — . cgroup v2, .


swap' ?


swap-, , , , . — , , , .

(4.0+) , swap' , . kswapd — , swap', — swap, , swap' . swapping' swap- . , 4.0+, swap swapping'. , swap , .

, , , . swap', ( ) . 2-3 swap' , ( ). , , swap' . , , swap . atop SWAPSZ , swap. — , ( ). , swap, .

swap'. swap , , . SSD , / , . , , , , . , swapping' , , , , .

/, swap [hibernate], , swap- .

swappiness?


-, , vm.swappiness. (sysctl), . : file_prio ( ) anon_prio ( ). vm.swappiness , anon_prio 200 file_prio, vm.swappiness = 50 anon_prio 50 file_prio 150 ( — ).

, vm.swappiness — , , . , , swap . , , swapping' . - , swap , , «» , swappiness swapping' , . SSD- , vm.swappiness = 100 (.. ) . swapping , .. , .

, , , , , — , . , .

vm.swappiness, , Satoru Moriya vmscan 2012 : vm.swappiness = 0.

, vm.swappiness = 0 ( ) , . , , , . vm.swappiness = 1 — , , , .

vm.swappiness = 60. , , . , « swap' ?», vm.swappiness ( ). , refault (. «refault distance-based file cache sizing» — . .), , «page refaulting» cgroup v2.




Source: https://habr.com/ru/post/J348324/


All Articles