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

⚠️ Advisory Scope & Terms

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 – 23ai)

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

---

## 📚 Official Documentation & Technical References
- **MOS Doc ID 401749.1:** *HugePages on Linux: What It Is and What It Is Not* Technical reference for static HugePages architecture vs dynamic kernel memory allocation.

- **Oracle Linux Documentation:** [Oracle Linux Administrator's Guide: Memory Management](https://docs.oracle.com/en/operating-systems/oracle-linux/) — Official documentation on kernel parameters, HugePages configuration, and swap tuning.
- **Oracle Database Installation Guide:** [Configuring Kernel Parameters for Linux](https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/configuring-kernel-parameters-for-linux.html) — Memory management guidelines and kernel parameter recommendations for database hosts.
- **ORACLE-BASE:** [Configuring HugePages for Oracle Database on Linux](https://oracle-base.com/articles/linux/configuring-huge-pages-for-oracle-on-linux-64) — Tim Hall's guide to configuring static HugePages and kernel swappiness.

---

Download our free [Log Collector & Sanitizer Script](/tools/sanitizer) or [Schedule a Virtualization & OS Audit](/audits) to audit host kernel parameters.
⚠️INFORMATIONAL & TECHNICAL ADVISORY DISCLAIMER

The diagnostic methodologies, commands, and runbooks provided on DBPros.Net are published for informational and educational purposes only. They do not constitute customized professional consulting advice. Operating engineers and DBAs are solely responsible for securing pre-flight backups (RMAN, VM snapshots, LVM clones), validating changes in non-production staging environments, and adhering to organizational change-control policies. All content, scripts, and runbooks are provided "AS IS" without warranty of any kind, and DBPros.Net assumes no liability for system downtime, database corruption, data loss, or operational disruption. For complete advisory limitations and legal terms, view our full Terms of Service & Advisory Disclaimer.