Nowadays the Linux memory management of a SAP system (application server) or SAP HANA system is becoming more important as SAP's clear roadmap (Linux as the only OS for HANA) indicates a steep rise in Linux installations.
One of the worst things that can affect system performance is swapping or paging. But are swapping and paging the same?
Many people use the term "paging" when referring to swapping. Swapping is the older method of moving data from memory to disk. To
swap
a process means moving the entire process out of main memory to the swap area on the hard disk, transferring all pages of that process at once.
With
paging
, when the kernel needs more main memory for an active process, only the least recently used pages of processes are moved to the swap space.
Most common Linux systems are mixed-mode systems that use both paging and swapping.
Many customers ask about monitoring to ensure correct system behavior when the used memory approaches the physical memory size. The Unix memory concept differs significantly from how an application handles its memory. OS memory monitoring is not very useful for monitoring HANA systems.
The most popular tools are top (default), htop, and nmon (included in most repositories).
Using ps -ef or ps axu provides a static view of the current processes.
Various memory information such as VSZ/VSS (virtual set size), RSS/RES (resident set size), SHR/SHM (shared memory) is available.
Have you ever totaled these values? In most cases, the total exceeds the physical memory size. How can you determine the real usage of a process and possibly the entire system?
Let's start from top to bottom to gain some insights.
-
Complete system memory
-
Buffer
-
Cache
-
Shared memory
-
Slab
-
Individual process memory usage
-
Collect support details
Test system is a 16GB SLES12 SP4 Application Server with 20 work processes.
Complete system memory
The most popular way to see the complete memory consumption is the command:
free -m
Example:
total used free shared buffers cached
Mem: 16318 15745 573 6548 174 8062
-/+ buffers/cache: 7508 8810
Swap: 12283 2422 9861
Pretty simple to explain:
Total = physical memory
Used = used memory (incl. buffers/caches)
Shared = Shared memory (details see shared memory section)
Free = not allocated memory
Swap = used swap space on disk
-
15.7GB of 16GB are allocated – only 573MB are free
-
7.5GB of 16GB are used by
buffer and caches
The real free memory is
8810MB
. This results from free (573MB), buffers (174MB), and cached (8062MB) => 573+174+8062 = ~8810 MB
Cache
With (Page)Cache and Buffers, it is similar to paging and swapping. Many people confuse these terms.
Pagecache is the caching of file data. When a file is read from disk or network, the contents are stored in pagecache. No disk or network access is required if the contents are up-to-date in pagecache.
Note:
tmpfs
and
shared memory segments
count toward pagecache!
|
Buffer
The buffercache is a type of pagecache for block devices (for example, /dev/sda). A file system typically uses the buffercache when accessing its on-disk metadata structures such as inode tables, allocation bitmaps, and so forth. Buffercache can be reclaimed similarly to pagecache.
These two terms were separate memory areas in Linux Kernel < 2.2. In newer Kernel 2.4+, they are combined to form the pagecache, as the buffer cache writes its mapping of a block into a page. A more common description is the holistic term you may know:
filesystem cache (FS Cache)