Memory swap occurs while the pagecache is reclaimed

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7.2 with a large memory size

Issue

  • If most or all of the memory is consumed in the pagecache and a very large anonymous memory workload is applied to the system swapping can occur at the same time the pagecache memory is being reclaimed for the anonymous workload.
  • The behavior may result in the depletion of the swap space and OOM of processes.

Resolution

  • Disable transparent huge pages (THP) as follows:
echo never > /sys/kernel/mm/transparent_hugepage/enabled

Root Cause

  • Transparent huge pages(THP) (2MB) is enabled by default which consumes free memory much faster than small pages(4KB).
  • Allocating and touching 2MB pages happens 512 times faster than allocating and touching 4KB pages.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments