Linux Kernel Tuning Anti-Patterns: Why Default vm.swappiness & THP Cause Database Stalls

Technical guide on why default Linux kernel settings force Oracle SGA paging and memory allocation stalls, and how to verify sysctl parameters on your host.

⚡ BLUF (Bottom Line Up Front) Summary

Running Oracle Database or Oracle Linux Virtualization Manager (OLVM) with default kernel settings (vm.swappiness=60 and transparent_hugepage=always) causes severe performance degradation. Default swappiness forces the OS to swap database SGA memory blocks to disk under light pressure, while THP causes dynamic memory allocation freezes. Set vm.swappiness=10, allocate static HugePages, and set transparent_hugepage=never.

Environment & Prerequisites

ComponentVersion / Specification
OSOracle Linux 7/8/9, RHEL 7/8/9, SuSE Enterprise
HypervisorOracle Linux Virtualization Manager (OLVM) 4.4 / KVM
Database EngineOracle Database (11g – 23c)

Introduction: The Hidden Kernel Defaults Killing Database Speed

When installing Linux (Oracle Linux, RHEL, Ubuntu) on a server host, the operating system defaults to general-purpose desktop/web server kernel settings:

  • vm.swappiness = 60
  • transparent_hugepage = always

While suitable for lightweight web servers, these default parameters cause severe latency spikes in memory-intensive databases like Oracle, SQL Server, and Postgres.


Why Default Kernel Settings Destroy Database Performance

1. The Swap Thrashing Penalty (vm.swappiness = 60)

  • The Problem: At swappiness=60, the Linux kernel aggressively reclaims memory by swapping inactive SGA memory pages to disk space—even when 30% of physical RAM is free.
  • The Result: High database wait events on latch: free list and severe disk read I/O delays.

2. Transparent Huge Pages (THP) Memory Freezes

  • The Problem: THP dynamically allocates 2MB memory pages at runtime. Under heavy transaction volumes, the kernel khugepaged thread locks memory spaces to defragment memory.
  • The Result: Random 5-to-30 second complete freezes of the database instance.

🔍 Check Your Environment Now (Diagnostic CTA)

Run the following shell commands on your database or OLVM hypervisor host nodes right now to inspect your kernel settings:

# Diagnostic 1: Check Current Swappiness
sysctl vm.swappiness

# Diagnostic 2: Check Transparent Huge Pages (THP) Status
cat /sys/kernel/mm/transparent_hugepage/enabled

# Diagnostic 3: Check Swap Space Utilization
free -m

What to Look For:

  • vm.swappiness = 60: Incorrect. Host is actively swapping SGA memory blocks.
  • [always] madvise never: Incorrect. THP is enabled and causing allocation freezes.

The Correct Production Kernel Configuration

Apply the following production parameters to /etc/sysctl.conf:

# 1. Reduce swappiness to 10
sysctl -w vm.swappiness=10
echo "vm.swappiness=10" >> /etc/sysctl.conf

# 2. Disable Transparent Huge Pages (THP)
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag

# Add grub kernel boot parameter to persist THP disable across reboot
# In /etc/default/grub: transparent_hugepage=never

Download our free Log Collector & Sanitizer Script or Schedule a Virtualization & OS Audit to audit host kernel parameters.