История изменений
Исправление Vsevolod-linuxoid, (текущая версия) :
Собственно, он пишет о том, что удаление swap может принести только вред, но не пользу, и потому его нужно оставлять:
Whenever you ask for a new memory page from the operating system, the memory manager has to make an educated decision:
-
- Purge a page from the buffer cache
-
- Purge a page from a mapping (effectively the same as #1, on most systems)
-
- Move a page that has not been accessed for a long time – preferably never – to swap (this could in fact even happen proactively, not necessarily at the very last moment)
-
- Kill your process, or kill a random process (OOM)
-
- Kernel panic
Options #4 and #5 are very undesirable and will only happen if the operating system has absolutely no other choice. Options #1 and #2 mean that you throw something away that you will possibly be needing soon again. This negatively impacts performance.
Option #3 means you move something that you (probably) don’t need any time soon onto slow storage. That’s fine because now something that you do need can use the fast RAM.
By removing option #3, you have effectively limited the operating system to doing either #1 or #2. Reloading a page from disk is the same as reloading it from swap, except having to reload from swap is usually less likely (due to making proper paging decisions).
In other words, by disabling swap you gain nothing, but you limit the operation system’s number of useful options in dealing with a memory request. Which might not be, but very possibly may be a disadvantage (and will never be an advantage).
Исходная версия Vsevolod-linuxoid, :
Whenever you ask for a new memory page from the operating system, the memory manager has to make an educated decision:
-
- Purge a page from the buffer cache
-
- Purge a page from a mapping (effectively the same as #1, on most systems)
-
- Move a page that has not been accessed for a long time – preferably never – to swap (this could in fact even happen proactively, not necessarily at the very last moment)
-
- Kill your process, or kill a random process (OOM)
-
- Kernel panic
Options #4 and #5 are very undesirable and will only happen if the operating system has absolutely no other choice. Options #1 and #2 mean that you throw something away that you will possibly be needing soon again. This negatively impacts performance.
Option #3 means you move something that you (probably) don’t need any time soon onto slow storage. That’s fine because now something that you do need can use the fast RAM.
By removing option #3, you have effectively limited the operating system to doing either #1 or #2. Reloading a page from disk is the same as reloading it from swap, except having to reload from swap is usually less likely (due to making proper paging decisions).
In other words, by disabling swap you gain nothing, but you limit the operation system’s number of useful options in dealing with a memory request. Which might not be, but very possibly may be a disadvantage (and will never be an advantage).